Have cycling option for scoreboard

This commit is contained in:
Neale Pickett 2010-09-09 16:51:11 -06:00
parent fd8f53dae3
commit 7aa23aadb5
2 changed files with 24 additions and 7 deletions

View File

@ -95,7 +95,7 @@ BEGIN {
# Get team colors and names
for (team in teams) {
fn = "/var/lib/ctf/teams/colors/" team ".color"
fn = "/var/lib/ctf/teams/colors/" team
getline colors_by_team[team] < fn
close(fn)
@ -129,7 +129,7 @@ BEGIN {
# Provide raw data for the chart
print " <script type=\"application/javascript\">"
print "function draw() {"
print "function init() {"
printf(" plot(\"chart\", %d, %.2f, {\n", tslen, maxscore)
c = 0
for (team in teams) {
@ -143,8 +143,12 @@ BEGIN {
printf("]],\n");
}
print " });"
print " if (location.hash) {"
print " cycle();"
print " setInterval(cycle, 10000);"
print " }"
print "window.onload = draw;"
print "}"
print "window.onload = init;"
print " </script>"
# Set up team colors and a few page-specific styles
@ -161,7 +165,7 @@ BEGIN {
print " <body>"
print " <h1>Scoreboard</h1>"
print "<p id=\"debug\"></p>"
print " <table class=\"scoreboard\">"
print " <table id=\"scoreboard\">"
print " <tr>"
print " <th>Overall</th>"

View File

@ -105,3 +105,16 @@ function restore(cls) {
}
var state = 0;
function cycle() {
if (state == 0) {
v = document.getElementById("scoreboard");
i = document.getElementById("chart");
} else {
v = document.getElementById("chart");
i = document.getElementById("scoreboard");
}
v.style.display = "block";
i.style.display = "none";
state = (state + 1) % 2;
}