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;
font-family: sans-serif;
font-weight: bold;
font-size: 133%;
}
#jam, #period {
background: #000;

View File

@ -1,7 +1,7 @@
/*
* LADD Roller Derby Scoreboard
* 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
* 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/>.
*/
var TIMEOUT = 0;
var STARTUP = 0;
var JAM = 1;
var ROTATE = 2;
var TIMEOUT = 3;
var state = TIMEOUT;
var state = STARTUP;
function pad(i) {
if (i < 10) {
@ -233,29 +234,25 @@ function handle(event) {
var team = e.id.substr(e.id.length - 1);
var newstate;
if (state == TIMEOUT) {
// During startup, everything is editable
switch (e.id) {
case "name-a":
case "name-b":
if (state == STARTUP) {
teamname(team, prompt("Enter team " + team + " name", e.innerHTML));
}
break;
case "logo-a":
case "logo-b":
if (state == STARTUP) {
var u = prompt("Enter URL to team " + team + " logo");
if (! u) return;
e.src = u;
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;
case "period":
if ((state == STARTUP) || (state == TIMEOUT)) {
var r = prompt("Enter new time for period clock", e.innerHTML);
if (! r) return;
@ -269,25 +266,18 @@ function handle(event) {
for (var i in t) {
var v = t[i];
sec = (sec * 60) + Number(v);
}
e.reset(sec*1000);
} else {
newstate = TIMEOUT;
}
break;
case "periodtext":
period = 3 - period;
e.innerHTML = "Period " + period;
break;
case "jam":
newstate = JAM;
break;
}
} else {
switch (e.id) {
case "period":
newstate = TIMEOUT;
break;
case "jam":
if (state == JAM) {
newstate = ROTATE;
@ -302,8 +292,7 @@ function handle(event) {
} else {
score(team, 1);
}
return;
}
break;
}
transition(newstate);
}