function swimPaceCompute() {
// convert distances to kilometers
var distanceSwim = document.frmSwim.swimDistance.value;
if (document.frmSwim.swimDistanceUnits[0].checked) { distanceSwim = distanceSwim / 1000; } else if (document.frmSwim.swimDistanceUnits[1].checked) { distanceSwim = distanceSwim * .9144 / 1000; } else if (document.frmSwim.swimDistanceUnits[3].checked) { distanceSwim = convertMilesToKm(distanceSwim); }
//var secondsSwim = document.frmSwim.swimTimeHours.options[document.frmSwim.swimTimeHours.selectedIndex].value * 60 * 60 + document.frmSwim.swimTimeMinutes.options[document.frmSwim.swimTimeMinutes.selectedIndex].value * 60 + document.frmSwim.swimTimeSeconds.options[document.frmSwim.swimTimeSeconds.selectedIndex].value * 1; var secondsSwim = document.frmSwim.swimHH.value * 60 * 60 + document.frmSwim.swimMM.value * 60 + document.frmSwim.swimSS.value * 1;
var speedSwim = distanceSwim / secondsSwim * 60 * 60;
var paceSwim = secondsSwim / distanceSwim;
if(document.frmSwim.swimPaceUnits[0].checked) { // /100m paceSwim = paceSwim / 1000 * 100; } else { paceSwim = paceSwim / 1000 * 100 * 0.9144; }
document.frmSwim.swimPace.value = secondsToTime(paceSwim);
if(document.frmSwim.swimSpeedUnits[1].checked) {
// convert from km to miles speedSwim = convertKmToMiles(speedSwim); }
document.frmSwim.swimSpeed.value = speedSwim;
}
function bikeSpeedCompute() {
//var secondsBike = document.frmBike.bikeTimeHours.options[document.frmBike.bikeTimeHours.selectedIndex].value * 60 * 60 + document.frmBike.bikeTimeMinutes.options[document.frmBike.bikeTimeMinutes.selectedIndex].value * 60 + document.frmBike.bikeTimeSeconds.options[document.frmBike.bikeTimeSeconds.selectedIndex].value * 1;
var secondsBike = document.frmBike.bikeHH.value * 60 * 60 + document.frmBike.bikeMM.value * 60 + document.frmBike.bikeSS.value * 1;
var speedBike = document.frmBike.bikeDistance.value / secondsBike * 60 * 60;
if(document.frmBike.bikeDistanceUnits[0].checked && document.frmBike.bikeSpeedUnits[1].checked) {
// convert from km to miles speedBike = convertKmToMiles(speedBike);
} else if (document.frmBike.bikeDistanceUnits[1].checked && document.frmBike.bikeSpeedUnits[0].checked) {
//convert from miles to km speedBike = convertMilesToKm(speedBike);
}
document.frmBike.bikeSpeed.value = speedBike;
}
function runPaceCompute() {
//var secondsRun = document.frmRun.runTimeHours.options[document.frmRun.runTimeHours.selectedIndex].value * 60 * 60 + document.frmRun.runTimeMinutes.options[document.frmRun.runTimeMinutes.selectedIndex].value * 60 + document.frmRun.runTimeSeconds.options[document.frmRun.runTimeSeconds.selectedIndex].value * 1; var secondsRun = document.frmRun.runHH.value * 60 * 60 + document.frmRun.runMM.value * 60 + document.frmRun.runSS.value * 1;
var paceRun = secondsRun / document.frmRun.runDistance.value
if(document.frmRun.runDistanceUnits[0].checked && document.frmRun.runPaceUnits[1].checked) {
paceRun = convertMilesToKm(paceRun);
} else if (document.frmRun.runDistanceUnits[1].checked && document.frmRun.runPaceUnits[0].checked) {
paceRun = convertKmToMiles(paceRun);
}
paceRun = secondsToTime(paceRun) document.frmRun.runPace.value = paceRun;
var speedRun = document.frmRun.runDistance.value / secondsRun * 60 * 60;
if(document.frmRun.runDistanceUnits[0].checked && document.frmRun.runSpeedUnits[1].checked) {
// convert from km to miles speedRun = convertKmToMiles(speedRun);
} else if (document.frmRun.runDistanceUnits[1].checked && document.frmRun.runSpeedUnits[0].checked) {
//convert from miles to km speedRun = convertMilesToKm(speedRun);
}
document.frmRun.runSpeed.value = speedRun;
}
function secondsToTime(secs) {
var ret = ""; // Return value var s = Math.floor(secs); // Whole seconds var m = Math.floor(s/60); // Whole minutes var h = Math.floor(m/60); // Whole hours
if (h < 10) ret += "0"; ret += h; ret += ":"; var m = m%60; if (m < 10) ret += "0"; ret += m; var s = s%60; ret += ":"; if (s < 10) ret += "0"; ret += s; return ret; } function convertMilesToKm(inputValue) { return inputValue * 1.609344; } function convertKmToMiles(inputValue) { return inputValue * 0.621371192; } function convertMToYd(inputValue) { return inputValue / 0.9144; } function convertYdToM(inputValue) { return inputValue * 0.9144; } function distanceCompute() { var inputDistance = document.frmDistance.inputDistance.value; // convert everything back to meters if (document.frmDistance.inputDistanceUnits[1].checked) { inputDistance = convertYdToM(inputDistance); } else if (document.frmDistance.inputDistanceUnits[2].checked) { inputDistance = inputDistance * 1000; } else if (document.frmDistance.inputDistanceUnits[3].checked) { inputDistance = convertMilesToKm(inputDistance) * 1000; } if (document.frmDistance.outputDistanceUnits[1].checked) { outputDistance = convertMToYd(inputDistance) } else if (document.frmDistance.outputDistanceUnits[2].checked) { outputDistance = inputDistance / 1000; } else if (document.frmDistance.outputDistanceUnits[3].checked) { outputDistance = convertKmToMiles(inputDistance / 1000); } else { outputDistance = inputDistance; } document.frmDistance.outputDistance.value = outputDistance; } function runPaceConvert() { var timeSeconds = document.frmRunPace.runHH.value * 60 * 60 + document.frmRunPace.runMM.value * 60 + document.frmRunPace.runSS.value * 1; var secondsPerKM = timeSeconds; // If Min/Mile entered, convert to seconds per Km if (document.frmRunPace.runPaceUnits0[1].checked) { secondsPerKM = convertKmToMiles(secondsPerKM); } var outputSeconds = secondsPerKM; // If Min/Mile requested, convert to Min/Mile if (document.frmRunPace.runPaceUnits[1].checked) { outputSeconds = convertMilesToKm(secondsPerKM); } // Output converted pace time document.frmRunPace.runPace.value = secondsToTime(outputSeconds); var kPH = 1 / (secondsPerKM / 60 / 60 ); var outputSpeed = kPH; // If MPH, then convert if (document.frmRunPace.runSpeedUnits[1].checked) { outputSpeed = convertKmToMiles(outputSpeed); } document.frmRunPace.runSpeed.value = outputSpeed; }
Recent Comments