mirror of https://github.com/dirtbags/moth.git
Changed points restore output to Neale's stupid space delimited format. Added url param 'snapshot' to specify a points snapshot to restore (0-19). Changed points log storage to an array of the 20 most recent points logs.
This commit is contained in:
parent
ca365e729f
commit
e10e4a539b
2
install
2
install
|
@ -45,7 +45,7 @@ setup() {
|
|||
|
||||
|
||||
echo "Figuring out web user..."
|
||||
for www in www-data http tc _; do
|
||||
for www in www-data http tc _ _www; do
|
||||
id $www && break
|
||||
done
|
||||
if [ $www = _ ]; then
|
||||
|
|
|
@ -1,22 +1,31 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Scoreboard</title>
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
<script src="scoreboard.js" async></script>
|
||||
<title>Points History</title>
|
||||
<script>
|
||||
function init() {
|
||||
var pointslog = JSON.parse(localStorage.getItem("points"));
|
||||
for (point in points){
|
||||
console.log(point);
|
||||
|
||||
function getParameterByName(name) {
|
||||
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
|
||||
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
|
||||
results = regex.exec(location.search);
|
||||
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
|
||||
}
|
||||
|
||||
var pointsDiv = document.getElementById("pointslog");
|
||||
var pointshistory = JSON.parse(localStorage.getItem("pointshistory"));
|
||||
// get snapshot specified by query param or else most recent snapshot
|
||||
var i = parseInt(getParameterByName("snapshot")) || pointshistory.length-1;
|
||||
var snapshot = pointshistory[i];
|
||||
pointsDiv.innerHTML = snapshot.map(function(entry){
|
||||
return entry.join(" ");
|
||||
}).join("<br>");
|
||||
}
|
||||
|
||||
window.addEventListener("load", init);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Scoreboard</h1>
|
||||
<div id="scoreboard"></div>
|
||||
<div id="pointslog"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -13,6 +13,12 @@ function scoreboard(element, continuous) {
|
|||
function update(state) {
|
||||
var teamnames = state["teams"];
|
||||
var pointslog = state["points"];
|
||||
var pointshistory = JSON.parse(localStorage.getItem("pointshistory")) || [];
|
||||
if (pointshistory.length >= 20){
|
||||
pointshistory.shift();
|
||||
}
|
||||
pointshistory.push(pointslog);
|
||||
localStorage.setItem("pointshistory", JSON.stringify(pointshistory));
|
||||
var highscore = {};
|
||||
var teams = {};
|
||||
|
||||
|
|
Loading…
Reference in New Issue