home *** CD-ROM | disk | FTP | other *** search
/ Beweegwijzer / beweegwijzer.iso / setup / _SETUP.1 / steptest.js < prev    next >
Encoding:
Text File  |  2001-11-19  |  4.1 KB  |  110 lines

  1. var moduleData = new ActiveXObject("Microsoft.XMLDOM");
  2. moduleData.load("data/steptest.xml");
  3. var moduleRoot = moduleData.documentElement;
  4.  
  5. var minMax = new Array(125,175,0,0);
  6.  
  7. var gewicht = parseFloat(parent.userRoot.selectSingleNode("gewicht").text);
  8. var geslacht = parent.userRoot.selectSingleNode("geslacht").text;
  9.  
  10. function showPage() {
  11.   buildPage();
  12.   parent.goPage = 'steptest.html';  
  13.   AppScreen.style.visibility = "visible";
  14.   }
  15.  
  16. function buildPage() {
  17.   style = new ActiveXObject("Microsoft.XMLDOM");
  18.  
  19.   styleRule = buildStyleRule(0);
  20.   style.loadXML(styleRule);
  21.   TextArea[0].innerHTML = moduleData.transformNode(style);
  22.   
  23.   styleRule = buildStyleRule(1);
  24.   style.loadXML(styleRule);
  25.   TextArea[1].innerHTML = moduleData.transformNode(style);
  26.  
  27.   styleRule = buildStyleRule(2);
  28.   style.loadXML(styleRule);
  29.   TextArea[2].innerHTML = moduleData.transformNode(style);
  30.  
  31.   waarde = new Array('onvoldoende','net niet voldoende','voldoende','ruim voldoende','goed');
  32.  
  33.   if (gewicht < 55) cgewicht = 50;
  34.   else if ((gewicht >= 55) && (gewicht < 65)) cgewicht = 60;
  35.   else if ((gewicht >= 65) && (gewicht < 75)) cgewicht = 70;
  36.   else if ((gewicht >= 75) && (gewicht < 85)) cgewicht = 80;
  37.   else if (gewicht >= 85) cgewicht = 90;      
  38.   
  39.   textString = '<table>';
  40.   textString += '<tr height="20" valign="top"><td style="color:#000000" width="70"></td><td style="color:#000000" width="60"><span style="position:relative; top:2px"></span></td><td> </td></tr>';
  41.   for (var i=0; i<5; i++) {
  42.     textString += '<tr><td>'+moduleRoot.selectNodes("vo[@gewicht = '"+cgewicht+"']")[i].getAttribute("hartslag")+'</td><td>'+moduleRoot.selectNodes("vo[@gewicht = '"+cgewicht+"']")[i].text+'</td><td>'+waarde[i]+'</td></tr>';
  43.     }
  44.   textString += '</table>'
  45.   
  46.   TextArea[4].innerHTML = textString;
  47.   }
  48.   
  49. function CountAction(c) {
  50.   theNum = c;
  51.   theValue = parseInt(CountBox[c].value);
  52.   if ((theValue >= minMax[theNum*2]) && (theValue <= minMax[(theNum*2)+1])) {
  53.     CountBox[c].value = parseInt(CountBox[c].value);
  54.     }
  55.   else CountBox[c].value = minMax[theNum*2];
  56.   
  57.   hartslag = parseFloat(CountBox[0].value);
  58.   
  59.   if (hartslag < 135) chartslag = 130;
  60.   else if ((hartslag >= 135) && (hartslag < 145)) chartslag = 140;
  61.   else if ((hartslag >= 145) && (hartslag < 155)) chartslag = 150;
  62.   else if ((hartslag >= 155) && (hartslag < 165)) chartslag = 160;
  63.   else if (hartslag >= 165) chartslag = 170;
  64.   
  65.   if (gewicht < 55) cgewicht = 50;
  66.   else if ((gewicht >= 55) && (gewicht < 65)) cgewicht = 60;
  67.   else if ((gewicht >= 65) && (gewicht < 75)) cgewicht = 70;
  68.   else if ((gewicht >= 75) && (gewicht < 85)) cgewicht = 80;
  69.   else if (gewicht >= 85) cgewicht = 90;
  70.   
  71.   Result.innerText = moduleRoot.selectSingleNode("vo[@gewicht = '"+cgewicht+"' $and$ @hartslag = '"+chartslag+"']").text
  72.   }
  73.   
  74. function buildStyleRule(t) {
  75.   styleRule = '<?xml version="1.0"?>';
  76.   styleRule += '<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">';
  77.   styleRule += '<xsl:template match="/">';
  78.   styleRule += '<xsl:apply-templates select="steptest/text['+t+']">';
  79.   styleRule += '<xsl:template>';
  80.   styleRule += '<xsl:copy>';
  81.   styleRule += '<xsl:apply-templates select="@* | * | comment() | pi() | text()"/>';
  82.   styleRule += '</xsl:copy>';
  83.   styleRule += '</xsl:template>';
  84.   styleRule += '</xsl:apply-templates>';
  85.   styleRule += '</xsl:template>';
  86.   styleRule += '</xsl:stylesheet>';
  87.   return styleRule;
  88.   }
  89.   
  90. var countTimer;
  91. var counting = false;
  92. var countObj;
  93.   
  94. function RealCount() {
  95.   clearTimeout(countTimer);
  96.   
  97.   theNum = parseInt(countObj.num);
  98.   theFactor = (countObj.factor)?parseInt(countObj.factor):1;
  99.   theValue = parseInt(CountBox[theNum].value);
  100.   if (((countObj.innerText == '-') || (countObj.dirtype == '-')) && ((theValue-theFactor) >= minMax[theNum*2])) {
  101.     theValue -= theFactor;
  102.     }
  103.   else if (((countObj.innerText == '+') || (countObj.dirtype == '+')) && ((theValue-theFactor) <= minMax[(theNum*2)+1])) {
  104.     theValue += theFactor;
  105.     }
  106.   CountBox[theNum].value = theValue;
  107.   CountAction(theNum);
  108.     
  109.   if (counting) countTimer = window.setTimeout('RealCount()',100);
  110.   }