Handle jammer penalties differently

This commit is contained in:
Neale Pickett 2012-03-22 13:52:12 -05:00
parent 07ae62c1dd
commit 8c4a8f3a3a
1 changed files with 65 additions and 15 deletions

View File

@ -2,20 +2,27 @@
<html> <html>
<head> <head>
<title>LADD Penalty Timer</title> <title>LADD Penalty Timer</title>
<meta name="viewport" content="width=device-width">
<style type="text/css"> <style type="text/css">
body { body {
background: black; background: url(bg.jpg) #222;
color: white; background-size: 100% auto;
color: #eee;
text-align: center; text-align: center;
} }
p { table {
width: 40%; margin: auto auto;
display: inline-block; }
td {
font-size: 200%;
border: solid #444 2px; border: solid #444 2px;
border-radius: 15px; border-radius: 15px;
margin: 1em; margin: 1em;
padding: 1em; padding: 1em;
} }
.jammer td {
border-color: #aa0;
}
.expired { .expired {
background: #080; background: #080;
} }
@ -133,9 +140,29 @@ function startTimer(element, tenths, callback) {
function clicky(event) { function clicky(event) {
var tgt = event.target || window.event.srcElement; var tgt = event.target || window.event.srcElement;
var rem = tgt.remaining();
var orem = (tgt.other?tgt.other.remaining():null);
tgt.set((tgt.remaining() + 60000) % (60000*8)); if (tgt.other && (orem > 0)) {
tgt.start(); // If jammer B gets a penalty when jammer A is in the box,
// deduct a minute from A. If the result is negative, A
// gets out and B serves the absolute value: this works
// out to be the amount of time under a minute A served.
orem -= 60000;
if (orem < 0) {
tgt.set(-orem);
tgt.start();
tgt.other.set(0);
tgt.other.stop();
} else {
tgt.other.set(orem);
tgt.other.start();
}
} else {
tgt.set((rem + 60000) % (60000*8));
tgt.start();
}
} }
var timers = []; var timers = [];
@ -166,14 +193,29 @@ function pause(event) {
function start() { function start() {
var t = document.getElementById("timers"); var t = document.getElementById("timers");
for (var i = 0; i < 8; i += 1) { for (var j = 0; j < 4; j += 1) {
var e = document.createElement("p"); var r = document.createElement("tr");
startTimer(e, true); for (var i = 0; i < 2; i += 1) {
e.set(0); var d = document.createElement("td");
e.onclick = clicky;
t.appendChild(e); startTimer(d, true);
timers.push(e); d.set(0);
d.onclick = clicky;
r.appendChild(d);
timers.push(d);
}
if (j == 0) {
// Jammers are speshul
var a = r.children[0];
var b = r.children[1];
a.other = b;
b.other = a;
r.className = "jammer";
}
t.appendChild(r);
} }
update_itimer = setInterval(update, 33); update_itimer = setInterval(update, 33);
} }
@ -182,7 +224,15 @@ window.onload = start;
</script> </script>
</head> </head>
<body> <body>
<div id="timers"></div> <table id="timers">
</table>
<input type="button" value="Pause" onclick="pause(event)"> <input type="button" value="Pause" onclick="pause(event)">
<ul>
<li>Tap a timer once per penalty</li>
<li>Top timers are for jammers and behave differently</li>
<li>Reload page to reset all timers to 0:00</li>
<li>WFTDA rules are unclear on how the penalty timer handles no-jammer jams.
You'll need to work it out with the refs.</li>
</ul>
</body> </body>
</html> </html>