home *** CD-ROM | disk | FTP | other *** search
Wrap
var moduleData = new ActiveXObject("Microsoft.XMLDOM"); moduleData.load("data/beweegplan.xml"); var moduleRoot = moduleData.documentElement; var styleData = new ActiveXObject("Microsoft.XMLDOM"); var activeDd = -1; var cancelCount = 0; var ddOpen = false; var ddFirst = 0; var ddLast = 8; var ddScrollMode = false; var scrollTimer; var scrollDirection = ''; var actName = ''; var actFact = 0; var activiteit = new Array('werk','huishouden','lopen','klussen','sport'); var chosenDag = ''; var chosenDagNum = -1; var weekNum = 1; var minMax = new Array(1,52,0,1440); var chosenTab = -1; var stepDotStep = 0; var stepTexts = new Array('U kunt hier een gezonde week plannen. Zorg ervoor dat de week minimaal 5 groene dagen heeft. Blader naar de gewenste week. Kies vervolgens een dag. Via [groene weken] kunt u ook een standaard beweegprofiel inladen.', 'Kies een bewegingsvorm door ΘΘn van tabbladen aan te klikken. Wilt u de gegevens overnemen van een reeds ingevulde dag, gebruik dan de knoppen <img src="images/btn_copy_0.bmp" width="29" height="10" alt="" border="0" style="position:relative; top:2px"/> en <img src="images/btn_paste_0.bmp" width="29" height="10" alt="" border="0" style="position:relative; top:2px"/> .', 'Kies een activiteit die u wilt uitoefenen of kies er een die erop lijkt. Geef aan hoeveel minuten u dit wilt doen. Ga hiermee door tot uw dagplanning compleet is. Kies dan de volgende dag.', 'U heeft alle dagen van de week ingevuld, kies rechts voor <img src="images/help_ok.gif" width="16" height="16" alt="" border="0" style="position:relative; top:3px"/> om uw weekresultaat te berekenen.'); var stepDotTimer; var gewicht = parseFloat(parent.userRoot.selectSingleNode("gewicht").text); var factor1 = 3; var factor2 = 5.25; var factor3 = 8; var cpweek = -1; var cpdag = ''; var weekResult = false; var groeneWeken = false; var groeneWeek = new Array(); groeneWeek[0] = new Array('2','wandelen: 7 km/u (6)','60'); groeneWeek[1] = new Array('2','fietsen: vrije tijd, matige inspanning (8)','80'); groeneWeek[2] = new Array('3','grasmaaien met handmaaier (6)','60'); groeneWeek[3] = new Array('4','zwemmen - baantjes trekken (6)','60'); groeneWeek[4] = new Array('2','wandelen: 7 km/u (6)','60', '2','fietsen: vrije tijd, matige inspanning (8)','80', '3','grasmaaien met handmaaier (6)','60', '4','zwemmen - baantjes trekken (6)','60', '0','laden en lossen (6.5)','65'); function showPage() { buildPage(); parent.goPage = 'beweegplan.html'; AppScreen.style.visibility = "visible"; CountBox[0].style.visibility = "inherit"; } function buildPage() { stepIt(); getWeek(); } function document.onclick() { var eSrc = window.event.srcElement; if (ddOpen) { if (eSrc != dd[activeDd]) { cancelCount++; if (cancelCount>1) { for (var i=0; i<dd[activeDd].childNodes.length; i++) { if ((dd[activeDd].childNodes[i].innerText != actName) && (dd[activeDd].childNodes[i].id == 'ddItem')) { dd[activeDd].childNodes[i].className = 'ddActHidden'; } else if (dd[activeDd].childNodes[i].id == 'ddItem') dd[activeDd].childNodes[i].className = 'ddActShown'; } ddScroll[0].style.display = 'none'; ddScroll[1].style.display = 'none'; ddScroll[0].style.visibility = 'hidden'; ddScroll[1].style.visibility = 'hidden'; ddOpen = false; cancelCount = 0; } } } } function ScrollDd() { if (scrollTimer) clearTimeout(scrollTimer); if ((scrollDirection == '-') && (ddFirst>0)) { ddFirst --; ddLast --; } else if ((scrollDirection == '+') && (ddLast<moduleRoot.selectNodes("item[@name='"+activiteit[chosenTab]+"']").length)) { ddFirst ++; ddLast ++; } else { ddScroll[0].style.display = 'none'; ddScroll[1].style.display = 'none'; ddScroll[0].style.visibility = 'hidden'; ddScroll[1].style.visibility = 'hidden'; if (ddFirst>0) { ddScroll[0].style.display = 'inline'; ddScroll[0].style.visibility = 'inherit'; } if (ddLast<moduleRoot.selectNodes("item[@name='"+activiteit[chosenTab]+"']").length) { ddScroll[1].style.display = 'inline'; ddScroll[1].style.visibility = 'inherit'; } } updateDdList(); if (ddScrollMode) scrollTimer = window.setTimeout("ScrollDd()",50); } function stepIt() { for (var i=0; i<StepDot.length; i++) { StepDot[i].src = "images/dot_0.gif"; } StepDot[stepDotStep].src = "images/dot_1.gif"; StepArea.innerHTML = stepTexts[stepDotStep]; stepDotTimer = window.setTimeout("stopStep()",10000); } function stopStep() { clearTimeout(stepDotTimer) for (var i=0; i<StepDot.length; i++) { StepDot[i].src = "images/dot_0.gif"; } } function doGroeneWeek(num) { dagCount = 0; itmCount = 0; dagen = new Array('ma','di','wo','do','vr','za','zo'); if (!parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']")) { // week? newWeek = parent.xmlUserData.createElement("planweek"); newWeek.setAttribute("num",weekNum); parent.userRoot.selectSingleNode("data").appendChild(newWeek); } while (parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag")) { // alle dagen wissen parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']").removeChild(parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag")); } while (dagCount < 5) { actFact = parseInt(groeneWeek[num][itmCount+2]); subtot = Math.round(((actFact/10) * 30) * (gewicht/60)); norm = Math.round(30/60*factor2*gewicht); result = (subtot<norm)?'r':'g'; newDag = parent.xmlUserData.createElement("dag"); newDag.setAttribute("naam",dagen[dagCount]); newDag.setAttribute("totaal",subtot); newDag.setAttribute("result",result); newDag.setAttribute("gewicht",gewicht); newAct = parent.xmlUserData.createElement("act"); newAct.setAttribute("num",groeneWeek[num][itmCount]); newAct.setAttribute("acttot",subtot); newDag.appendChild(newAct); newItem = parent.xmlUserData.createElement("item"); newItem.setAttribute("factor",groeneWeek[num][itmCount+2]); newItem.setAttribute("kcal",subtot); newItem.setAttribute("tijd","30"); newItem.text = groeneWeek[num][itmCount+1]; newAct.appendChild(newItem); parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']").appendChild(newDag); if (groeneWeek[num].length>itmCount+3) itmCount += 3; dagCount++; } parent.xmlUserData.save(parent.userDataFileName); getWeek(); GroenewekenArea.style.visibility = 'hidden'; groeneWeken = false; } function CountAction(c) { theNum = c; theValue = parseInt(CountBox[c].value); if ((theValue >= minMax[theNum*2]) && (theValue <= minMax[(theNum*2)+1])) { CountBox[c].value = parseInt(CountBox[c].value); } else CountBox[c].value = minMax[theNum*2]; if (theNum == 0) { // week weekNum = parseInt(CountBox[0].value); chosenDag = ''; chosenDagNum = -1; for (var i=0; i<DagBtn.length; i++) { DagBtn[i].style.backgroundImage = "url('images/bt_dag_"+DagBtn[i].dag+((DagBtn[i].dag == chosenDag)?"_2":"_0")+".gif')"; } TabArea.style.backgroundImage = "url('images/tab_default.bmp')"; TabImg.filters.blendTrans.Apply(); TabImg.src = "images/bck_"+((parent.goPage == 'beweegplan.html')?"plan":"meet")+"tab_default.bmp"; TabImg.filters.blendTrans.Play(); chosenTab = -1; CopyPaste.style.visibility = 'hidden'; getWeek(); stepDotStep = 0; stepIt(); } else calculateDag(); } function calculateDag() { if (chosenTab == -1) { CountBox[1].value = 0; return; } gewicht = parseInt(parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+chosenDag+"']").getAttribute("gewicht")); if ((actFact == 0) || (actName == '')) return; subtot = Math.round(((actFact/10) * parseInt(CountBox[1].value)) * (gewicht/60)); norm = Math.round(30/60*factor2*gewicht); putItem(actName,actFact,parseInt(CountBox[1].value),subtot); tot = makeBlad(); ResultBox[chosenTab].innerText = tot; t = parseFloat(ResultBox[0].innerText)+parseFloat(ResultBox[1].innerText)+parseFloat(ResultBox[2].innerText)+parseFloat(ResultBox[3].innerText)+parseFloat(ResultBox[4].innerText); DagBox[chosenDagNum].innerText = Math.round(t); if (t<norm) { DagBox[chosenDagNum].className = 'dagBoxRed'; result = 'r'; } else if (t>=norm) { DagBox[chosenDagNum].className = 'dagBoxGreen'; result = 'g'; } if (DagBox[chosenDagNum].innerText != '0') { CopyPasteBtn[0].style.visibility = 'inherit'; CopyPaste.style.visibility = 'inherit'; } else CopyPaste.style.visibility = 'hidden'; if (cpweek != -1) { CopyPasteBtn[1].style.visibility = 'inherit'; CopyPaste.style.visibility = 'inherit'; } putResultInDag(tot,t,result); // checkWeekComplete(); } function makeBlad() { bladItems = parent.userRoot.selectNodes("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+chosenDag+"']/act[@num = '"+chosenTab+"']/item"); tot = 0; blString = '<table border="0" cellpadding="0" cellspacing="0">'; for (var i=bladItems.length-1; i>-1; i--) { blString += '<tr><td width="8"><img id="ActDelete" ref="'+bladItems[i].text+'" src="images/delete.gif" width="8" height="8" alt="activiteit verwijderen" border="0"/></td><td width="330" class="bladText">'+bladItems[i].text+'</td><td width="50" class="bladText">'+bladItems[i].getAttribute("tijd")+'</td><td width="40" class="bladText">'+bladItems[i].getAttribute("kcal")+'</td></tr>'; tot += parseInt(bladItems[i].getAttribute("kcal")); } blString += '</table>'; BladArea.innerHTML = blString; return tot; } function checkWeekComplete() { complete = true; for (var i=0; i<7; i++) { if (!parent.userRoot.selectSingleNode("data/week[@num = '"+weekNum+"']/dag[@naam = '"+DagBtn[i].dag+"']")) { complete = false; break; } } if (complete) { WeekBtn.style.visibility = 'inherit'; stepDotStep = 3; stepIt(); } else WeekBtn.style.visibility = 'hidden'; } function getWeek() { CountBox[1].value = 0; ResultBox[0].innerText = '0'; ResultBox[1].innerText = '0'; ResultBox[2].innerText = '0'; ResultBox[3].innerText = '0'; ResultBox[4].innerText = '0'; BladArea.innerHTML = ''; for (var i=0; i<7; i++) { if (parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+DagBox[i].parentElement.dag+"']")) { DagBox[i].innerText = Math.round(parseFloat(parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+DagBox[i].parentElement.dag+"']").getAttribute("totaal"))); DagBox[i].className = (parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+DagBox[i].parentElement.dag+"']").getAttribute("result")=='g')?'dagBoxGreen':'dagBoxRed'; } else { DagBox[i].innerText = '0'; DagBox[i].className = 'dagBoxNeutral'; } } // VoorbeeldButtons('hide'); // WeekArea.style.visibility = 'hidden'; // WeekResultImg.src = "images/weekresult_oranje.bmp"; // weekResult = false; // checkWeekComplete(); } function getDag() { if (!parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']")) { // week? newWeek = parent.xmlUserData.createElement("planweek"); newWeek.setAttribute("num",weekNum); parent.userRoot.selectSingleNode("data").appendChild(newWeek); } if (!parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+chosenDag+"']")) { // dag? newDag = parent.xmlUserData.createElement("dag"); newDag.setAttribute("naam",chosenDag); newDag.setAttribute("totaal","0"); newDag.setAttribute("result",""); newDag.setAttribute("gewicht",gewicht); parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']").appendChild(newDag); } BladArea.innerHTML = ''; CountBox[1].value = '0'; ResultBox[0].innerText = (parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+chosenDag+"']/act[@num = '0']"))?parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+chosenDag+"']/act[@num = '0']").getAttribute("acttot"):'0'; ResultBox[1].innerText = (parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+chosenDag+"']/act[@num = '1']"))?parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+chosenDag+"']/act[@num = '1']").getAttribute("acttot"):'0'; ResultBox[2].innerText = (parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+chosenDag+"']/act[@num = '2']"))?parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+chosenDag+"']/act[@num = '2']").getAttribute("acttot"):'0'; ResultBox[3].innerText = (parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+chosenDag+"']/act[@num = '3']"))?parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+chosenDag+"']/act[@num = '3']").getAttribute("acttot"):'0'; ResultBox[4].innerText = (parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+chosenDag+"']/act[@num = '4']"))?parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+chosenDag+"']/act[@num = '4']").getAttribute("acttot"):'0'; parent.xmlUserData.save(parent.userDataFileName); } function putItem(n,f,tijd,kcal,t) { if (!parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+chosenDag+"']/act[@num = '"+chosenTab+"']")) { newAct = parent.xmlUserData.createElement("act"); newAct.setAttribute("num",chosenTab); parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+chosenDag+"']").appendChild(newAct); } if (!parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+chosenDag+"']/act[@num = '"+chosenTab+"']/item[. = '"+n+"']")) { newItem = parent.xmlUserData.createElement("item"); newItem.setAttribute("factor",f); newItem.text = n; parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+chosenDag+"']/act[@num = '"+chosenTab+"']").appendChild(newItem); } parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+chosenDag+"']/act[@num = '"+chosenTab+"']/item[. = '"+n+"']").setAttribute("tijd",tijd); parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+chosenDag+"']/act[@num = '"+chosenTab+"']/item[. = '"+n+"']").setAttribute("kcal",kcal); parent.xmlUserData.save(parent.userDataFileName); } function putResultInDag(acttot,dagtot,result) { parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+chosenDag+"']/act[@num = '"+chosenTab+"']").setAttribute("acttot",acttot); parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+chosenDag+"']").setAttribute("totaal",dagtot); parent.userRoot.selectSingleNode("data/planweek[@num = '"+weekNum+"']/dag[@naam = '"+chosenDag+"']").setAttribute("result",result); parent.xmlUserData.save(parent.userDataFileName); } function getTab() { ddFirst = 0; ddLast = 8; actName = moduleRoot.selectNodes("item[@name='"+activiteit[chosenTab]+"']")[0].text; actFact = parseInt(moduleRoot.selectNodes("item[@name='"+activiteit[chosenTab]+"']")[0].getAttribute("factor")); ddWriteString = '<div id="ddScroll" dirtype="-" onselectstart="return false;" style="visibility:hidden; display:none"><img src="images/pijl_up.gif" width="6" height="4" alt="" border="0"></div>'; for (var i=ddFirst; i<ddLast; i++) { ddWriteString += '<div id="ddItem" factor="' + moduleRoot.selectNodes("item[@name='"+activiteit[chosenTab]+"']")[i].getAttribute("factor") +'"num="' + (i+1) + '" class="' + ((i==0)?'ddActShown':'ddActHidden')+'">' + moduleRoot.selectNodes("item[@name='"+activiteit[chosenTab]+"']")[i].text + '</div>'; } ddWriteString += '<div id="ddScroll" dirtype="+" onselectstart="return false;" style="visibility:hidden; display:none"><img src="images/pijl_down.gif" width="6" height="4" alt="" border="0"></div>'; dd[0].innerHTML = ddWriteString; ControlActiviteit.style.visibility = 'inherit'; ControlGezond.style.visibility = 'inherit'; CountBox[1].style.visibility = 'inherit'; makeBlad(); } function updateDdList() { for (var i=0; i<8; i++) { ddItem[i].factor = moduleRoot.selectNodes("item[@name='"+activiteit[chosenTab]+"']")[ddFirst+i].getAttribute("factor"); ddItem[i].innerText = moduleRoot.selectNodes("item[@name='"+activiteit[chosenTab]+"']")[ddFirst+i].text; } } function VoorbeeldButtons(t) { VoorbeeldBtn[0].style.visibility = (t=='hide')?"hidden":"visible"; VoorbeeldBtn[1].style.visibility = (t=='hide')?"hidden":"visible"; VoorbeeldBtn[2].style.visibility = (t=='hide')?"hidden":"visible"; } function buildWeek(t) { WeekArea.style.visibility = 'inherit'; WeekResultImg.filters.blendTrans.Apply(); if (t<3) theSrc = "images/weekresult_groen.bmp"; else if (t>3) theSrc = "images/weekresult_rood.bmp"; else theSrc = "images/weekresult_oranje.bmp"; WeekResultImg.src = theSrc; WeekResultImg.filters.blendTrans.Play(); WeekTitle.innerText = moduleRoot.selectNodes("//result")[t].selectSingleNode("titel").text; styleRule = '<?xml version="1.0"?>'; styleRule += '<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">'; styleRule += '<xsl:template match="/">'; styleRule += '<xsl:apply-templates select="//result['+t+']/tekst">'; styleRule += '<xsl:template>'; styleRule += '<xsl:copy>'; styleRule += '<xsl:apply-templates select="@* | * | comment() | pi() | text()"/>'; styleRule += '</xsl:copy>'; styleRule += '</xsl:template>'; styleRule += '</xsl:apply-templates>'; styleRule += '</xsl:template>'; styleRule += '</xsl:stylesheet>'; style = new ActiveXObject("Microsoft.XMLDOM"); style.loadXML(styleRule); WeekTekst.innerHTML = moduleData.transformNode(style); } var countTimer; var counting = false; var countObj; function RealCount() { clearTimeout(countTimer); theNum = parseInt(countObj.num); theFactor = (countObj.factor)?parseInt(countObj.factor):1; theValue = parseInt(CountBox[theNum].value); if (((countObj.innerText == '-') || (countObj.dirtype == '-')) && ((theValue-theFactor) >= minMax[theNum*2])) { theValue -= theFactor; } else if (((countObj.innerText == '+') || (countObj.dirtype == '+')) && ((theValue-theFactor) <= minMax[(theNum*2)+1])) { theValue += theFactor; } CountBox[theNum].value = theValue; CountAction(theNum); if (counting) countTimer = window.setTimeout('RealCount()',100); }