l>Track Calculator// multiplication factors supplied to transform one unit of measure to an additional where: F=foot, I=inch, K=kilometer, L=mile, M=meter, Y=yard// all components are based on 1 foot = .3048 meters// to transform from one unit to an additional, multiply the "from" value by the factor presented in the following table:// TO CONVERT to METERS to KILOMETERS to INCHES to FEET to YARDS to MILES// from METERS = 1/1000 12/.3048 1/.3048 1/(3*.3048) 1/(5280*.3048)// from KILOMETERS 1000 = 12000/.3048 1000/.3048 1000/3*.3048) 1000/(5280*.3048)// from INCHES .3048/12 .3048/12000 = 1/12 1/36 1/(12*5280)// from FEET .3048 .3048/1000 12 = 1/3 1/5280// from YARDS 3*.3048 (3*.3048)/1000 36 3 = 1/1760// from MILES 5280*.3048 (5280*.3048)/1000 12*5280 5280 1760 =//// develop translation components - all intermediate calculations are made in metersvar xbasis = .3048 * 1; // define standard foot-to-meter relationshipvar xF2M = xbasis * 1; // from feet to metersvar xI2M = xbasis / 12; // from inches to metersvar xK2M = 1000 * 1; // from kilometers to metersvar xL2K = ( 5280 * .3048 ) / 1000; // from miles to kilometersvar xL2M = 5280 * xbasis; // from miles to metersvar xM2K = 1 / 1000; // from meters to kilometersvar xM2L = 1 / (5280 * xbasis ); // from meters to milesvar xY2M = 3 * xbasis; // from yards to metersvar inchesPerMeter = 12 * ( 1 / .3048 );var metersPerInch = 1 / inchesPerMeter;var kilosPerMile = metersPerInch * 12 * 5280 / 1000;var milesPerKilo = 1 / kilosPerMile;var error = false;var laneDistK = new Array(8);var laneDistL = new Array(8);var laneDistM = brand-new Array(8);var laneLenM = new Array(8);var lanePaceM = new Array(8);var laneTime = new Array(8);var lapCount = 0;var lapsCalc = new Array(8);// track size defaults: 400 meters in Lane 1var trackSizeM = 400 * 1;var smork = 1 * 1;var refLane = 1 * 1;// lane width defaults: 42 inchesvar laneWidthM = 42 * xI2M;// curb default: novar curb = "N";// create occupational arraysvar zhrs = brand-new Array(8);var zminutes = new Array(8);var zseconds = brand-new Array(8);var ztime = brand-new Array(8);var ztotalsecs = brand-new Array(8);// -----------------------------------------------------------// CALCULATE LANE LENGTHS IN METERS// gather and edit input values -- just print one error at a time to prevent confusion// -----------------------------------------------------------feature calcLaneLengths(track) trackSizeM = document.track.trackSize.worth * 1;smork = (document.track.smork.options.value);refLane = (document.track.refLane.options.value);laneWidthM = document.track.laneWidth.value * 1;wmork = (record.track.wmork.options.value);curb = record.track.curb.options.value;// ---------- process track sizeif ( smork == "F" ) trackSizeM = trackSizeM * xF2M; // convert feet to meters else if ( smork == "Y" ) trackSizeM = trackSizeM * xY2M; // convert yards to metersif ( trackSizeM = 501 ) if ( ! confirm ( "Warning: Track dimension is more than 500 meters (547 yeard). Proceed?" ) ) error = true;return; // ---------- process lane widthif ( wmork == "I" ) laneWidthM = laneWidthM * xI2M; // transform inches to metersif ( laneWidthM = 1.5 ) if ( ! confirm ( "Warning: Lane width is even more than 1.5 meters (59 inches). Proceed?" ) ) error = true;return;// ---------- develop size of Lane 1if ( refLane >= 2 ) trackSizeM = trackSizeM - ( ( refLane - 1 ) * ( 2 * laneWidthM * Math.PI ) );// ---------- calculate size of Lanes 2-8laneLenM<1> = trackSizeM;for ( var i = 2; i = 60 ) // include up minuteswtotalsecs -= 60;wmins += 1;while ( wtotalsecs >= .50 ) // add up secondswtotalsecs -= 1;wsecs += 1;minphrase = 100 + wmins + "x";secphrase = 100 + wsecs + "x";ztime = minexpression.substring(1,3) + ":" + secphrase.substring(1,3);}// -----------------------------------------------------------// CALCULATE TIME PHRASES FROM TOTAL SECONDS -- IN TENTHS OF SECOND// -----------------------------------------------------------feature calcTime10(track) for ( var i = 1; i = 60 ) // add up minuteswtotalsecs -= 60;wmins += 1;while ( wtotalsecs >= 1 ) // add up secondswtotalsecs -= 1;wsecs += 1;while ( wtotalsecs >= .05 ) // include up 10ths of a secondwtotalsecs -= .1;w10s += 1;minphrase = 100 + wmins + "x";secexpression = 100 + wsecs + "x";tenexpression = 100 + wtens + "X";ztime = minexpression.substring(1,3) + ":" + secexpression.substring(1,3) + "." + tenphrase.substring(2,3);}// -----------------------------------------------------------// A - CALCULATE LAPS BASED ON DISTANCE// -----------------------------------------------------------function calcA(track) {record.track.alaps1.worth = "";record.track.alaps2.worth = "";document.track.alaps3.worth = "";document.track.alaps4.value = "";record.track.alaps5.value = "";record.track.alaps6.worth = "";record.track.alaps7.worth = "";record.track.alaps8.value = "";calcLaneLengths(track); if ( error ) return zdist = document.track.adist.worth * 1;zmork = (record.track.amork.options.value);if ( zmork == "K" ) zdist = zdist * xK2M; // transform kilometers to meters else zdist = zdist * xL2M; // convert miles to metersif ( zdist = 21 ) alert ( "Error: Minutes need to be from 2 to 20 -- please reenter." );return;if ( zs = 60 ) alert ( "Error: Seconds must be from 0 to 59.99 -- please reenter." );return;if ( zmork == "L" ) zsecsperM = ( ( zm * 60) + zs ) / xL2M; else zsecsperM = ( ( zm * 60 ) + zs ) / xK2M;for ( var i = 1; i = 11 ) alert ( "Error: Minutes need to be from 0 to 10 -- please reenter." );return;if ( zs = 60 ) alert ( "Error: Seconds must be from 0 to 59.99 -- please reenter." );return;zlapsecs = ( zm * 60) + zs;for ( var i = 1; i = 11 ) alert ( "Error: Minutes need to be from 0 to 10 -- please reenter." );return;if ( zs = 60 ) alert ( "Error: Seconds have to be from 0 to 59.99 -- please reenter." );return;zlap1secs = ( ( zm * 60 ) + zs ) * ( laneLenM<1> / laneLenM );for ( var i = 1; i
*