网页脚本里代码的含义
发布网友
发布时间:2022-11-11 09:50
我来回答
共1个回答
热心网友
时间:2024-11-30 00:37
function runcalcs(){
var racetime = 0;
var racelength = 0;
var racespeed = 0;
racetime = document.forms.inputs.hours.value * 60;
racetime += document.forms.inputs.hours1.value * 1;
racetime += document.forms.inputs.hours2.value / 60;
if(racetime <= 0 || isNaN(racetime)){
alert("You did not enter a valid race time.");
return;
}
racelength = document.forms.inputs.distance.value * 1;
if(racelength <=0 || isNaN(racelength)){
alert("You did not enter a valid race distance.");
return;
}
if(document.forms.inputs.units[0].checked) racelength *=1609;
else racelength *=1000;
var intime=racetime*60;
var indist=racelength/1609;
var fac = intime/((3600/(13.49681-(.048865*indist)+(2.438936/(Math.pow(indist,0.7905)))))*indist);
document.forms.equivtimes.t800.value = "" + convtotime(fac*101.020796);
document.forms.equivtimes.t1500.value = "" + convtotime(fac*209.56359);
document.forms.equivtimes.tmile.value = "" + convtotime(fac*226.60206);
document.forms.equivtimes.t3000.value = "" + convtotime(fac*450.46813);
document.forms.equivtimes.t2mile.value = "" + convtotime(fac*486.18638);
document.forms.equivtimes.t5k.value = "" + convtotime(fac*779.978107);
document.forms.equivtimes.t10k.value = "" + convtotime(fac*1625.00956);
document.forms.equivtimes.t10mile.value = "" + convtotime(fac*2685.914933);
document.forms.equivtimes.thalfm.value = "" + convtotime(fac*3581.90674);
document.forms.equivtimes.tmarathon.value = "" + convtotime(fac*7611.95023);
racespeed=racelength/racetime;
VO2max = (-4.6 + .182258 * racespeed + .000104 * racespeed * racespeed) / (.8 + .1894393 * Math.exp(-.012778 * racetime) + .2989558 * Math.exp(-.1932695 * racetime));
document.forms.paces.easy.value = calcpace(VO2max * .7);
document.forms.paces.tempo.value = calcpace(VO2max * .88);
document.forms.paces.vo2max.value = calcpace(VO2max);
document.forms.paces.speed.value = calcpace(VO2max * 1.1);
document.forms.paces.plong.value = "" + calcpace(VO2max * .7) + " to " + calcpace(VO2max * .6);
document.forms.paces.marathon.value = calcpace(VO2max * .823);
}
function calcpace(VO2){
var pace =0;
var pacevel = (29.54+ 5.000663 * VO2 - .007546 * VO2 * VO2);
if(document.forms.inputs.units[0].checked) pace =(1/pacevel) * 1609;
else pace =(1/pacevel) * 1000;
minutes = Math.floor(pace);
seconds = Math.floor((pace-minutes)*60);
if(seconds>9) return "" + minutes + ":" + seconds;
else return "" + minutes + ":0" + seconds;
}
function convtotime(timesec){
var hours = Math.floor(timesec/3600);
var minutes = Math.floor((timesec-hours*3600)/60);
var seconds = Math.floor(timesec-hours*3600-minutes*60);
if(seconds==0) seconds=":00";
if(seconds<10 && seconds!=0) seconds=":0" + seconds;
if(seconds>9) seconds=":" + seconds;
if(hours!=0){
if(minutes==0) minutes=":00";
if(minutes<10 && minutes!=0) minutes=":0" + minutes;
if(minutes>9) minutes=":" + minutes;
}
if(hours==0) hours="";
return ("" + hours + minutes + seconds);
}
对于这些公式不是很明白。。按照他写的就是啦。。
追问能举了个例子计算吗?比如输入10公里/50分钟,是在看不懂赋值过程。
追答racetime = document.forms.inputs.hours.value * 60; 小时
racetime += document.forms.inputs.hours1.value * 1; 分
racetime += document.forms.inputs.hours2.value / 60;秒
上面就是获取50分钟的换成秒数 racetime就是最后的秒数
======================
太多了。。我问你你会不会js的。。不会js那你会不会编程 要是连编程都不会 那就不用看了。。