Fix for IE7, yay!

This commit is contained in:
Neale Pickett 2012-07-16 22:51:42 -06:00
parent ef75ef8b98
commit e0da7925c4
3 changed files with 44 additions and 23 deletions

View File

@ -149,7 +149,6 @@ img, p {
bottom: 0; bottom: 0;
} }
</style> </style>
<script type="text/javascript" src="logos/logos.js"></script> <script type="text/javascript" src="logos/logos.js"></script>
<script type="text/javascript" src="res/scoreboard.js"></script> <script type="text/javascript" src="res/scoreboard.js"></script>
@ -192,7 +191,7 @@ tenths = false;
<span id="jamtext" onclick="handle(event);"></span> <span id="jamtext" onclick="handle(event);"></span>
<span id="jamno" onclick="handle(event);">0</span> <span id="jamno" onclick="handle(event);">0</span>
</p> </p>
<p class="timer button"><span id="jam" onclick="handle(event);">-:--.-</span></p> <p class="timer button"><span id="jam" onclick="handle(event);">-:--</span></p>
</div> </div>
</div> </div>

View File

@ -70,6 +70,7 @@ body {
/* Jammer indicators */ /* Jammer indicators */
#jammer-a, #jammer-b { #jammer-a, #jammer-b {
font-family: monospace;
position: absolute; position: absolute;
bottom: 0em; bottom: 0em;
color: #444; color: #444;
@ -144,8 +145,7 @@ body {
position: absolute; position: absolute;
font-size: 50%; font-size: 50%;
bottom: 2.2em; bottom: 2.2em;
left: 50%; right: 30%;
margin-left: 3em;
} }

View File

@ -432,16 +432,20 @@ function key(event) {
transition(newstate); transition(newstate);
} }
function dfl(v, d) { function get(k, d) {
if (v == undefined) { if (! window.localStorage) {
return d; return d;
} else { } else {
var v = window.localStorage["rdsb_" + k];
if (v == undefined) {
return d;
}
return v; return v;
} }
} }
function store(k, v) { function store(k, v) {
if ((v == undefined) || ! localStorage) { if ((v == undefined) || ! window.localStorage) {
return; return;
} else { } else {
localStorage["rdsb_" + k] = v; localStorage["rdsb_" + k] = v;
@ -449,8 +453,6 @@ function store(k, v) {
} }
function save() { function save() {
var ls = localStorage || {};
store("period_clock", e("period").remaining()); store("period_clock", e("period").remaining());
store("name_a", e("name-a").innerHTML); store("name_a", e("name-a").innerHTML);
store("name_b", e("name-b").innerHTML); store("name_b", e("name-b").innerHTML);
@ -460,27 +462,48 @@ function save() {
store("score_b", e("score-b").innerHTML); store("score_b", e("score-b").innerHTML);
store("timeout_a", e("timeouts-a").innerHTML); store("timeout_a", e("timeouts-a").innerHTML);
store("timeout_b", e("timeouts-b").innerHTML); store("timeout_b", e("timeouts-b").innerHTML);
store("jamno", jamno);
store("period", period); 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() { function start() {
resize();
iecheck();
var p = document.getElementById("period"); var p = document.getElementById("period");
var j = document.getElementById("jam"); var j = document.getElementById("jam");
var ls = localStorage || {};
var c; 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); save_itimer = setInterval(save, 1000);
} }
@ -492,7 +515,7 @@ function start() {
e("jamtext").innerHTML = jamtext[3]; e("jamtext").innerHTML = jamtext[3];
transition(); transition();
c = Number(ls.rdsb_period_clock || 1800000); c = Number(get("period_clock", 1800000));
startTimer(p); startTimer(p);
p.set(c); p.set(c);
@ -503,7 +526,6 @@ function start() {
save_timer = setInterval(save, 1000); save_timer = setInterval(save, 1000);
update_itimer = setInterval(update, 33); update_itimer = setInterval(update, 33);
resize();
} }
function resize() { function resize() {