From e0da7925c4e0338947ebc6bb0f0af28336fe7a46 Mon Sep 17 00:00:00 2001
From: Neale Pickett
Date: Mon, 16 Jul 2012 22:51:42 -0600
Subject: [PATCH] Fix for IE7, yay!
---
crg.html | 3 +--
res/scoreboard.css | 4 ++--
res/scoreboard.js | 60 +++++++++++++++++++++++++++++++---------------
3 files changed, 44 insertions(+), 23 deletions(-)
diff --git a/crg.html b/crg.html
index 3d8f993..89b8710 100644
--- a/crg.html
+++ b/crg.html
@@ -149,7 +149,6 @@ img, p {
bottom: 0;
}
-
@@ -192,7 +191,7 @@ tenths = false;
0
- -:--.-
+ -:--
diff --git a/res/scoreboard.css b/res/scoreboard.css
index 3bd5fc9..cc0ec87 100644
--- a/res/scoreboard.css
+++ b/res/scoreboard.css
@@ -70,6 +70,7 @@ body {
/* Jammer indicators */
#jammer-a, #jammer-b {
+ font-family: monospace;
position: absolute;
bottom: 0em;
color: #444;
@@ -144,8 +145,7 @@ body {
position: absolute;
font-size: 50%;
bottom: 2.2em;
- left: 50%;
- margin-left: 3em;
+ right: 30%;
}
diff --git a/res/scoreboard.js b/res/scoreboard.js
index 5a8c808..fe9e972 100644
--- a/res/scoreboard.js
+++ b/res/scoreboard.js
@@ -432,16 +432,20 @@ function key(event) {
transition(newstate);
}
-function dfl(v, d) {
- if (v == undefined) {
+function get(k, d) {
+ if (! window.localStorage) {
return d;
} else {
+ var v = window.localStorage["rdsb_" + k];
+ if (v == undefined) {
+ return d;
+ }
return v;
}
}
function store(k, v) {
- if ((v == undefined) || ! localStorage) {
+ if ((v == undefined) || ! window.localStorage) {
return;
} else {
localStorage["rdsb_" + k] = v;
@@ -449,8 +453,6 @@ function store(k, v) {
}
function save() {
- var ls = localStorage || {};
-
store("period_clock", e("period").remaining());
store("name_a", e("name-a").innerHTML);
store("name_b", e("name-b").innerHTML);
@@ -460,27 +462,48 @@ function save() {
store("score_b", e("score-b").innerHTML);
store("timeout_a", e("timeouts-a").innerHTML);
store("timeout_b", e("timeouts-b").innerHTML);
+ store("jamno", jamno);
store("period", period);
}
+function iecheck() {
+ // If it's IE, it's got to be at least 7
+ var ua = navigator.userAgent;
+ var ie = ua.indexOf("MSIE ");
+
+ if (ie == -1) {
+ // Not IE
+ return;
+ } else {
+ var n = parseFloat(ua.substring(ie + 5, ua.indexOf(";", ie)));
+ if (n < 7) {
+ alert("Your browser is too old to run the Woozle scoreboard.\nYou can use Firefox, Chrome, Opera, or Internet Explorer 7 and up.");
+ }
+ }
+}
+
function start() {
+ resize();
+ iecheck();
+
var p = document.getElementById("period");
var j = document.getElementById("jam");
- var ls = localStorage || {};
var c;
- // IE8 doesn't have localStorage for file:// URLs :<
- e("name-a").innerHTML = dfl(ls.rdsb_name_a, "Home");
- e("name-b").innerHTML = dfl(ls.rdsb_name_b, "Vis");
- e("logo-a").src = dfl(ls.rdsb_logo_a, "logos/black.png");
- e("logo-b").src = dfl(ls.rdsb_logo_b, "logos/white.png");
- e("score-a").innerHTML = dfl(ls.rdsb_score_a, 0);
- e("score-b").innerHTML = dfl(ls.rdsb_score_b, 0);
- e("timeouts-a").innerHTML = dfl(ls.rdsb_timeout_a, 3);
- e("timeouts-b").innerHTML = dfl(ls.rdsb_timeout_b, 3);
- period = Number(ls.rdsb_period) || 0;
- if (localStorage) {
+ // IE8 doesn't have localStorage for file:// URLs :<
+ e("name-a").innerHTML = get("name_a", "Home");
+ e("name-b").innerHTML = get("name_b", "Vis");
+ e("logo-a").src = get("logo_a", "logos/black.png");
+ e("logo-b").src = get("logo_b", "logos/white.png");
+ e("score-a").innerHTML = get("score_a", 0);
+ e("score-b").innerHTML = get("score_b", 0);
+ e("timeouts-a").innerHTML = get("timeout_a", 3);
+ e("timeouts-b").innerHTML = get("timeout_b", 3);
+ period = Number(get("period", 0));
+ jamno = Number(get("jamno", 0));
+
+ if (window.localStorage) {
save_itimer = setInterval(save, 1000);
}
@@ -492,7 +515,7 @@ function start() {
e("jamtext").innerHTML = jamtext[3];
transition();
- c = Number(ls.rdsb_period_clock || 1800000);
+ c = Number(get("period_clock", 1800000));
startTimer(p);
p.set(c);
@@ -503,7 +526,6 @@ function start() {
save_timer = setInterval(save, 1000);
update_itimer = setInterval(update, 33);
- resize();
}
function resize() {