"; wc = window.open("","nocren","width=900,height=800,left=150,top=100") wc.document.write(html); wc.document.close(); } function keyHit(evt) { var e = evt || window.event; if (e.keyCode == 40 || e.keyCode == 34 || e.keyCode == 13 || e.keyCode == 38 || e.keyCode == 33) // mode=mode; // For debugging, can put a break point there. var m = Math.floor(j/8); // Create team occurrence number (can change depending on sort type) if (maxTeams < m) // Make maxTeams keep up. maxTeams = m; if (mode == 3 && e.keyCode == 13) { // Answered last question correctly teamTable[m].score++; // Update internal table teamTable[m].cumul++; document.trivia.elements[j].value = score=teamTable[m].score; // Update display document.trivia.elements[j+1].value = score=teamTable[m].cumul; } if (e.keyCode == 40 || e.keyCode == 34 || e.keyCode == 13) { // Down arrow, page down, or Enter j= ( j < 184)? j+=8: j-=184; } //Move down or wrap up to top if (e.keyCode == 38 || e.keyCode == 33) { j= ( j > 8)? j-=8: j+=184; } //Move up or wrap down to bottom if (j > 191 || j < 0) alert("j = " + j); // Should never happen if (mode < 4) document.trivia.elements[j].focus(); return true; } function teamLine(Num,name,r1,r2,r3,r4,score,cumulative) { this.num = Num; this.name = name; this.r1 = r1; this.r2 = r2; this.r3 = r3; this.r4 = r4; this.score = score; this.cumul = cumulative; } function NumSort(a,b) { if (a.num > b.num) return 1; if (a.num < b.num) return -1; else return 0; } function TeamSort(a,b) { if (a.name > b.name) return 1; if (a.name < b.name) return -1; else return 0; } function scoreSort(a,b) { var aScore=0, bScore=0, diff; aScore = (a.r1 == "*")? 1 : 0; // Sort on rounds won aScore += (a.r2 == "*")? 1 : 0; aScore += (a.r3 == "*")? 1 : 0; aScore += (a.r4 == "*")? 1 : 0; bScore = (b.r1 == "*")? 1 : 0; bScore += (b.r2 == "*")? 1 : 0; bScore += (b.r3 == "*")? 1 : 0; bScore += (b.r4 == "*")? 1 : 0; diff = bScore - aScore; // Major sort: prev rounds won if (diff != 0) return diff; diff = b.cumul - a.cumul; // If prev rounds equal, use cumulative score if (diff == 0) // If tie return TeamSort(a,b); // Sort alphabetical else return diff; // Return cumulative diff } function alphaNames() { mode=1; // Entering team names j=1; // 2nd col document.control.memo.value ="Col 2 locked"; document.control.memo.style.color="red"; document.trivia.elements[j].focus(); } function alphaDisp() { loadAll(); // Refresh tables teamTable.sort(TeamSort); redisplay(); } function enterNum() { mode=0; // Entering team numbers, location in room document.control.memo.value ="Col 1 locked"; document.control.memo.style.color="red"; j=0; // 1st column document.trivia.elements[j].focus(); } function doScore() { loadAll(); teamTable.sort(NumSort); redisplay(); mode=3; document.control.memo.value ="Col 7 locked"; document.control.memo.style.color="red"; j=6; document.trivia.elements[j].focus(); } function showScores() { document.control.memo.value ="Page Open"; document.control.memo.style.color="blue"; loadAll(); teamTable.sort(scoreSort); redisplay(); } function endRound() { mode=4; document.control.memo.value ="Page Open"; document.control.memo.style.color="blue"; for (var i =0; i " ") ; i++,i8=i*8) { Num=document.trivia.elements[i8].value; name=document.trivia.elements[i8+1].value; r1=document.trivia.elements[i8+2].value; r2=document.trivia.elements[i8+3].value; r3=document.trivia.elements[i8+4].value; r4=document.trivia.elements[i8+5].value; score=parseInt(document.trivia.elements[i8+6].value); if (isNaN(score)) score=0; cumulative=parseInt(document.trivia.elements[i8+7].value); if (isNaN(cumulative)) cumulative=0; teamTable[i] = new teamLine(Num, name, r1, r2, r3, r4, score, cumulative); } maxTeams=teamTable.length; //alert("There are " + maxTeams + " teams"); redisplay(); } function delTeam() { var ans=prompt("Is team at the bottom? ") if (ans == "y" || ans == "Y") { var i8 = (teamTable.length -1) * 8; document.trivia.elements[i8+1].value =" "; maxTeams--; teamTable.length--; redisplay(); } }

Trivia Scoreboard

No.Team NameRd. 1Rd. 2Rd. 3Rd. 4ScoreCumulative
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.