// test var var testcounter = 0; // Progress Bar Stuff // global var var progressBarPercentage = 0; // call this function to increase the percentage of the progress bar. function increaseProgressBarPercentageBy(addval) { progressBarPercentage += addval; pint = Math.round(progressBarPercentage) if (pint > 100) pint = 100; .style.width = pint + "%" .innerText = pint+"%"; } // a special function function open_special() { window.open('http://www.propellerhead.de/mystery/01/08/fliptier.html','win1','width=400,height=400,left=50,top=50,status=no,toolbar=no,scrollbars=no,resizable=no,location=no,menubar=no'); } // Several Constants // var N_COLS = grid[0].length; // var N_ROWS = grid.length; var Q_WIDTH = 30 + 1; // not sure if adding 1 is right. maybe because of the array var Q_HEIGHT = 30 + 1; var Q_MOUSEOVERBGCOLOR = "#dddddd"; // var HTML_TARGET = ".innerHTML"; // var SOLUTION_HTML_TARGET = ".innerHTML"; var CRSR_BLINK_SPEED = 250; var CRSR_BLINK_COLOR1 = "#a4ae7a"; var CRSR_BLINK_COLOR2 = "#e4eeaa"; var SYM_LETTER = "."; var SYM_WORDBEGIN = "I"; var SYM_WORDEND = "S"; var SYM_NOTHING = " "; var XWORDGRID_FIELDNAME = "XWordGrid"; // More or less useful variables var cursorIRQ; var currentFocusFieldId; var SolutionStr = ""; var qBoxIRQ; var tmpQnr; // to see if the question changed // string-array helper classes function replaceCharAt(sourceString, pos, byChar) { if(sourceString) { return sourceString.substring(0,pos) + byChar + sourceString.substring(pos+1,sourceString.length); } } // replace Char in a string function replaceCharInArray(arr, xpos, ypos, byChar) { arr[ypos] = replaceCharAt(arr[ypos], xpos, byChar); return arr; } // in an array of string, gets char at stringpos x in array element y function getCharInArray(arr, xpos, ypos) { return arr[ypos].charAt(xpos); } // make arr[x] of String to TextArea function arrayToTextArea(arr) { ares = ""; for(i=0;i<(arr.length - 1);++i) { ares += arr[i] + "\n"; } ares += arr[(arr.length)-1]; return ares; } // make arr[x][y] to textArea function twoDimArrayToTextArea(arr) { ares = ""; for(i=0;i<(arr.length - 1);++i) { for(j=0;j<(arr[i].length-1);++j) { ares += arr[i][j]; } ares += "\n"; } return ares; } function textAreaToArray(ta) { // count the elements: nv = ta.count(...) nv = 100; //##tmpvalue arr = new Array(nv); arr = ta.split("\r\n") return arr } // attr="X" or "Y", fid= field ID in format "FH42V32E", or "S" for solutionfieldnumber // returns either the value behind H or V function getCoordFromFID(attr,fid) { res = -1; if(attr == "X") { bsign = "H"; esign = "V" } else if(attr == "Y") { bsign = "V"; esign = "E" } else if(attr == "S") { bsign = "S"; esign = "E" } b = fid.indexOf(bsign); e = fid.indexOf(esign); if((b>0) && (e>0) && (b 0) { numcand = fid.substring(b+1,b+1+spos); } res=parseInt(numcand); } return res } // if a document is new, initialize the grid field. if not, load it into the grid function initOrLoadXWordGrid() { // init the field where the xword grid is remembered // only init when field is empty xf = eval("document.forms['xword']."+XWORDGRID_FIELDNAME) if (xf) { xfv = xf.value; xfa = textAreaToArray(xfv); makenew = true; if (xfa.length == parseInt(Q_HEIGHT)) if (xfa[0].length == parseInt(Q_WIDTH)) makenew = false if (makenew == true) { // wrong format, so // if the field HAS an entry (test if width or height is > e.g. 3), put an error if ((xfa.length > 3) || (xfa[0].length > 3)) { alert("Found a default entry, but not loading: should be sized h="+Q_HEIGHT+" w="+Q_WIDTH+", but is h="+ xfa.length+" w="+xfa[0].length+"."); } // make a new save field NTA_ROWS = Q_HEIGHT+2; // no idea why 2 NTA_COLS = Q_WIDTH+2; na = new Array(NTA_ROWS); for(h=0;h<=NTA_ROWS;++h) { la = new Array(NTA_COLS); for(l=0;l<=NTA_COLS;++l) { // initialization with blank la[l] = " "; } na[h] = la; } // write the content in the xwordgridfield xf.value = twoDimArrayToTextArea(na); } else { // format ok } } } function initXWord() { checkXWordIntegrity(); initOrLoadXWordGrid(); } function hideQuestionbox() { boxObj = ; boxObj.style.visibility = "hidden"; boxObj.innerText = ""; } function disallowHideQuestionbox() { window.clearTimeout(qBoxIRQ); } function allowHideQuestionbox() { qBoxIRQ = window.setTimeout("hideQuestionbox()",400); } //display Question if(!(window.event)) { document.onmouseover=getMousePositions; } var mouseX = 0; var mouseY = 0; function getMousePositions(e) { if(!(window.event)) { mouseX = e.clientX; mouseY = e.clientY; } } function displayQuestion(qnr) { boxObj = ; boxObj.innerHTML = "
" + qnr + "
  " + questions[qnr-1][0] + "

" + questions[qnr-1][1]; if (qnr != tmpQnr) { if(window.event) { cx = window.event.clientX; cy = window.event.clientY; } else { cx = mouseX; cy = mouseY; } if(cy > 250) { dy = -200 } else dy = 30; if(cx > 250) { dx = -100 } else dx = 100; if(!(window.pageXOffset)) { oy = document.body.scrollTop; // scrolled down ox = document.body.scrollLeft; // scrolled right } else { ox = window.pageXOffset; oy = window.pageYOffset; } boxObj.style.top = cy + dy + oy; boxObj.style.left = cx + dx + ox; tmpQnr = qnr; } boxObj.style.visibility = "visible"; disallowHideQuestionbox(); } // If a letter is found, enter it into the solution string // If then all letters are solved, show the otherwise hidden send button function enterLetterInSolutionString(ind, letter) { // --ind; // convert from xword index number to array index number SolutionStr = document.forms['xword'].Solution.value; // Find the appropriate letter in the word grid and replace it cnt = 0; var i = 0; for(cnt=0;cnt=37 && kc<=40) { dx = 0; dy = 0; if(kc==37) dx=-1; if(kc==38) dy=-1; if(kc==39) dx=1; if(kc==40) dy=1; newx = getCoordFromFID("X",fid) + dx; newy = getCoordFromFID("Y",fid) + dy; // news = getCoordFromFID("S",fid); //alert(news); newid = "CH"+newx+"V"+newy+"E"; //newids = "CH"+newx+"V"+newy+"S"+news+"E"; newfocusfield = eval(getObjXS(newid)); //newfocusfields = eval(getObjXS(newids)); if (newfocusfield != null) { fieldFocus(newid); // again we will fill the keyCode with some nothing-doing value if(window.event) { window.event.keyCode = 37; } return; } //else if (newfocusfields != null) //{ // fieldFocus(newids); // // again we will fill the keyCode with some nothing-doing value // window.event.keyCode = 37; // return; //} } // delete and backspace will be treated as spacebar if (kc==46 || kc==8) kc = 32; newLetter = String.fromCharCode(kc); validLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ "; if (validLetters.indexOf(newLetter) >= 0) { newLetterTranslated = newLetter; if (newLetter == " ") newLetterTranslated = " "; // Is the current focused field a solution index field? // If yes, also enter the value in the solution field and the HTML field. sind = fid.indexOf("S"); if (sind >= 0) { eind = fid.indexOf("E"); solutionIndex = fid.substring(sind+1,eind); // solutionLetterArray[solutionIndex-1] = newLetter; enterLetterInSolutionString(solutionIndex-1, newLetter); solutionObj = eval(getObjXS("CS"+solutionIndex)); if (solutionObj) { solutionObj.innerHTML = newLetterTranslated; } } // In any case, enter the letter into the grid field. cfObj.innerHTML = newLetterTranslated; ff = eval("document.forms['xword']."+XWORDGRID_FIELDNAME) ff.value = arrayToTextArea(replaceCharInArray(textAreaToArray(ff.value),getCoordFromFID("X",fid),getCoordFromFID("Y",fid), newLetter)); // A little workaround to avoid that, on the IE, the pressed SPACEBAR is interpreted as "Scroll down". // We overwrite the event key. Don't ask why it's 37. 37 just doesn't do ANYthing, that's why. In a way, it's like the 42. if (kc==32) { window.event.keyCode = 37; } } } } } function cursorActivity() { fid = currentFocusFieldId; fid = "C" + fid.substr(1); fieldObj = eval(getObjXS(fid)); if (fieldObj.style.backgroundColor == CRSR_BLINK_COLOR1) fieldObj.style.backgroundColor = CRSR_BLINK_COLOR2 else fieldObj.style.backgroundColor = CRSR_BLINK_COLOR1 } function fieldUnfocus() { fid = currentFocusFieldId; if (fid != null) { fid = "C" + fid.substr(1); eval(getObjXS(fid)+".style.backgroundColor='#ffffff';"); clearInterval(cursorIRQ); } } function fieldFocus(fid) { // cursor activity fieldUnfocus(); fid = "F" + fid.substr(1); currentFocusFieldId = fid; cursorIRQ = setInterval("cursorActivity()",CRSR_BLINK_SPEED); } function mouseOver(fid) { eval(getObjXS(fid)+".style.backgroundColor = Q_MOUSEOVERBGCOLOR;"); } function getObjXS(id) { return ''; }