home *** CD-ROM | disk | FTP | other *** search
Wrap
var activeDd = -1; var cancelCount = 0; var ddOpen = false; var userName = ''; var profielType = 0; var minMax = new Array(0,120,30,260,10,300); var qiMode = false; var moduleData = new ActiveXObject("Microsoft.XMLDOM"); moduleData.load("data/profiel.xml"); var moduleRoot = moduleData.documentElement; var xmlUserData = new ActiveXObject("Microsoft.XMLDOM"); xmlUserData.load("data/gebruikers.xml"); var userRoot = xmlUserData.documentElement; function showPage() { buildPage(); AppScreen.style.visibility = "visible"; NaamBox.style.visibility = "visible"; } function buildPage() { TextArea.innerHTML = moduleRoot.selectSingleNode("text").text; Geluid[parent.soundSettings].style.textDecoration = 'underline'; if ((userRoot.selectNodes("gebruiker").length > 0) && (parent.userName == '')) { // er zijn reeds gebruikers, maar er is nog niet aangelogd ddWriteString = '<div id="ddItem" num="0" class="ddShown">...</div>'; for (var i=0; i<userRoot.selectNodes("gebruiker").length; i++) { ddWriteString += '<div id="ddItem" num="' + (i+1) + '" class="ddHidden">' + userRoot.selectNodes("gebruiker")[i].getAttribute("naam") + '</div>'; } dd[0].innerHTML = ddWriteString; Indicator[1].style.visibility = 'inherit'; } else if ((userRoot.selectNodes("gebruiker").length > 0) && (parent.userName != '')) { // er zijn reeds gebruikers, en er is aangelogd ddWriteString = '<div id="ddItem" num="0" class="ddHidden">...</div>'; for (var i=0; i<userRoot.selectNodes("gebruiker").length; i++) { classType = (userRoot.selectNodes("gebruiker")[i].getAttribute("naam") == parent.userName)?'ddShown':'ddHidden'; ddWriteString += '<div id="ddItem" num="' + (i+1) + '" class="' + classType + '">' + userRoot.selectNodes("gebruiker")[i].getAttribute("naam") + '</div>'; } dd[0].innerHTML = ddWriteString; Indicator[1].style.visibility = 'inherit'; Indicator[0].style.backgroundImage = "url('images/indcover.bmp')"; Indicator[1].style.backgroundImage = "url('images/indicator.bmp')"; profielType = 1; userName = parent.userName; buildSubPage(); } } 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 != userName) { dd[activeDd].childNodes[i].className = 'ddHidden'; } else dd[activeDd].childNodes[i].className = 'ddShown'; } ddOpen = false; cancelCount = 0; } } } } function profielTypeChange(n) { if (profielType == n) return; else profielType = n; Indicator[2].style.visibility = 'hidden'; Indicator[3].style.visibility = 'hidden'; Indicator[4].style.visibility = 'hidden'; Indicator[5].style.visibility = 'hidden'; CountBox[0].style.visibility = 'hidden'; CountBox[1].style.visibility = 'hidden'; CountBox[2].style.visibility = 'hidden'; ProfielBtn[0].style.visibility = 'hidden'; ProfielBtn[1].style.visibility = 'hidden'; ProfielBtn[2].style.visibility = 'hidden'; if (n == 0) { Indicator[1].style.backgroundImage = "url('images/indcover.bmp')"; Indicator[0].style.backgroundImage = "url('images/indicator.bmp')"; for (var i=0; i<dd[0].childNodes.length; i++) { dd[0].childNodes[i].className = (i==0)?'ddShown':'ddHidden'; } } else { Indicator[0].style.backgroundImage = "url('images/indcover.bmp')"; Indicator[1].style.backgroundImage = "url('images/indicator.bmp')"; } } function NaamAction() { if ((userName == '') || (userName == '...')) { FbkArea.innerHTML = 'Om een gebruikersprofiel aan te maken dient u een geldige naam in te voeren.<br/><br/>Om een bestaand profiel op te halen dient u een naam te selecteren.'; return; } else FbkArea.innerText = ''; if (profielType == 0) { // nieuw parent.emptyProfiel(userName); parent.userName = userName; buildSubPage(); } else { // bestaand parent.getProfiel(userName); parent.userName = userName; buildSubPage(); } } 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]; } function buildSubPage() { if (parent.userRoot.selectSingleNode("geslacht").text == 'm') { Sex[0].style.textDecoration = 'underline'; Sex[1].style.textDecoration = 'none'; } else if (parent.userRoot.selectSingleNode("geslacht").text == 'v') { Sex[0].style.textDecoration = 'none'; Sex[1].style.textDecoration = 'underline'; } CountBox[0].innerText = parent.userRoot.selectSingleNode("leeftijd").text; CountBox[1].innerText = parent.userRoot.selectSingleNode("lengte").text; CountBox[2].innerText = parent.userRoot.selectSingleNode("gewicht").text; Indicator[2].style.visibility = 'inherit'; Indicator[3].style.visibility = 'inherit'; Indicator[4].style.visibility = 'inherit'; Indicator[5].style.visibility = 'inherit'; CountBox[0].style.visibility = 'inherit'; CountBox[1].style.visibility = 'inherit'; CountBox[2].style.visibility = 'inherit'; if (profielType == 0) { // nieuw ProfielBtn[0].style.visibility = 'hidden'; ProfielBtn[1].style.visibility = 'hidden'; ProfielBtn[2].style.visibility = 'inherit'; } else { // bestaand ProfielBtn[0].style.visibility = 'inherit'; ProfielBtn[1].style.visibility = 'inherit'; ProfielBtn[2].style.visibility = 'inherit'; } } function buildQi() { geslacht = (Sex[1].style.textDecoration == 'underline')?'v':'m'; leeftijd = CountBox[0].value; lengte = CountBox[1].value; gewicht = CountBox[2].value; qi = Math.round(10 * (gewicht / Math.pow((lengte/100),2)))/10; 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="//inlog/qi">'; 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); QiArea.innerHTML = moduleData.transformNode(style); QiArea.innerHTML += '<p><table width="220" cellpadding="0" cellspacing="0"><tr><td width="160" style="color:#000000">Uw quetelet index is: </td><td>' + qi + '</td></tr></table>'; for (var i=0; i<moduleRoot.selectNodes("fbk").length; i++) { minQI = parseFloat(moduleRoot.selectNodes("fbk")[i].getAttribute("min")); maxQI = parseFloat(moduleRoot.selectNodes("fbk")[i].getAttribute("max")); if ((qi >= minQI) && (qi < maxQI)) { QiArea.innerHTML += moduleRoot.selectNodes("fbk")[i].selectNodes("text")[0].text; if (moduleRoot.selectNodes("fbk")[i].getAttribute("displaymin") == "true") QiArea.innerHTML += '<p><table width="220" cellpadding="0" cellspacing="0"><tr><td width="160" style="color:#000000">Minimaal gewicht: </td><td>' + Math.round(185 * Math.pow((lengte/100),2))/10 + '</td></tr></table>'; if (moduleRoot.selectNodes("fbk")[i].getAttribute("displaymax") == "true")QiArea.innerHTML += '<p><table width="220" cellpadding="0" cellspacing="0"><tr><td width="160" style="color:#000000">Maximaal gewicht: </td><td>' + Math.round(249 * Math.pow((lengte/100),2))/10 + '</td></tr></table>'; if (moduleRoot.selectNodes("fbk")[i].selectNodes("text")[1]) QiArea.innerHTML += moduleRoot.selectNodes("fbk")[i].selectNodes("text")[1].text; } } QiArea.style.visibility = 'inherit'; } function storeData() { if (userName == "") return; if (!userRoot.selectSingleNode("gebruiker[@naam = '" + userName + "']")) { // gebruiker toevoegen newUser = xmlUserData.createElement("gebruiker"); userRoot.appendChild(newUser); userRoot.lastChild.setAttribute("naam",userName); xmlUserData.save("data/gebruikers.xml"); } geslacht = (Sex[1].style.textDecoration == 'underline')?'v':'m'; leeftijd = CountBox[0].value; lengte = CountBox[1].value; gewicht = CountBox[2].value; parent.putProfiel(userName,geslacht,leeftijd,lengte,gewicht); } function eraseCurrentUser() { for (var i=0; i<userRoot.childNodes.length; i++) { if (userRoot.childNodes[i].getAttribute("naam") == userName) { userRoot.removeChild(userRoot.childNodes(i)); } } xmlUserData.save("data/gebruikers.xml"); userName = ""; parent.userName = ""; } 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()',200); }