Difference between revisions of "Test"

From Fellrnr.com, Running tips
Jump to: navigation, search
User:Fellrnr (User talk:Fellrnr | contribs)
User:Fellrnr (User talk:Fellrnr | contribs)
Line 1: Line 1:
 
<html>
 
<html>
 
<script type="text/javascript">
 
<script type="text/javascript">
var isArray = function (obj) {
+
function doCalc()
return Object.prototype.toString.call(obj) === "[object Array]";
+
{
},
+
var trimps=new Array();
getNumWithSetDec = function( num, numOfDec ){
+
var total = 0;
var pow10s = Math.pow( 10, numOfDec || 0 );
+
for(i=1; i< 8; i++)
return ( numOfDec ) ? Math.round( pow10s * num ) / pow10s : num;
+
{
},
+
doTrimp('dur_'+i, 'cr10_'+i, 'trimp_'+i);
getAverageFromNumArr = function( numArr, numOfDec ){
+
trimps[i-1] = Number(document.getElementById('trimp_'+i).innerHTML);
if( !isArray( numArr ) ){ return false; }
+
total += trimps[i-1];
var i = numArr.length,
 
sum = 0;
 
while( i-- ){
 
sum += numArr[ i ];
 
 
}
 
}
return getNumWithSetDec( (sum / numArr.length ), numOfDec );
+
var average = getAverageFromNumArr(trimps, 2);
},
+
var stddev = getStandardDeviation(trimps, 2);
getVariance = function( numArr, numOfDec ){
+
var Monotony = 10.0;
if( !isArray(numArr) ){ return false; }
+
if (average < (10 * stddev))
var avg = getAverageFromNumArr( numArr, numOfDec ),
+
        {
i = numArr.length,
+
Monotony = average / stddev;
v = 0;
+
Monotony = Math.round(Monotony*100)/100;
 
while( i-- ){
 
v += Math.pow( (numArr[ i ] - avg), 2 );
 
 
}
 
}
v /= numArr.length;
+
document.getElementById('Monotony').innerHTML = "Monotony: " + Monotony + "  ( " + average + " / " + stddev + " )";
return getNumWithSetDec( v, numOfDec );
+
document.getElementById('Total').innerHTML = "Total TRIMP: " + total;
},
+
document.getElementById('Stress').innerHTML = "Training Stress: " + Math.round(total * Monotony);
getStandardDeviation = function( numArr, numOfDec ){
 
if( !isArray(numArr) ){ return false; }
 
var stdDev = Math.sqrt( getVariance( numArr, numOfDec ) );
 
return getNumWithSetDec( stdDev, numOfDec );
 
};
 
 
 
function doCalc()
 
{
 
var d1 = document.getElementById('dur_1').innerHTML;
 
alert(d1);
 
//var c1 = document.getElementById('cr10_1').innerHTML;
 
//alert(c1);
 
//var t1 = d1 * c1;
 
//alert(t1);
 
//document.getElementById('trimp_1').innerHTML = t1;
 
 
}
 
}
 
</script>
 
</script>
  
<form style="font-family: Helvetica,Arial,sans-serif;" id="Monotony">
+
<form style="font-family: Helvetica,Arial,sans-serif;border: solid 2px #40a0c0" id="MonotonyForm">
 
   <table style="text-align: left;" border="1" cellpadding="1" cellspacing="1">
 
   <table style="text-align: left;" border="1" cellpadding="1" cellspacing="1">
 
       <tr>
 
       <tr>
         <th>Day</th>
+
         <th>Question</th>
         <th>Duration (min)</th>
+
         <th>strongly disagree</th>
         <th>CR10 Rating</th>
+
         <th>disagree</th>
         <th>TRIMP(CR10)</th>
+
         <th>neutral</th>
      </tr>
+
         <th>agree</th>
      <tr>
+
         <th>strongly agree</th>
      <td>1</td>
 
         <td><input maxlength="3" size="3" id="Dur_1" value="0"></td>
 
         <td><input maxlength="3" size="3" id="cr10_1" value="0"></td>
 
        <td><label id="trimp_1"></label></td>
 
      </tr>
 
      <tr>
 
      <td>2</td>
 
        <td><input maxlength="3" size="3" id="Dur_2" value="0"></td>
 
        <td><input maxlength="3" size="3" id="cr10_2" value="0"></td>
 
        <td><input maxlength="3" size="3" id="trimp_2" value="0" readonly="readonly"></td>
 
      </tr>
 
      <tr>
 
      <td>3</td>
 
        <td><input maxlength="3" size="3" id="Dur_3" value="0"></td>
 
        <td><input maxlength="3" size="3" id="cr10_3" value="0"></td>
 
        <td><input maxlength="3" size="3" id="trimp_3" value="0" readonly="readonly"></td>
 
      </tr>
 
      <tr>
 
      <td>4</td>
 
        <td><input maxlength="3" size="3" id="Dur_4" value="0"></td>
 
        <td><input maxlength="3" size="3" id="cr10_4" value="0"></td>
 
        <td><input maxlength="3" size="3" id="trimp_4" value="0" readonly="readonly"></td>
 
      </tr>
 
      <tr>
 
      <td>5</td>
 
        <td><input maxlength="3" size="3" id="Dur_5" value="0"></td>
 
        <td><input maxlength="3" size="3" id="cr10_5" value="0"></td>
 
        <td><input maxlength="3" size="3" id="trimp_5" value="0" readonly="readonly"></td>
 
      </tr>
 
      <tr>
 
      <td>6</td>
 
        <td><input maxlength="3" size="3" id="Dur_6" value="0"></td>
 
        <td><input maxlength="3" size="3" id="cr10_6" value="0"></td>
 
        <td><input maxlength="3" size="3" id="trimp_6" value="0" readonly="readonly"></td>
 
 
       </tr>
 
       </tr>
 
       <tr>
 
       <tr>
       <td>7</td>
+
       <td>I slept well last night</td>
         <td><input maxlength="3" size="3" id="Dur_7" value="0"></td>
+
         <td><input type="radio" name="slept" value="1" /></td>
         <td><input maxlength="3" size="3" id="cr10_7" value="0"></td>
+
        <td><input type="radio" name="slept" value="2" /></td>
         <td><input maxlength="3" size="3" id="trimp_7" value="0" readonly="readonly"></td>
+
         <td><input type="radio" name="slept" value="3" /></td>
 +
         <td><input type="radio" name="slept" value="4" /></td>
 +
        <td><input type="radio" name="slept" value="5" /></td>
 
       </tr>
 
       </tr>
 
   </table>
 
   </table>
   <label id="Monotony">Monotony:</label>
+
   <label id="Total">Total:</label><br/>
  <br>
 
  <input type="button" value="Calculate" onclick="doCalc()"/>
 
 
</form>
 
</form>
 
</html>
 
</html>

Revision as of 19:58, 6 March 2012

Question strongly disagree disagree neutral agree strongly agree
I slept well last night