Shadowed SVG Text


CSS has the text-shadow property that allows text to be shadowed. SVG text does not have the same property. If shadowed text is needed with SVG, it is possible to use Foreign Object and than the CSS text. However, sometimes there is an advantage to using SVG text, such as putting a border on the text.
This is a method for creating shadowed SVG text.
Here is an example:

Click Image for larger view

shadowsvgtext

Here is he code;

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'&gt;
<html xmlns='http://www.w3.org/1999/xhtml'&gt;
<head profile='http://gmpg.org/xfn/11'&gt;
<title>Enter Title Here</title>
<style>
body {margin-left:0;margin-right:0;font:normal normal normal 15pt Arial;}a{ text-decoration: }:link { color: rgb(0, 0, 255) }:visited {color :rgb(100, 0,100) }:hover { }:active { } #svg1{position: absolute; width: 100%; height: 100%; top:0}
</style>
</head>
<body>
<svg id=”svg1″ xmlns=”http://www.w3.org/2000/svg&#8221; version=”1.1″ width=”” height=””>
<defs>
<filter id=”shadow”>
<feGaussianBlur stdDeviation=”4″/>
</filter>
</defs>
<g transform=”translate(8,8)”>
<text x=”100″ y=”100″ style=”fill: #666666 ; stroke: #666666; stroke-width:3 ; filter:url(#shadow); font-size: 72pt; font-family: Comic Sans MS; font-style: italic; font-weight: 800″>Text</text>
</g>
<text x=”100″ y=”100″ style=”fill:#ff5500 ; stroke: black; stroke-width:3 ; font-size: 72pt; font-family: Comic Sans MS; font-style:italic ; font-weight: 800″>Text</text>
</svg>
</body></html>


a shadow filter is created:
<defs>
<filter id=”shadow”>
<feGaussianBlur stdDeviation=”4″/>
</filter>
</defs>

This is then applied to text the same font and size as the desired text, and the shadow is translated:
<g transform=”translate(8,8)”>
<text x=”100″ y=”100″ style=”fill: #666666 ; stroke: #666666; stroke-width:3 ; filter:url(#shadow); font-size: 72pt; font-family: Comic Sans MS; font-style: italic; font-weight: 800″>Text</text>
</g>

The desired text is then added:
<text x=”100″ y=”100″ style=”fill:#ff5500 ; stroke: black; stroke-width:3 ; font-size: 72pt; font-family: Comic Sans MS; font-style:italic ; font-weight: 800″>Text</text>

Adding Code to Posts


My previous post showed how to convert tag brackets to symbols so they would not be interpreted. This is needed to list code in WordPress.
Other than the script tags, javascript can be viewed directly as text.
Converting tag brackets is however, not sufficient to properly display a page with code. I have therefore written some wrapper code for displaying pages:

<span style=”font-size: 14pt; white-space: pre-wrap;”>
</span>
<div style=”white-space:pre-wrap;font:normal normal normal 15pt Arial;background:#CCCCCC;padding:5px;”>
</div>


The code is placed in a formatted division while all non-code is placed inside span tags.

Here is the code for the demo:

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'&gt;
<html xmlns='http://www.w3.org/1999/xhtml'&gt;
<head profile='http://gmpg.org/xfn/11'&gt;
<title>Enter Title Here</title>
<style>
body {margin-left:0;margin-right:0;font:normal normal normal 15pt Arial;}a{ text-decoration: }
:link { color: rgb(0, 0, 255) }:visited {color :rgb(100, 0,100) }:hover { }:active { } input{position: relative; left: 12px; font:normal normal normal 15pt Arial}
</style>
</head>
<body>
<input type=”text” id=”t1″ name=”t1″ value=”text1″ /><br />
<input type=”button” id=”b1″ name=”b1″ value=”button” onclick=’func();’/>

function func() {
document.getElementById(“t1”).value = “button clicked”;
}

</body></html>


The post is written offline and pasted into the Text tab of WordPress. The Visual tab is not used at all and the post is checked only with the Preview.

HTML: Replace Every Occurrence of a String in a TextArea


I had previously discussed a HTML editor written in HTML, which I use to create code on my Chromebook. This editor is based on a textarea. It lacked one feature however; the ability to replace multiple strings of text. This omission has now been remedied. This post is a model of how that can be done. It can replace every occurrence of multiple strings of text.

Here is how a textarea appears before the text replacement:

Click Image for larger view

orig

Here is how it appears after the brackets have been replaced with symbols:

Click Image for larger view

replaced

here is the code:

 

<!DOCTYPE html PUBLIC ‘-//W3C//DTD XHTML 1.0 Transitional//EN’ ‘http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd’&gt;
<html xmlns=’http://www.w3.org/1999/xhtml’&gt;
<head profile=’http://gmpg.org/xfn/11′&gt;
<title>Enter Title Here</title>
<style>
body {margin-left:0;margin-right:0;font:normal normal normal 15pt Arial;}a{ text-decoration: }:link { color: rgb(0, 0, 255) }:visited {color :rgb(100, 0,100) }:hover { }:active { } #no,#b1,#ta2{position: relative; left: 10px; padding; 2px; font:normal normal normal 15pt Arial}
</style>
</head>
<body>
<input type=”text” id=”no” name=”no” value=”# to replace” /><br />
<input type=”button” id=”b1″ name=”b1″ value=”replace” onclick=’repl();’ /><br />
<textarea id=”ta2″ name=”ta2″ rows=”20″ cols=”50″></textarea>function repl() {
var cnt = parseInt(document.getElementById(“no”).value);
for (var i=1; i
</body></html>

 

The interface has a text input, textarea and button. The text input determines the number of strings to be replaced. On clicking the button, a function repl() is called:
function repl() {
var cnt = parseInt(document.getElementById(“no”).value);
for (var i=1; i <=cnt; i ++) {
var srch = prompt(“replace,replace with”, “”);
var a = srch.indexOf(“,”);
var rpl = srch.substr(a + 1);
srch = srch.substr(0,a);
document.getElementById(“ta”).value = replaceAll(document.getElementById(“ta”).value, srch, rpl);
}
}

A prompt is called multiple times to set the find and replace strings, separated by a comma. The outputs of the prompts are parsed and a function replaceAll is called to do the replacement, by means of a Regular Expression:
document.getElementById(“ta”).value = replaceAll(document.getElementById(“ta”).value, srch, rpl);

function replaceAll (str, search, replacement) {
var test2 = str.replace(new RegExp(search, ‘g’),replacement);
return test2;
}

The code section of this post is written using this method.

A HTML Fitness Calculator with Tabulation

To use this calculator Click Here.    

Click Calculators on the menu

This calculator is designed primarily but not exclusively for runners.

Here is what can be calculated:

Click Image for larger view

fitnessgui

Whem a calculation is chosen, the interface automaticall displays what must be entereed:

Click Image for larger view

calcgui

When data us entered, clicking Cakculate will show the result:

Click Image for larger view

calc

Clicking Show Table will display multiple results as a table:

Click Image for larger view

table

Here is the code:


<html><head>
<style>
body{white-space: pre-wrap; font: normal normal normal 12pt Arial}
</style></head>
<body>
A HTML Fitness Calculator with Tabulation
This calculator is designed primarily but not exclusively for runners.
Here is what can be calculated:
Click Image for larger view
<img src="file:///home/chronos/u-1eb10e124afb2b2cad22d7f9b971259b7789c079/Downloads/fitnessGUI.png" width="500" />
Whem a calculation is chosen, the interface automaticall displays what must be entereed:
Click Image for larger view
<img src="file:///home/chronos/u-1eb10e124afb2b2cad22d7f9b971259b7789c079/Downloads/calcGUI.png" width="500" />
When data us entered, clicking Cakculate will show the result:
Click Image for larger view
<img src="file:///home/chronos/u-1eb10e124afb2b2cad22d7f9b971259b7789c079/Downloads/calc.png" width="500" />
Clicking Show Table will display multiple results as a table:
Click Image for larger view
<img src="file:///home/chronos/u-1eb10e124afb2b2cad22d7f9b971259b7789c079/Downloads/table.png" width="500" />
Here is the code:
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'&gt;
<html xmlns='http://www.w3.org/1999/xhtml'&gt;
<head profile='http://gmpg.org/xfn/11'&gt;
<title>Fitness Calculator</title>
<style type='text/css'>
body {margin-left:0;margin-right:0;font:normal normal 800 12pt Arial; background: #EEE999}
a{ text-decoration: }
:link { color: rgb(0, 0, 255) }
:visited {color :rgb(100, 0,100) }
:hover { }
:active { }
input, select{font:normal normal 800 12pt Arial}
input{visibility: hidden}
#c2{visibility: visible}
#s1{width: 160pt}
#s2,#s3,#h1{visibility: hidden; width: 80pt}
.frame{position: relative; left: 5px}
#d1{position: relative; left:5px}
#table1{position: absolute; width: 100%; height: 100%; visibility: hidden; top: 0; background: white}
td{padding: 2px 40px 2px 10px}
</style>
</head>
<body>
<div class="frame">
<select id="s1" onchange='params();' >
<option>Choose Calculation</option>
<option>Male Body Fat</option>
<option>Female Body Fat</option>
<option>Metabolism</option>
<option>VO2Max</option>
<option> Equivalent Time</option>
<option>Female Age Conversion</option>
<option>Male Age Conversion</option>
<option>Male WAVA %</option>
<option>Female WAVA %</option>
</select> <input type="checkbox" id="c2"name="c2" value="Add Name" /><h id="h2">add name</h>
<select id="s2">
<option>distance1</option>
<option>1500 m</option>
<option>3K</option>
<option>5K</option>
<option>8K</option>
<option>10K</option>
<option>12K</option>
<option>15K</option>
<option>20K</option>
<option>half</option>
<option>25K</option>
<option>30K</option>
<option>marathon</option>
</select>
<select id="s3">
<option>distance2</option>
<option>1500 m</option>
<option>3K</option>
<option>5K</option>
<option>8K</option>
<option>10K</option>
<option>12K</option>
<option>15K</option>
<option>20K</option>
<option>half</option>
<option>25K</option>
<option>30K</option>
<option>marathon</option>
</select><br /><br />
<input type="text" id="t1"name="t1" value="" /> <input type="text" id="t2" name="t2" value="" /> <input type="text" id="t3" name="t3" value="" /> <input type="text" id="t4" name="t4" value="" /> <input type="text" id="t5" name="t5" value="" /><br /><br />
<input type="button" id="b1"name="b1" value="Calculate" onclick='calc();' /> <input type="button" id="b2"name="b2" value="Show Table" onclick='table();' /><input type="checkbox" id="c1" name="c1"value="metric" ><h id="h1">metric</h>
<br /><br /><br />
<input type="text" id="res"name="res" value="result" /><br /><br /><br />
</div>
<div id="d1" onclick='document.getElementById("d1").style.visibility="hidden";'> Instructions:<br /><br /> Calculator will work whether these instructions are visible or not.<br /><br /> If metric is checked, weight is in kg and waist, height, hips and neck are in meters, else they are in pounds and inches.<br /><br />
If you want to add names to the rows, check add name before selecting the calculation. It must be checked or not checked for every calculation of that set, but can be changed for a different type calculation. The actual name can be left blank.<br /><br />
Select a value from Choose Calculation to start. All values to be entered for that calculation will be displayed.<br /><br />
Be certain to enter every value, such as distance1 and distance2, or you will get an error.<br /><br />
For Equivalent Time, entered time is that of distance1<br /><br />
If a value of hours, minutes or seconds is 0, enter 0 or 00.<br /><br />
Single digit numbers can be entered as either the number or 0 plus the number, eg; 08.<br /><br />
Click Show Table to view an editable generated table. The table can be closed by double clicking it, to add more records.<br /><br />
Click Here to Close Instructions</div>
<div id="table1" contenteditable="true" ondblclick='document.getElementById("table1").style.visibility = "hidden";'; ></div>
<script type='text/javascript'>
var res; var std; var strtable = '<table style="empty-cells: hide"><tr><td colspan="20">'; var nm = ""; var init = "";
var K1w =[1,1,0.9999,0.9922,0.9845,0.9768,0.9691,0.9613,0.9536,0.9458,0.9381,0.9303,0.9225,0.9146,0.9068,0.8990,0.8910,0.8831,0.8751,0.8672,0.8592,0.8510,0.8428,0.8347,0.8265,0.8183,0.8098,0.8013,0.7928,0.7843,0.7758,0.7669,0.7579,0.7490,0.7400,0.7311,0.7216,0.7121,0.7025,0.6930,0.6835,0.6732,0.6630,0.6527,0.6425,0.6322,0.6210,0.6098,0.5985,0.5873,0.5761,0.5635,0.5509,0.5384,0.5258,0.5132];
var K3 = [1,1,1,1,0.9939,0.9862,0.9784,0.9707,0.9629,0.9552,0.9474,0.9396,0.9317,0.9239,0.9239,0.9160,0.9082,0.9002,0.8922,0.8843,0.8763,0.8683,0.8601,0.8519,0.8437,0.8355,0.8273,0.8188,0.8103,0.8017,0.7932,0.7847,0.7757,0.7668,0.7578,0.7489,0.7399,0.7304,0.7208,0.7113,0.7017,0.6922,0.6819,0.6716,0.6614,0.6511,0.6408,0.6296,0.6183,0.6071,0.5958,0.5846,0.5720,0.5594,0.5468,0.5342,0.5216];
var K5w = [1 ,1 ,1 ,1 ,0.9947 ,0.987 ,0.9792 ,0.9715 ,0.9637 ,0.956 ,0.9482 ,0.9404 ,0.9325 ,0.9247 ,0.9168 ,0.909 ,0.901 ,0.893 ,0.8851 ,0.8771 ,0.8691 ,0.8609 ,0.8527 ,0.8445 ,0.8363 ,0.8281 ,0.8196 ,0.8111 ,0.8025 ,0.794 ,0.7855 ,0.7765 ,0.7676 ,0.7586 ,0.7497 ,0.7407 ,0.7312 ,0.7216 ,0.7121 ,0.7025 ,0.693 ,0.6827 ,0.6724 ,0.6622 ,0.6519 ,0.6416 ,0.6304 ,0.6191 ,0.6079 ,0.5966 ,0.5854 ,0.5728 ,0.5602 ,0.5476 ,0.535 ,0.5224];
var K8w = [1 ,1 ,1 ,1 ,1 ,0.9954 ,0.9876 ,0.9798 ,0.9721 ,0.9643 ,0.9565 ,0.9486 ,0.9408 ,0.9329 ,0.9251 ,0.9172 ,0.9092 ,0.9012 ,0.8932 ,0.8852 ,0.8772 ,0.869 ,0.8608 ,0.8525 ,0.8443 ,0.8361 ,0.8276 ,0.819 ,0.8105 ,0.8019 ,0.7934 ,0.7844 ,0.7754 ,0.7665 ,0.7575 ,0.7485 ,0.7389 ,0.7294 ,0.7198 ,0.7103 ,0.7007 ,0.6904 ,0.6801 ,0.6698 ,0.6595 ,0.6492 ,0.6379 ,0.6267 ,0.6154 ,0.6042 ,0.5929 ,0.5803 ,0.5677 ,0.555 ,0.5298 ];
var K10w = [1 ,1 ,1 ,1 ,0.9974 ,0.9896 ,0.9818 ,0.9741 ,0.9663 ,0.9585 ,0.9506 ,0.9428 ,0.9349 ,0.9271 ,0.9192 ,0.9112 ,0.9032 ,0.8952 ,0.8872 ,0.8792 ,0.871 ,0.8628 ,0.8545 ,0.8463 ,0.8381 ,0.8296 ,0.821 ,0.8125 ,0.8039 ,0.7954 ,0.7864 ,0.7774 ,0.7685 ,0.7595 ,0.7505 ,0.7409 ,0.7314 ,0.7218 ,0.7123 ,0.7027 ,0.6924 ,0.6821 ,0.6718 ,0.6615 ,0.6512 ,0.6399 ,0.6287 ,0.6174 ,0.6062 ,0.5949 ,0.5823 ,0.5697 ,0.557 ,0.5444 ,0.5318];
var K12w = [1 ,1 ,1 ,1 ,0.9991 ,0.9913 ,0.9835 ,0.9758 ,0.968 ,0.9602 ,0.9523 ,0.9445 ,0.9366 ,0.9288 ,0.9209 ,0.9129 ,0.9049 ,0.8969 ,0.8889 ,0.8809 ,0.8727 ,0.8645 ,0.8562 ,0.848 ,0.8398 ,0.8313 ,0.8227 ,0.8142 ,0.8056 ,0.7971 ,0.7881 ,0.7791 ,0.7702 ,0.7612 ,0.7522 ,0.7426 ,0.7331 ,0.7235 ,0.714 ,0.7044 ,0.6941 ,0.6838 ,0.6735 ,0.6632 ,0.6529 ,0.6416 ,0.6304 ,0.6191 ,0.6079 ,0.5966 ,0.584 ,0.5714 ,0.5587 ,0.5461 ,0.5335];
var K15w = [1 ,1 ,1 ,1 ,1 ,0.9934 ,0.9856 ,0.9779 ,0.9701 ,0.9623 ,0.9544 ,0.9466 ,0.9387 ,0.9309 ,0.923 ,0.915 ,0.907 ,0.899 ,0.891 ,0.883 ,0.8748 ,0.8666 ,0.8583 ,0.8501 ,0.8419 ,0.8334 ,0.8248 ,0.8163 ,0.8077 ,0.7992 ,0.7902 ,0.7812 ,0.7723 ,0.7633 ,0.7543 ,0.7447 ,0.7352 ,0.7256 ,0.7161 ,0.7065 ,0.6962 ,0.6859 ,0.6756 ,0.6653 ,0.655 ,0.6437 ,0.6325 ,0.6212 ,0.61 ,0.5987 ,0.5861 ,0.5735 ,0.5608 ,0.5482 ,0.5356];
var K20w = [1 ,1 ,1 ,1 ,1 ,1 ,0.9963 ,0.9885 ,0.9807 ,0.9729 ,0.9651 ,0.9572 ,0.9493 ,0.9415 ,0.9336 ,0.9257 ,0.9177 ,0.9097 ,0.9016 ,0.8856 ,0.8774 ,0.8691 ,0.8609 ,0.8526 ,0.8444 ,0.8358 ,0.8273 ,0.8187 ,0.8102 ,0.8016 ,0.7926 ,0.7836 ,0.7746 ,0.7656 ,0.7566 ,0.747 ,0.7374 ,0.7279 ,0.7183 ,0.7087 ,0.6984 ,0.6881 ,0.6777 ,0.6674 ,0.6571 ,0.6458 ,0.6345 ,0.6233 ,0.612 ,0.6007 ,0.5881 ,0.5754 ,0.5628 ,0.5501 ,0.5375];
var Khalfw = [1 ,1 ,1 ,1 ,1 ,1 ,0.9969 ,0.9891 ,0.9813 ,0.9735 ,0.9657 ,0.9578 ,0.9499 ,0.9421 ,0.9342 ,0.9263 ,0.9183 ,0.9103 ,0.9022 ,0.8862 ,0.878 ,0.8697 ,0.8615 ,0.8532 ,0.845 ,0.8364 ,0.8279 ,0.8193 ,0.8108 ,0.8022 ,0.7932 ,0.7842 ,0.7752 ,0.7662 ,0.7572 ,0.7476 ,0.738 ,0.7285 ,0.7189 ,0.7093 ,0.699 ,0.6887 ,0.6783 ,0.668 ,0.6577 ,0.6464 ,0.6351 ,0.6239 ,0.6126 ,0.6013 ,0.5887 ,0.576 ,0.5634 ,0.5507 ,0.5381];
var K25w = [1 ,1 ,1 ,1 ,1 ,1 ,0.9988 ,0.991 ,0.9832 ,0.9754 ,0.9676 ,0.9597 ,0.9518 ,0.944 ,0.9361 ,0.9282 ,0.9202 ,0.9122 ,0.9041 ,0.8881 ,0.8799 ,0.8716 ,0.8634 ,0.8551 ,0.8469 ,0.8383 ,0.8298 ,0.8212 ,0.8127 ,0.8041 ,0.7951 ,0.7861 ,0.7771 ,0.7681 ,0.7591 ,0.7495 ,0.7399 ,0.7304 ,0.7208 ,0.7112 ,0.7009 ,0.6906 ,0.6802 ,0.6699 ,0.6596 ,0.6483 ,0.637 ,0.6258 ,0.6145 ,0.6032 ,0.5906 ,0.5779 ,0.5653 ,0.5526 ,0.54 ];
var K30w = [1 ,1 ,1 ,1 ,1 ,1 ,1 ,0.9932 ,0.9854 ,0.9776 ,0.9698 ,0.9619 ,0.954 ,0.9462 ,0.9383 ,0.9304 ,0.9224 ,0.9144 ,0.9063 ,0.8903 ,0.8821 ,0.8738 ,0.8656 ,0.8573 ,0.8491 ,0.8405 ,0.832 ,0.8234 ,0.8149 ,0.8063 ,0.7973 ,0.7883 ,0.7793 ,0.7703 ,0.7613 ,0.7517 ,0.7421 ,0.7326 ,0.723 ,0.7134 ,0.7031 ,0.6928 ,0.6824 ,0.6721 ,0.6618 ,0.6505 ,0.6392 ,0.628 ,0.6167 ,0.6054 ,0.5928 ,0.5801 ,0.5675 ,0.5548 ,0.5422 ];
var Kmarw = [1 ,1 ,1 ,1 ,1 ,1 ,1 ,0.9979 ,0.9901 ,0.9823 ,0.9745 ,0.9666 ,0.9587 ,0.9509 ,0.943 ,0.9351 ,0.9271 ,0.9191 ,0.911 ,0.895 ,0.8868 ,0.8785 ,0.8703 ,0.862 ,0.8538 ,0.8452 ,0.8367 ,0.8281 ,0.8196 ,0.811 ,0.802 ,0.793 ,0.784 ,0.775 ,0.766 ,0.7564 ,0.7468 ,0.7373 ,0.7277 ,0.7181 ,0.7078 ,0.6975 ,0.6871 ,0.6768 ,0.6665 ,0.6552 ,0.6439 ,0.6327 ,0.6214 ,0.6101 ,0.5975 ,0.5848 ,0.5722 ,0.5595 ,0.5469 ];
var K1m = [1 ,1 ,1 ,0.9951 ,0.9884 ,0.9817 ,0.9749 ,0.9682 ,0.9614 ,0.9547 ,0.9479 ,0.9411 ,0.9342 ,0.9274 ,0.9205 ,0.9137 ,0.9067 ,0.8997 ,0.8928 ,0.8858 ,0.8788 ,0.8716 ,0.8644 ,0.8572 ,0.85 ,0.8428 ,0.8353 ,0.8278 ,0.8202 ,0.8127 ,0.8052 ,0.7972 ,0.7893 ,0.7813 ,0.7734 ,0.7654 ,0.7569 ,0.7483 ,0.7398 ,0.7312 ,0.7227 ,0.7134 ,0.7041 ,0.6949 ,0.6856 ,0.6763 ,0.6661 ,0.6558 ,0.6456 ,0.6353 ,0.6251 ,0.6135 ,0.6019 ,0.5903 ,0.5787 ,0.5671 ];
var K3m = [1 ,1 ,1 ,1 ,0.9979 ,0.9912 ,0.9844 ,0.9777 ,0.9709 ,0.9642 ,0.9574 ,0.9506 ,0.9437 ,0.9369 ,0.93 ,0.9232 ,0.9162 ,0.9092 ,0.9023 ,0.8953 ,0.8883 ,0.8811 ,0.8739 ,0.8667 ,0.8595 ,0.8523 ,0.8448 ,0.8373 ,0.8297 ,0.8222 ,0.8147 ,0.8067 ,0.7988 ,0.7908 ,0.7829 ,0.7749 ,0.7664 ,0.7578 ,0.7493 ,0.7407 ,0.7322 ,0.7229 ,0.7136 ,0.7044 ,0.6951 ,0.6858 ,0.6756 ,0.6653 ,0.6551 ,0.6448 ,0.6346 ,0.623 ,0.6114 ,0.5998 ,0.5882 ,0.5766 ];
var K5m = [1 ,1 ,1 ,1 ,1 ,0.9963 ,0.9895 ,0.9827 ,0.976 ,0.9692 ,0.9624 ,0.9555 ,0.9487 ,0.9418 ,0.935 ,0.9281 ,0.9211 ,0.9141 ,0.9071 ,0.9001 ,0.8931 ,0.8859 ,0.8787 ,0.8714 ,0.8642 ,0.857 ,0.8495 ,0.8419 ,0.8344 ,0.8268 ,0.8193 ,0.8113 ,0.8033 ,0.7954 ,0.7874 ,0.7794 ,0.7708 ,0.7623 ,0.7537 ,0.7452 ,0.7366 ,0.7273 ,0.718 ,0.7087 ,0.6994 ,0.6901 ,0.6798 ,0.6696 ,0.6593 ,0.6491 ,0.6388 ,0.6272 ,0.6156 ,0.6039 ,0.5923 ,0.5807 ];
var K8m = [1 ,1 ,1 ,1 ,1 ,1 ,0.9934 ,0.9866 ,0.9797 ,0.9729 ,0.9661 ,0.9592 ,0.9523 ,0.9454 ,0.9385 ,0.9316 ,0.9246 ,0.9175 ,0.9105 ,0.9034 ,0.8964 ,0.8891 ,0.8819 ,0.8746 ,0.8674 ,0.8601 ,0.8525 ,0.8449 ,0.8374 ,0.8298 ,0.8222 ,0.8142 ,0.8062 ,0.7981 ,0.7901 ,0.7821 ,0.7735 ,0.7649 ,0.7563 ,0.7477 ,0.7391 ,0.7298 ,0.7204 ,0.7111 ,0.7017 ,0.6924 ,0.6821 ,0.6718 ,0.6615 ,0.6512 ,0.6409 ,0.6292 ,0.6176 ,0.6059 ,0.5943 ,0.5826 ];
var K10m = [1 ,1 ,1 ,1 ,1 ,1 ,0.9953 ,0.9884 ,0.9816 ,0.9747 ,0.9679 ,0.961 ,0.9541 ,0.9471 ,0.9402 ,0.9333 ,0.9262 ,0.9192 ,0.9121 ,0.9051 ,0.898 ,0.8907 ,0.8834 ,0.8762 ,0.8689 ,0.8616 ,0.854 ,0.8464 ,0.8388 ,0.8312 ,0.8236 ,0.8156 ,0.8075 ,0.7995 ,0.7914 ,0.7834 ,0.7748 ,0.7662 ,0.7575 ,0.7489 ,0.7403 ,0.7309 ,0.7216 ,0.7122 ,0.7029 ,0.6935 ,0.6832 ,0.6729 ,0.6625 ,0.6522 ,0.6419 ,0.6302 ,0.6185 ,0.6069 ,0.5952 ,0.5835 ];
var K12m = [1 ,1 ,1 ,1 ,1 ,1 ,0.997 ,0.9901 ,0.9833 ,0.9764 ,0.9696 ,0.9627 ,0.9558 ,0.9488 ,0.9419 ,0.935 ,0.9279 ,0.9209 ,0.9138 ,0.9068 ,0.8997 ,0.8924 ,0.8851 ,0.8779 ,0.8706 ,0.8633 ,0.8557 ,0.8481 ,0.8405 ,0.8329 ,0.8253 ,0.8173 ,0.8092 ,0.8012 ,0.7931 ,0.7851 ,0.7765 ,0.7679 ,0.7592 ,0.7506 ,0.742 ,0.7326 ,0.7233 ,0.7139 ,0.7046 ,0.6952 ,0.6849 ,0.6746 ,0.6642 ,0.6539 ,0.6436 ,0.6319 ,0.6202 ,0.6086 ,0.5969 ,0.5852 ];
var K15m = [1 ,1 ,1 ,1 ,1 ,1 ,0.9989 ,0.9921 ,0.9852 ,0.9784 ,0.9715 ,0.9646 ,0.9576 ,0.9507 ,0.9437 ,0.9368 ,0.9297 ,0.9226 ,0.9156 ,0.9085 ,0.9014 ,0.8941 ,0.8868 ,0.8795 ,0.8722 ,0.8649 ,0.8573 ,0.8497 ,0.842 ,0.8344 ,0.8268 ,0.8187 ,0.8107 ,0.8026 ,0.7946 ,0.7865 ,0.7779 ,0.7692 ,0.7606 ,0.7519 ,0.7433 ,0.7339 ,0.7245 ,0.7152 ,0.7058 ,0.6964 ,0.6861 ,0.6757 ,0.6654 ,0.655 ,0.6447 ,0.633 ,0.6213 ,0.6096 ,0.5979 ,0.5862 ];
var K20m = [1 ,1 ,1 ,1 ,1 ,1 ,1 ,0.9951 ,0.9882 ,0.9814 ,0.9745 ,0.9676 ,0.9606 ,0.9537 ,0.9467 ,0.9398 ,0.9327 ,0.9256 ,0.9186 ,0.9115 ,0.9044 ,0.8971 ,0.8898 ,0.8825 ,0.8752 ,0.8679 ,0.8603 ,0.8527 ,0.845 ,0.8374 ,0.8298 ,0.8217 ,0.8137 ,0.8056 ,0.7976 ,0.7895 ,0.7809 ,0.7722 ,0.7636 ,0.7549 ,0.7463 ,0.7369 ,0.7275 ,0.7182 ,0.7088 ,0.6994 ,0.6891 ,0.6787 ,0.6684 ,0.658 ,0.6477 ,0.636 ,0.6243 ,0.6126 ,0.6009 ,0.5892 ];
var Khalfm = [1 ,1 ,1 ,1 ,1 ,1 ,1 ,0.9957 ,0.9888 ,0.982 ,0.9751 ,0.9682 ,0.9612 ,0.9543 ,0.9473 ,0.9404 ,0.9333 ,0.9262 ,0.9192 ,0.9121 ,0.905 ,0.8977 ,0.8904 ,0.8831 ,0.8758 ,0.8685 ,0.8609 ,0.8533 ,0.8456 ,0.838 ,0.8304 ,0.8223 ,0.8143 ,0.8062 ,0.7982 ,0.7901 ,0.7815 ,0.7728 ,0.7642 ,0.7555 ,0.7469 ,0.7375 ,0.7281 ,0.7188 ,0.7094 ,0.7 ,0.6897 ,0.6793 ,0.669 ,0.6586 ,0.6483 ,0.6366 ,0.6249 ,0.6132 ,0.6015 ,0.5898 ];
var K25m = [1 ,1 ,1 ,1 ,1 ,1 ,1 ,0.9974 ,0.9906 ,0.9837 ,0.9768 ,0.9698 ,0.9629 ,0.9559 ,0.949 ,0.942 ,0.9349 ,0.9278 ,0.9207 ,0.9136 ,0.9065 ,0.8992 ,0.8919 ,0.8845 ,0.8772 ,0.8699 ,0.8623 ,0.8546 ,0.847 ,0.8393 ,0.8317 ,0.8236 ,0.8155 ,0.8075 ,0.7994 ,0.7913 ,0.7826 ,0.774 ,0.7653 ,0.7567 ,0.748 ,0.7386 ,0.7292 ,0.7198 ,0.7104 ,0.701 ,0.6906 ,0.6803 ,0.6699 ,0.6596 ,0.6492 ,0.6375 ,0.6258 ,0.614 ,0.6023 ,0.5906 ];
var K30m = [1 ,1 ,1 ,1 ,1 ,1 ,1 ,0.9996 ,0.9928 ,0.9859 ,0.979 ,0.972 ,0.9651 ,0.9581 ,0.9512 ,0.9442 ,0.9371 ,0.93 ,0.9229 ,0.9158 ,0.9087 ,0.9014 ,0.8941 ,0.8867 ,0.8794 ,0.8721 ,0.8645 ,0.8568 ,0.8492 ,0.8415 ,0.8339 ,0.8258 ,0.8177 ,0.8097 ,0.8016 ,0.7935 ,0.7848 ,0.7762 ,0.7675 ,0.7589 ,0.7502 ,0.7408 ,0.7314 ,0.722 ,0.7126 ,0.7032 ,0.6928 ,0.6825 ,0.6721 ,0.6618 ,0.6514 ,0.6397 ,0.628 ,0.6162 ,0.6045 ,0.5928 ];
var Kmarm = [1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,0.9973 ,0.9904 ,0.9835 ,0.9765 ,0.9695 ,0.9626 ,0.9556 ,0.9486 ,0.9415 ,0.9344 ,0.9272 ,0.9201 ,0.913 ,0.9057 ,0.8983 ,0.891 ,0.8836 ,0.8763 ,0.8686 ,0.861 ,0.8533 ,0.8457 ,0.838 ,0.8299 ,0.8218 ,0.8137 ,0.8056 ,0.7975 ,0.7888 ,0.7801 ,0.7715 ,0.7628 ,0.7541 ,0.7447 ,0.7353 ,0.7258 ,0.7164 ,0.707 ,0.6966 ,0.6862 ,0.6759 ,0.6655 ,0.6551 ,0.6434 ,0.6316 ,0.6199 ,0.6081 ,0.5964 ];
function params() {
strtable = '<table style="empty-cells: hide"><tr><td colspan="20">'
document.getElementById("s2").style.visibility = "hidden";
document.getElementById("b1").style.visibility = "visible";
document.getElementById("b2").style.visibility = "visible";
document.getElementById("c1").style.visibility = "visible";
document.getElementById("c2").style.visibility = "visible";
document.getElementById("h1").style.visibility = "visible";
document.getElementById("h2").style.visibility = "visible";
document.getElementById("res").style.visibility = "visible";
document.getElementById("t1").style.visibility = "hidden";
document.getElementById("t2").style.visibility = "hidden";
document.getElementById("t3").style.visibility = "hidden";
document.getElementById("t4").style.visibility = "hidden";
document.getElementById("t5").style.visibility = "hidden";
if ( document.getElementById("s1").value == "Metabolism" ) {
document.getElementById("t1").value = "weight";
document.getElementById("t2").value = "height";
document.getElementById("t3").value = "age";
document.getElementById("t1").style.visibility = "visible";
document.getElementById("t2").style.visibility = "visible";
document.getElementById("t3").style.visibility = "visible";
strtable += 'Metabolism</td></tr><tr>'
if (document.getElementById("c2").checked) strtable += '<td>name</td>';
strtable += '<td>weight</td><td>height</td><td>age</td></tr>';
}
if ( document.getElementById("s1").value == "Male Body Fat") {
document.getElementById("t1").value = "weight";
document.getElementById("t2").value = "waist";
document.getElementById("t1").style.visibility = "visible";
document.getElementById("t2").style.visibility = "visible";
strtable += 'Male Body Fat</td></tr><tr>';
if (document.getElementById("c2").checked) strtable += '<td>name</td>';
strtable += '<td>weight</td><td>waist</td></tr>';
}
if ( document.getElementById("s1").value == "Female Body Fat") {
document.getElementById("t1").value = "waist";
document.getElementById("t2").value = "hips";
document.getElementById("t3").value = "neck";
document.getElementById("t4").value = "height";
document.getElementById("t1").style.visibility = "visible";
document.getElementById("t2").style.visibility = "visible";
document.getElementById("t3").style.visibility = "visible";
document.getElementById("t4").style.visibility = "visible";
strtable += 'Female Body Fat</td></tr><tr>';
if (document.getElementById("c2").checked) strtable += '<td>name</td>';
strtable += '<td>waist</td><td>hips</td><td>neck</td><td>height</td></tr>';
}
if ( document.getElementById("s1").value == "VO2Max" || document.getElementById("s1").value == "Equivalent Time" || document.getElementById("s1").value.indexOf("WAVA") != -1) {
document.getElementById("t1").value = "hours";
document.getElementById("t2").value = "minutes";
document.getElementById("t3").value = "seconds";
document.getElementById("t4").value = "age";
document.getElementById("t1").style.visibility = "visible";
document.getElementById("t2").style.visibility = "visible";
document.getElementById("t3").style.visibility = "visible";
document.getElementById("s2").style.visibility = "visible";
document.getElementById("t4").style.visibility = "visible";
}
if ( document.getElementById("s1").value.indexOf("WAVA") != -1) {
if ( document.getElementById("s1").value.indexOf("Male") != -1) strtable += 'Male WAVA %</td></tr><tr>';
if ( document.getElementById("s1").value.indexOf("Female") != -1) strtable += 'Female WAVA %</td></tr><tr>';
if (document.getElementById("c2").checked) strtable += '<td>name</td>';
strtable += '<td>hours</td><td>minutes</td><td>seconds</td><td>age</td><td>distance</td></tr>';
}
if ( document.getElementById("s1").value.indexOf("Eq") != -1) {
strtable += 'Equivalent Time</td></tr><tr>';
if (document.getElementById("c2").checked) strtable += '<td>name</td>';
strtable += '<td>hours</td><td>minutes</td><td>seconds</td><td>distance1</td><td>distance2</td></tr>';
}
if ( document.getElementById("s1").value == "VO2Max") {
document.getElementById("t4").style.visibility = "hidden";
strtable += 'VO2Max</td></tr><tr>';
if (document.getElementById("c2").checked) strtable += '<td>name</td>';
strtable += '<td>hours</td><td>minutes</td><td>seconds</td><td>distance</td></tr>';
}
if ( document.getElementById("s1").value.indexOf("WAVA") != -1) document.getElementById("t4").value = "age";
if (document.getElementById("s1").value == "Equivalent Time") {
document.getElementById("s3").style.visibility = "visible";
document.getElementById("t4").style.visibility = "hidden";
} else {
document.getElementById("s3").style.visibility = "hidden";
}
if (document.getElementById("s1").value == "Female Age Conversion" || document.getElementById("s1").value == "Male Age Conversion") {
document.getElementById("t1").value = "hours";
document.getElementById("t2").value = "minutes";
document.getElementById("t3").value = "seconds";
document.getElementById("t4").value = "age1";
document.getElementById("t5").value = "age2";
document.getElementById("t1").style.visibility = "visible";
document.getElementById("t2").style.visibility = "visible";
document.getElementById("t3").style.visibility = "visible";
document.getElementById("t4").style.visibility = "visible";
document.getElementById("t5").style.visibility = "visible";
document.getElementById("s2").style.visibility = "visible";
if ( document.getElementById("s1").value.indexOf("Male") != -1) strtable += 'Male Age Conversion</td></tr><tr>';
if ( document.getElementById("s1").value.indexOf("Female") != -1) strtable += 'Female Age Conversion</td></tr><tr>';
if (document.getElementById("c2").checked) strtable += '<td>name</td>';
strtable += '<td>hours</td><td>minutes</td><td>seconds</td><td>age1</td><td>age2</td><td>distance</td></tr>';
}
init = strtable;
}
function calc() {
var v1 = parseFloat(document.getElementById("t1").value); var v2 = parseFloat(document.getElementById("t2").value); var v3 = parseFloat(document.getElementById("t3").value); var v4 = parseFloat(document.getElementById("t4").value); var v5 = parseFloat(document.getElementById("t5").value); var v; var runtime; var va;
if (document.getElementById("c1").checked) {
if ( document.getElementById("s1").value == "Male Body Fat") {
v1 *= 2.20462;
v2 *= 100/2.54;
}
if ( document.getElementById("s1").value == "Female Body Fat") {
v1 *= 100/2.54;
v2 *= 100/2.54;
v3 *= 100/2.54;
v4 *= 100/2.54;
}
}
if ( document.getElementById("s1").value == "Male Body Fat") res = (( (v1 – ( ( (v1 * 1.082) + 94.42) – (v2 * 4.15) ) ) * 100) / v1).toFixed(1) + " %";
if ( document.getElementById("s1").value == "Female Body Fat") res = (163.205 *Math.log10(v1 + v2 – v3) – 97.684 * Math.log10(v4) – 78.387).toFixed(1) + " %";;
if ( document.getElementById("s1").value == "Metabolism" ) res = (Math.floor(66.473 + ((v1/ 2.2) * 13.751) + (5.0033 * v2 * 2.54) – (6.55 * v3))).toString() + " KCal/Day";
if ( document.getElementById("s1").value == "VO2Max" ) {
runtime = 60*(parseFloat(document.getElementById("t1").value)) + parseFloat(document.getElementById("t2").value) + (parseFloat(document.getElementById("t3").value)) / 60;
if (document.getElementById("s2").value.indexOf("half") != -1) {
v = 21.05;
} else if (document.getElementById("s2").value.indexOf("marathon") != -1) {
v = 42,1;
} else if (document.getElementById("s2").value.indexOf("1500") != -1) {
v = 1.5;
} else {
v = parseFloat( document.getElementById("s2").value.substr(0, document.getElementById("s2").value.length – 1 )) ;
}
v *= (1000 / runtime);
var percent_max = 0.8 + (0.1894393 * Math.exp(-0.012778 * runtime)) + (0.2989558 * Math.exp(-0.1932605 * runtime));
var VO2 = -4.6 + (0.182258 * v) + (0.000104 * v * v);
res = (VO2 / percent_max).toFixed(1);
}
if ( document.getElementById("s1").value == "Equivalent Time" ) {
if (document.getElementById("s2").value.indexOf("1500") != -1) {
v = 1.5;
} else if (document.getElementById("s2").value.indexOf("half") != -1) {
v = 21.05;
} else if (document.getElementById("s2").value.indexOf("marathon") != -1) {
v = 42,1;
} else {
v = parseFloat( document.getElementById("s2").value.substr(0, document.getElementById("s2").value.length – 1 )) ;
}
if (document.getElementById("s3").value.indexOf("1500") != -1) {
va = 1.5;
} else if (document.getElementById("s3").value.indexOf("half") != -1) {
va = 21.05;
} else if (document.getElementById("s3").value.indexOf("marathon") != -1) {
va = 42,1;
} else {
va = parseFloat( document.getElementById("s3").value.substr(0, document.getElementById("s3").value.length – 1 )) ;
}
runtime = v1 * 3600 + v2 * 60 + v3;
var fact1 = 3600 / (13.5 – (0.049 * v) + 2.44 / (v ^ 0.79)) * v;
var fact2 = 3600 / (13.5 – (0.049 * va) + 2.44 / (va ^ 0.79)) * va;
var time2 = (runtime / fact1) * fact2;
var hrs = Math.floor(time2/3600);
var mins = Math.floor(time2/60 – 60 * hrs);
var secs = Math.floor(time2 – (3600 * hrs) – (60 * mins));
hrs = hrs.toString();
if (hrs.length < 2) hrs = "0" + hrs;
mins = mins.toString();
if (mins.length < 2) mins = "0" + mins;
secs = secs.toString();
if (secs.length < 2) secs = "0" + secs;
res = hrs + ":" + mins + ":" + secs;
}
if ( document.getElementById("s1").value == "Female Age Conversion" || document.getElementById("s1").value == "Male Age Conversion" ) {
var time2;
runtime = v1 * 3600 + v2 * 60 + v3;
if ( document.getElementById("s1").value == "Female Age Conversion") {
if (document.getElementById("s2").value == "1500 m") time2 = runtime * (K1w[v4-30]/K1w[v5-30]);
if (document.getElementById("s2").value == "3K") time2 = runtime * (K3w[v4-30]/K3w[v5-30]);
if (document.getElementById("s2").value == "5K") time2 = runtime * (K5w[v4-30]/K5w[v5-30]);
if (document.getElementById("s2").value == "8K") time2 = runtime * (K8w[v4-30]/K8w[v5-30]);
if (document.getElementById("s2").value == "10K") time2 = runtime * (K10w[v4-30]/K10w[v5-30]);
if (document.getElementById("s2").value == "12K") time2 = runtime * (K12w[v4-30]/K12w[v5-30]);
if (document.getElementById("s2").value == "15K") time2 = runtime * (K15w[v4-30]/K15w[v5-30]);
if (document.getElementById("s2").value == "20K") time2 = runtime * (K20w[v4-30]/K20w[v5-30]);
if (document.getElementById("s2").value == "half") time2 = runtime * (Khalfw[v4-30]/Khalfw[v5-30]);
if (document.getElementById("s2").value == "25K") time2 = runtime * (K25w[v4-30]/K25w[v5-30]);
if (document.getElementById("s2").value == "30K") time2 = runtime * (K30w[v4-30]/K30w[v5-30]);
if (document.getElementById("s2").value == "marathon") time2 = runtime * (Kmarw[v4-30]/Kmarw[v5-30]);
}
if ( document.getElementById("s1").value == "Male Age Conversion") {
if (document.getElementById("s2").value == "1500 m") time2 = runtime * (K1m[v4-30]/K1m[v5-30]);
if (document.getElementById("s2").value == "3K") time2 = runtime * (K3m[v4-30]/K3m[v5-30]);
if (document.getElementById("s2").value == "5K") time2 = runtime * (K5m[v4-30]/K5m[v5-30]);
if (document.getElementById("s2").value == "8K") time2 = runtime * (K8m[v4-30]/K8m[v5-30]);
if (document.getElementById("s2").value == "10K") time2 = runtime * (K10m[v4-30]/K10m[v5-30]);
if (document.getElementById("s2").value == "12K") time2 = runtime * (K12m[v4-30]/K12m[v5-30]);
if (document.getElementById("s2").value == "15K") time2 = runtime * (K15w[v4-30]/K15w[v5-30]);
if (document.getElementById("s2").value == "20K") time2 = runtime * (K20m[v4-30]/K20m[v5-30]);
if (document.getElementById("s2").value == "half") time2 = runtime * (Khalfm[v4-30]/Khalfm[v5-30]);
if (document.getElementById("s2").value == "25K") time2 = runtime * (K25m[v4-30]/K25m[v5-30]);
if (document.getElementById("s2").value == "30K") time2 = runtime * (K30m[v4-30]/K30m[v5-30]);
if (document.getElementById("s2").value == "marathon") time2 = runtime * (Kmarm[v4-30]/Kmarm[v5-30]);
}
var hrs = Math.floor(time2/3600);
hrs = hrs.toString();
if(hrs.length < 2) hrs = "0" + hrs;
var mins = Math.floor(time2/60 – 60*hrs);
mins = mins.toString();
if(mins.length < 2) mins = "0" + mins;
var secs = Math.floor(time2 – 3600*hrs – 60*mins);
secs = secs.toString();
if(secs.length < 2) secs = "0" + secs;
res = hrs + ":" + mins + ":" + secs;
}
if ( document.getElementById("s1").value == "Female WAVA %") {
runtime = v1 * 3600 + v2 * 60 + v3;
if (document.getElementById("s2").value == "1500 m") res = ((230.46/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "3K") res = ((498.00/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "5K") res = ((863.69/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "8K") res = ((1419.0/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "10K") res = ((1795.0/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "12K") res = ((2175.0/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "15K") res = ((2751.0/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "20K") res = ((3730.0/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "half") res = ((3948.0/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "25K") res = ((4730.0/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "30K") res = ((5752.0/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "marathon") res = ((8331.0/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
}
if ( document.getElementById("s1").value == "Male WAVA %") {
runtime = v1 * 3600 + v2 * 60 + v3;
if (document.getElementById("s2").value == "1500 m") res = ((207.70/runtime) * (100 / K1m[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "3K") res = ((448.96/runtime) * (100 / K1m[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "5K") res = ((778.39/runtime) * (100 / K1m[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "8K") res = ((1278.9/runtime) * (100 / K1m[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "10K") res = ((1618.4/runtime) * (100 / K1m[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "12K") res = ((1962.0/runtime) * (100 / K1m[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "15K") res = ((2486.0/runtime) * (100 / K1m[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "20K") res = ((3380.0/runtime) * (100 / K1m[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "half") res = ((3579.0/runtime) * (100 / K1m[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "25K") res = ((4296.0/runtime) * (100 / K1m[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "30K") res = ((5235.0/runtime) * (100 / K1m[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "marathon") res = ((7610.0/runtime) * (100 / K1m[v4-30] )).toFixed(1) + "%";
}
document.getElementById("res").value = res;
strtable = init + '<tr><td>';
if (document.getElementById("c2").checked) {
nm = prompt("Enter a Name",nm);
strtable += nm + '</td><td>';
}
if (document.getElementById("s1").value.indexOf("Male Body")!= -1)
strtable += document.getElementById("t1").value + '</td><td>' + document.getElementById("t2").value + '<td><td>' + document.getElementById("res").value + '<td></tr>';
if (document.getElementById("s1").value.indexOf("Female Body")!= -1)
strtable += document.getElementById("t1").value + '</td><td>' + document.getElementById("t2").value + '</td><td>' + document.getElementById("t3").value + '</td><td>' + document.getElementById("t4").value + '</td><td>' + document.getElementById("res").value + '<td></tr>';
if (document.getElementById("s1").value.indexOf("Metabolism")!= -1)
strtable += document.getElementById("t1").value + '</td><td>' + document.getElementById("t2").value + '</td><td>' + document.getElementById("t3").value + '</td><td>' + document.getElementById("res").value + '<td></tr>';
if (document.getElementById("s1").value.indexOf("VO2")!= -1)
strtable += document.getElementById("t1").value + '</td><td>' + document.getElementById("t2").value + '</td><td>' + document.getElementById("t3").value + '</td><td>'+ document.getElementById("s2").value + '</td><td>' + document.getElementById("res").value + '</td></tr>';
if ( document.getElementById("s1").value.indexOf("WAVA") != -1) {
strtable += document.getElementById("t1").value + '</td><td>' + document.getElementById("t2").value + '</td><td>' + document.getElementById("t3").value + '</td><td>'+ document.getElementById("t4").value + '</td><td>' + document.getElementById("s2").value + '</td><td>' + document.getElementById("res").value + '</td></tr>';
}
if ( document.getElementById("s1").value.indexOf("Conversion") != -1) {
strtable += document.getElementById("t1").value + '</td><td>' + document.getElementById("t2").value + '</td><td>' + document.getElementById("t3").value + '</td><td>'+ document.getElementById("t4").value + '</td><td>' + document.getElementById("t5").value + '</td><td>' + document.getElementById("s2").value + '</td><td>' + document.getElementById("res").value + '</td></tr>';
}
if ( document.getElementById("s1").value.indexOf("Eq") != -1) {
strtable += document.getElementById("t1").value + '</td><td>' + document.getElementById("t2").value + '</td><td>' + document.getElementById("t3").value + '</td><td>' + document.getElementById("s2").value + '</td><td>' + document.getElementById("s3").value + '</td><td>' + document.getElementById("res").value + '</td></tr>';
}
init = strtable;
}
function table() {
strtable += '</table>';
document.getElementById("table1").innerHTML= strtable;
document.getElementById("table1").style.visibility="visible";
}
</script>
</body></html>
My previous post had demonstrated converting a rable column to a row. This is why I needed that:
var K12m = [1 ,1 ,1 ,1 ,1 ,1 ,0.997 ,0.9901 ,0.9833 ,0.9764 ,0.9696 ,0.9627 ,0.9558 ,0.9488 ,0.9419 ,0.935 ,0.9279 ,0.9209 ,0.9138 ,0.9068 ,0.8997 ,0.8924 ,0.8851 ,0.8779 ,0.8706 ,0.8633 ,0.8557 ,0.8481 ,0.8405 ,0.8329 ,0.8253 ,0.8173 ,0.8092 ,0.8012 ,0.7931 ,0.7851 ,0.7765 ,0.7679 ,0.7592 ,0.7506 ,0.742 ,0.7326 ,0.7233 ,0.7139 ,0.7046 ,0.6952 ,0.6849 ,0.6746 ,0.6642 ,0.6539 ,0.6436 ,0.6319 ,0.6202 ,0.6086 ,0.5969 ,0.5852 ];
The calculations are done by the function calc(). Here is a typical calculation:
if ( document.getElementById("s1").value == "VO2Max" ) {
runtime = 60*(parseFloat(document.getElementById("t1").value)) + parseFloat(document.getElementById("t2").value) + (parseFloat(document.getElementById("t3").value)) / 60;
if (document.getElementById("s2").value.indexOf("half") != -1) {
v = 21.05;
} else if (document.getElementById("s2").value.indexOf("marathon") != -1) {
v = 42,1;
} else if (document.getElementById("s2").value.indexOf("1500") != -1) {
v = 1.5;
} else {
v = parseFloat( document.getElementById("s2").value.substr(0, document.getElementById("s2").value.length – 1 )) ;
}
v *= (1000 / runtime);
var percent_max = 0.8 + (0.1894393 * Math.exp(-0.012778 * runtime)) + (0.2989558 * Math.exp(-0.1932605 * runtime));
var VO2 = -4.6 + (0.182258 * v) + (0.000104 * v * v);
res = (VO2 / percent_max).toFixed(1);
}
The arrays are used for the Age Conversions:
if ( document.getElementById("s1").value == "Female WAVA %") {
runtime = v1 * 3600 + v2 * 60 + v3;
if (document.getElementById("s2").value == "1500 m") res = ((230.46/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "3K") res = ((498.00/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "5K") res = ((863.69/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "8K") res = ((1419.0/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "10K") res = ((1795.0/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "12K") res = ((2175.0/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "15K") res = ((2751.0/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "20K") res = ((3730.0/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "half") res = ((3948.0/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "25K") res = ((4730.0/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "30K") res = ((5752.0/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
if (document.getElementById("s2").value == "marathon") res = ((8331.0/runtime) * (100 / K1w[v4-30] )).toFixed(1) + "%";
}
The calculation will take either metric or English arguments. If metric is checked, it must be converted for the calculation:
if (document.getElementById("c1").checked) {
if ( document.getElementById("s1").value == "Male Body Fat") {
v1 *= 2.20462;
v2 *= 100/2.54;
}
There is also the option of adding a name to the table, so values for multiple can be compared. Clicking add name will bring up a prompt where a name can be added and the resulting table will have an additional column:
if (document.getElementById("c2").checked) {
nm = prompt("Enter a Name",nm);
strtable += nm + '</td><td>';
</body></html>

view raw

fitnesscode.txt

hosted with ❤ by GitHub