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) {
// During startup, everything is editable
switch (e.id) { switch (e.id) {
case "name-a": case "name-a":
case "name-b": case "name-b":
if (state == STARTUP) {
teamname(team, prompt("Enter team " + team + " name", e.innerHTML)); teamname(team, prompt("Enter team " + team + " name", e.innerHTML));
}
break; break;
case "logo-a": case "logo-a":
case "logo-b": 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":
case "score-b":
var s = prompt("Enter team " + team + " score", e.innerHTML);
if (! s) return;
e.innerHTML = s;
break; break;
case "period": case "period":
if ((state == STARTUP) || (state == TIMEOUT)) {
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,25 +266,18 @@ 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);
} else {
newstate = TIMEOUT;
}
break; break;
case "periodtext": case "periodtext":
period = 3 - period; period = 3 - period;
e.innerHTML = "Period " + period; e.innerHTML = "Period " + period;
break; break;
case "jam":
newstate = JAM;
break;
}
} else {
switch (e.id) {
case "period":
newstate = TIMEOUT;
break;
case "jam": case "jam":
if (state == JAM) { if (state == JAM) {
newstate = ROTATE; newstate = ROTATE;
@ -302,8 +292,7 @@ function handle(event) {
} else { } else {
score(team, 1); score(team, 1);
} }
return; break;
}
} }
transition(newstate); transition(newstate);
} }