new STARTUP state

This commit is contained in:
Neale Pickett 2011-11-22 00:45:52 -07:00
parent ec72a5d25e
commit 82c97a9cd6
3 changed files with 43 additions and 49 deletions

4
TODO.txt Normal file
View File

@ -0,0 +1,4 @@
* Star indicator for lead jammer
* Add a halftime state
* Easier team name/logo selection from database
* Per-team timeout counter

View File

@ -21,6 +21,7 @@
color: yellow; color: yellow;
font-family: sans-serif; font-family: sans-serif;
font-weight: bold; font-weight: bold;
font-size: 133%;
} }
#jam, #period { #jam, #period {
background: #000; background: #000;

View File

@ -1,7 +1,7 @@
/* /*
* LADD Roller Derby Scoreboard * LADD Roller Derby Scoreboard
* Copyright © 2011 Neale Pickett <neale@woozle.org> * Copyright © 2011 Neale Pickett <neale@woozle.org>
* Time-stamp: <2011-11-21 23:17:49 neale> * Time-stamp: <2011-11-22 00:20:00 neale>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -17,11 +17,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
var TIMEOUT = 0; var STARTUP = 0;
var JAM = 1; var JAM = 1;
var ROTATE = 2; var ROTATE = 2;
var TIMEOUT = 3;
var state = TIMEOUT; var state = STARTUP;
function pad(i) { function pad(i) {
if (i < 10) { if (i < 10) {
@ -233,29 +234,25 @@ function handle(event) {
var team = e.id.substr(e.id.length - 1); var team = e.id.substr(e.id.length - 1);
var newstate; var newstate;
if (state == TIMEOUT) { switch (e.id) {
// During startup, everything is editable case "name-a":
switch (e.id) { case "name-b":
case "name-a": if (state == STARTUP) {
case "name-b":
teamname(team, prompt("Enter team " + team + " name", e.innerHTML)); teamname(team, prompt("Enter team " + team + " name", e.innerHTML));
break; }
case "logo-a": break;
case "logo-b": case "logo-a":
case "logo-b":
if (state == STARTUP) {
var u = prompt("Enter URL to team " + team + " logo"); var u = prompt("Enter URL to team " + team + " logo");
if (! u) return; if (! u) return;
e.src = u; e.src = u;
e.plastic = false; e.plastic = false;
break; }
case "score-a": break;
case "score-b": case "period":
var s = prompt("Enter team " + team + " score", e.innerHTML); if ((state == STARTUP) || (state == TIMEOUT)) {
if (! s) return;
e.innerHTML = s;
break;
case "period":
var r = prompt("Enter new time for period clock", e.innerHTML); var r = prompt("Enter new time for period clock", e.innerHTML);
if (! r) return; if (! r) return;
@ -269,41 +266,33 @@ function handle(event) {
for (var i in t) { for (var i in t) {
var v = t[i]; var v = t[i];
sec = (sec * 60) + Number(v); sec = (sec * 60) + Number(v);
} }
e.reset(sec*1000); e.reset(sec*1000);
break; } else {
case "periodtext":
period = 3 - period;
e.innerHTML = "Period " + period;
break;
case "jam":
newstate = JAM;
break;
}
} else {
switch (e.id) {
case "period":
newstate = TIMEOUT; newstate = TIMEOUT;
break;
case "jam":
if (state == JAM) {
newstate = ROTATE;
} else {
newstate = JAM;
}
break;
case "score-a":
case "score-b":
if (event.shiftKey == 1) {
score(team, -1);
} else {
score(team, 1);
}
return;
} }
break;
case "periodtext":
period = 3 - period;
e.innerHTML = "Period " + period;
break;
case "jam":
if (state == JAM) {
newstate = ROTATE;
} else {
newstate = JAM;
}
break;
case "score-a":
case "score-b":
if (event.shiftKey == 1) {
score(team, -1);
} else {
score(team, 1);
}
break;
} }
transition(newstate); transition(newstate);
} }