From c404968c6cb9b7a302b9e3ae79a8d65ac7f402d6 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Sat, 15 Feb 2014 17:06:58 -0700 Subject: [PATCH 1/2] Add team name box (hidden) --- res/scoreboard.css | 4 ++++ res/scoreboard.html | 10 ++++++---- res/scoreboard.js | 12 +++++++----- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/res/scoreboard.css b/res/scoreboard.css index db46b9a..ab0beca 100644 --- a/res/scoreboard.css +++ b/res/scoreboard.css @@ -61,6 +61,10 @@ input[readonly] { text-align: center; } +.name { + display: none; +} + .logo { text-align: center; } diff --git a/res/scoreboard.html b/res/scoreboard.html index 0fe68a1..394b811 100644 --- a/res/scoreboard.html +++ b/res/scoreboard.html @@ -27,27 +27,29 @@
+ + - 3 - - + 3
+ + - 3 - - + 3
diff --git a/res/scoreboard.js b/res/scoreboard.js index 120a072..2ff56c9 100644 --- a/res/scoreboard.js +++ b/res/scoreboard.js @@ -602,8 +602,8 @@ function start() { ei("close"); ei("preset"); - e("color-a").addEventListener("change", function() {rekitty("a")}, false); - e("color-b").addEventListener("change", function() {rekitty("b")}, false); + e("color-a").addEventListener("change", function() {recolor("a")}, false); + e("color-b").addEventListener("change", function() {recolor("b")}, false); ei("periodtext").innerHTML = periodtext[period]; ei("jamtext").innerHTML = jamtext[3]; @@ -622,13 +622,15 @@ function start() { } -function rekitty(team) { +function recolor(team) { var i = e("img-" + team) var k = e("kitty-" + team) + var n = e("name-" + team) var color = e("color-" + team).value i.style.display = "none" k.style.display = "inline" + n.style.backgroundColor = color kitty(k.getContext("2d"), color) } @@ -649,8 +651,8 @@ function resize() { k.width = kw k.height = kh } - rekitty("a") - rekitty("b") + recolor("a") + recolor("b") } window.onload = start; From d46d47ad4cd402ece410cf3f5e254bbc47a9b725 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Sat, 15 Feb 2014 19:52:34 -0700 Subject: [PATCH 2/2] JavaScript updates from the overlay branch --- res/scoreboard.js | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/res/scoreboard.js b/res/scoreboard.js index 2ff56c9..9489fbb 100644 --- a/res/scoreboard.js +++ b/res/scoreboard.js @@ -225,8 +225,8 @@ function transition(newstate) { } // Reset lead jammer indicators - e("jammer-a").className = ""; - e("jammer-b").className = ""; + e("jammer-a").className = "jammer"; + e("jammer-b").className = "jammer"; var setupElements = document.getElementsByClassName("setup") for (var i = 0; i < setupElements.length; i += 1) { @@ -287,11 +287,11 @@ function score(team, points) { function leadJammer(team) { tgt = e("jammer-" + team); - var on = ! tgt.className; + var on = (tgt.className.indexOf("lead") == -1); - e("jammer-a").className = ""; - e("jammer-b").className = ""; - if (on) tgt.className = "lead"; + e("jammer-a").className = "jammer"; + e("jammer-b").className = "jammer"; + if (on) tgt.className = "lead jammer"; } function changeLogo(team) { @@ -622,21 +622,38 @@ function start() { } +function fgColor(color) { + var v = 0 + + for (var i = 0; i < 3; i += 1) { + v += parseInt(color.substr(1+i*2, 2), 16) + } + if (v / 3 >= 0x88) { + return "#000000" + } else { + return "#ffffff" + } +} + function recolor(team) { var i = e("img-" + team) var k = e("kitty-" + team) - var n = e("name-" + team) + var t = e("team-" + team) var color = e("color-" + team).value - i.style.display = "none" - k.style.display = "inline" - n.style.backgroundColor = color - kitty(k.getContext("2d"), color) + if (k.style) { + i.style.display = "none" + k.style.display = "inline" + kitty(k.getContext("2d"), color) + } else { + t.style.backgroundColor = color + t.style.color = fgColor(color) + } } function resize() { - var w = window.innerWidth / 7 - var h = window.innerHeight / 5 + var w = window.innerWidth / Number(document.body.getAttribute("data-x") || 7) + var h = window.innerHeight / Number(document.body.getAttribute("data-y") || 5) var fs = Math.min(w, h) document.body.style.fontSize = Math.min(w, h) + 'px'