Merge branch 'master' into overlay

Conflicts:
	res/scoreboard.css
This commit is contained in:
Neale Pickett 2014-02-15 22:03:22 -07:00
commit 96fc6b15f9
3 changed files with 83 additions and 22 deletions

View File

@ -97,8 +97,14 @@ input {
.timeouts {
<<<<<<< HEAD
margin-top: 4.8em;
font-size: 20%;
=======
position: absolute;
width: 1.8em;
bottom: 0.1em;
>>>>>>> master
}
@ -120,6 +126,7 @@ input {
}
.clocks .timeout {
background: #044;
}
.clocks .lineup {
background: #060;

View File

@ -34,7 +34,7 @@
<input type="image" class="setup load" id="load-a" src="ic_picture.png">
</div>
<span class="score" id="score-a">-</span>
<span class="timeouts" id="timeouts-a">3</span>
<canvas class="timeouts" id="timeouts-a" height="20" width="300" data-gravity="west">
</div>
<div class="team" id="team-b">
@ -45,7 +45,7 @@
<input type="image" class="setup load" id="load-b" src="ic_picture.png">
</div>
<span class="score" id="score-b">-</span>
<span class="timeouts" id="timeouts-b">3</span>
<canvas class="timeouts" id="timeouts-b" height="20" width="300" data-gravity="east">
</div>
<div class="clocks">

View File

@ -35,7 +35,6 @@ var presets = [
var period_time;
var jam_time;
var lineup_time;
var timeouts;
/* State names */
var SETUP = 0;
@ -186,6 +185,66 @@ function startTimer(element) {
timer_updates.push(pulse);
}
// Timeout arrow thingy
function timeouts(c, total) {
var ctx = c.getContext("2d")
var gravity = c.getAttribute("data-gravity")
var enabled = "#ffff00"
var disabled = "#666666"
c.render = function() {
var bw = 300 / c.max;
var pw = bw / 10;
ctx.clearRect(0, 0, c.width, c.height)
ctx.save()
ctx.fillStyle = "#ffff00"
for (var i = 0; i < c.max; i += 1) {
ctx.fillStyle = disabled
if (gravity == "east") {
if (c.max - i <= c.cur) {
ctx.fillStyle = enabled
}
} else {
if (i < c.cur) {
ctx.fillStyle = enabled
}
}
ctx.beginPath()
ctx.moveTo(i * bw + pw, c.height)
ctx.lineTo(i*bw + bw/2, c.height - 20)
ctx.lineTo(i*bw + bw - pw, c.height)
ctx.closePath()
ctx.fill()
}
ctx.restore()
}
c.set = function(cur) {
c.cur = cur
if (c.cur == -1) {
c.cur = c.max
}
c.render()
}
c.dec = function() {
c.set(c.cur - 1)
}
c.set_max = function(max) {
c.max = max
c.cur = max
c.render()
}
c.set_max(total)
}
// Transition state machine based on state
function transition(newstate) {
var jt = e("jam");
@ -342,14 +401,7 @@ function handle(event) {
break;
case "timeouts-a":
case "timeouts-b":
// Allow for timeouts > 3
var v = Number(tgt.innerHTML);
v -= adj;
if (v == -1) {
v = timeouts;
}
tgt.innerHTML = v;
tgt.dec()
break;
case "period":
if ((state == SETUP) || (state == TIMEOUT)) {
@ -511,8 +563,8 @@ function save() {
"preset": e("preset").innerHTML,
"score_a": e("score-a").innerHTML,
"score_b": e("score-b").innerHTML,
"timeouts_a": e("timeouts-a").innerHTML,
"timeouts_b": e("timeouts-b").innerHTML,
"timeouts_a": e("timeouts-a").cur,
"timeouts_b": e("timeouts-b").cur,
"period_clock": e("period").remaining(),
}
);
@ -521,6 +573,7 @@ function save() {
function load_preset(preset_name) {
var inc = false;
var pn = 0;
var ntimeouts = 3;
if (preset_name == +1) {
preset_name = e("preset").innerHTML;
@ -540,15 +593,16 @@ function load_preset(preset_name) {
period_time = presets[pn][1];
jam_time = presets[pn][2];
lineup_time = presets[pn][3];
timeouts = presets[pn][4];
ntimeouts = presets[pn][4];
e("preset").innerHTML = preset_name;
e("jam").set(jam_time);
e("period").set(period_time);
e("timeouts-a").innerHTML = timeouts;
e("timeouts-b").innerHTML = timeouts;
e("score-a").innerHTML = 0;
e("score-b").innerHTML = 0;
timeouts(e("timeouts-a"), ntimeouts)
timeouts(e("timeouts-b"), ntimeouts)
}
function load() {
@ -560,9 +614,9 @@ function load() {
e("score-a").innerHTML = state.score_a;
e("score-b").innerHTML = state.score_b;
e("timeouts-a").innerHTML = (state.timeouts_a >= 0) ? state.timeouts_a : timeouts;
e("timeouts-b").innerHTML = (state.timeouts_b >= 0) ? state.timeouts_b : timeouts;
e("timeouts-a").grape = state.timeouts_a
e("timeouts-a").set(state.timeouts_a)
e("timeouts-b").set(state.timeouts_b)
}
chrome.storage.local.get({
@ -594,14 +648,14 @@ function start() {
ei("score-b")
ei("jammer-a");
ei("jammer-b");
ei("timeouts-a");
ei("timeouts-b");
ei("timeouts-a")
ei("timeouts-b")
ei("period");
ei("jam");
ei("prefs");
ei("close");
ei("preset");
e("color-a").addEventListener("change", function() {recolor("a")}, false);
e("color-b").addEventListener("change", function() {recolor("b")}, false);