mirror of https://github.com/dirtbags/moth.git
Added ajax request to projections.json for hot swapping projector rotation
This commit is contained in:
parent
b26ce03f8c
commit
33efccf344
|
@ -0,0 +1,5 @@
|
|||
[
|
||||
"scoreboard.html",
|
||||
"tanks.html",
|
||||
"credits.html"
|
||||
]
|
|
@ -20,10 +20,20 @@
|
|||
}
|
||||
</style>
|
||||
<script>
|
||||
var urls = ["scoreboard.html", "credits.html", "tanks.html"];
|
||||
var SECS = 1000;
|
||||
var urls = ["scoreboard.html"];
|
||||
var stack = [];
|
||||
var secs = 1000;
|
||||
var i = 0;
|
||||
var xmlhttp;
|
||||
if (window.XMLHttpRequest){
|
||||
xmlhttp = new XMLHttpRequest();
|
||||
}
|
||||
xmlhttp.onreadystatechange = function(){
|
||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
|
||||
urls = JSON.parse(xmlhttp.responseText);
|
||||
//console.log("new urls:", urls);
|
||||
}
|
||||
}
|
||||
function reload() {
|
||||
// alternate between scoreboard and other things
|
||||
if (i%2){
|
||||
|
@ -31,15 +41,24 @@ function reload() {
|
|||
}
|
||||
else {
|
||||
if (stack.length === 0){
|
||||
stack = urls.slice(1);
|
||||
xmlhttp.open("GET", "projections.json", true);
|
||||
xmlhttp.send();
|
||||
if (urls.length > 1){
|
||||
stack = urls.slice(1);
|
||||
}
|
||||
else {
|
||||
stack = urls;
|
||||
}
|
||||
}
|
||||
url = stack.pop();
|
||||
}
|
||||
console.log("loading " + url + " of " + urls);
|
||||
document.getElementById("reloader").src = url;
|
||||
i++;
|
||||
}
|
||||
|
||||
function init() {
|
||||
setInterval(reload, 60*secs);
|
||||
setInterval(reload, 2*SECS);
|
||||
}
|
||||
|
||||
window.addEventListener("load", init);
|
||||
|
|
Loading…
Reference in New Issue