home *** CD-ROM | disk | FTP | other *** search
/ Beweegwijzer / beweegwijzer.iso / setup / _SETUP.1 / wandeltest.js < prev    next >
Encoding:
Text File  |  2000-08-24  |  3.6 KB  |  104 lines

  1. var moduleData = new ActiveXObject("Microsoft.XMLDOM");
  2. moduleData.load("data/wandeltest.xml");
  3. var moduleRoot = moduleData.documentElement;
  4.  
  5. var minMax = new Array(0,60,0,60,50,450);
  6.  
  7. var gewicht = parseFloat(parent.userRoot.selectSingleNode("gewicht").text);
  8. var geslacht = parent.userRoot.selectSingleNode("geslacht").text;
  9. var leeftijd =  parseFloat(parent.userRoot.selectSingleNode("leeftijd").text);
  10. var lengte =  parseFloat(parent.userRoot.selectSingleNode("lengte").text);
  11.  
  12. function showPage() {
  13.   buildPage();
  14.   parent.goPage = 'wandeltest.html';  
  15.   AppScreen.style.visibility = "visible";
  16.   }
  17.  
  18. function buildPage() {
  19.   style = new ActiveXObject("Microsoft.XMLDOM");
  20.  
  21.   styleRule = buildStyleRule(0);
  22.   style.loadXML(styleRule);
  23.   TextArea[0].innerHTML = moduleData.transformNode(style);
  24.   
  25.   styleRule = buildStyleRule(1);
  26.   style.loadXML(styleRule);
  27.   TextArea[1].innerHTML = moduleData.transformNode(style);
  28.   
  29.   styleRule = buildStyleRule(2);
  30.   style.loadXML(styleRule);
  31.   TextArea[2].innerHTML = moduleData.transformNode(style);
  32.   
  33.   styleRule = buildStyleRule(3);
  34.   style.loadXML(styleRule);
  35.   TextArea[3].innerHTML = moduleData.transformNode(style);
  36.  
  37.   styleRule = buildStyleRule(4);
  38.   style.loadXML(styleRule);
  39.   TextArea[4].innerHTML = moduleData.transformNode(style);
  40.   
  41.   styleRule = buildStyleRule(5);
  42.   style.loadXML(styleRule);
  43.   TextArea[5].innerHTML = moduleData.transformNode(style);    
  44.   }
  45.   
  46. function CountAction(c) {
  47.   theNum = c;
  48.   theValue = parseInt(CountBox[c].value);
  49.   if ((theValue >= minMax[theNum*2]) && (theValue <= minMax[(theNum*2)+1])) {
  50.     CountBox[c].value = parseInt(CountBox[c].value);
  51.     }
  52.   else CountBox[c].value = minMax[theNum*2];
  53.   
  54.   minuten = parseFloat(CountBox[0].value);
  55.   seconden = parseFloat(CountBox[1].value);  
  56.   hartslag = parseFloat(CountBox[2].value);
  57.   
  58.   resultValue = '';
  59.   if ((geslacht == 'v') && (hartslag > 0) && (minuten + seconden > 0)) {
  60.     resultValue = 304-((leeftijd*-0.4)+(minuten*8.5)+(seconden*0.14)+(hartslag*0.32)+(gewicht*11000/(lengte*lengte)));
  61.     }
  62.   else if ((geslacht == 'm') && (hartslag > 0) && (minuten + seconden > 0)) {
  63.     resultValue = 420-((leeftijd*-0.2)+(minuten*11.6)+(seconden*0.2)+(hartslag*0.56)+(gewicht*26000/(lengte*lengte)));
  64.     }   
  65.   Result.innerText = Math.round(resultValue);
  66.   }
  67.   
  68. function buildStyleRule(t) {
  69.   styleRule = '<?xml version="1.0"?>';
  70.   styleRule += '<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">';
  71.   styleRule += '<xsl:template match="/">';
  72.   styleRule += '<xsl:apply-templates select="wandeltest/text['+t+']">';
  73.   styleRule += '<xsl:template>';
  74.   styleRule += '<xsl:copy>';
  75.   styleRule += '<xsl:apply-templates select="@* | * | comment() | pi() | text()"/>';
  76.   styleRule += '</xsl:copy>';
  77.   styleRule += '</xsl:template>';
  78.   styleRule += '</xsl:apply-templates>';
  79.   styleRule += '</xsl:template>';
  80.   styleRule += '</xsl:stylesheet>';
  81.   return styleRule;
  82.   }
  83.   
  84. var countTimer;
  85. var counting = false;
  86. var countObj;
  87.   
  88. function RealCount() {
  89.   clearTimeout(countTimer);
  90.   
  91.   theNum = parseInt(countObj.num);
  92.   theFactor = (countObj.factor)?parseInt(countObj.factor):1;
  93.   theValue = parseInt(CountBox[theNum].value);
  94.   if (((countObj.innerText == '-') || (countObj.dirtype == '-')) && ((theValue-theFactor) >= minMax[theNum*2])) {
  95.     theValue -= theFactor;
  96.     }
  97.   else if (((countObj.innerText == '+') || (countObj.dirtype == '+')) && ((theValue-theFactor) <= minMax[(theNum*2)+1])) {
  98.     theValue += theFactor;
  99.     }
  100.   CountBox[theNum].value = theValue;
  101.   CountAction(theNum);
  102.     
  103.   if (counting) countTimer = window.setTimeout('RealCount()',100);
  104.   }