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>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
var urls = ["scoreboard.html", "credits.html", "tanks.html"];
|
var SECS = 1000;
|
||||||
|
var urls = ["scoreboard.html"];
|
||||||
var stack = [];
|
var stack = [];
|
||||||
var secs = 1000;
|
|
||||||
var i = 0;
|
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() {
|
function reload() {
|
||||||
// alternate between scoreboard and other things
|
// alternate between scoreboard and other things
|
||||||
if (i%2){
|
if (i%2){
|
||||||
|
@ -31,15 +41,24 @@ function reload() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (stack.length === 0){
|
if (stack.length === 0){
|
||||||
|
xmlhttp.open("GET", "projections.json", true);
|
||||||
|
xmlhttp.send();
|
||||||
|
if (urls.length > 1){
|
||||||
stack = urls.slice(1);
|
stack = urls.slice(1);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
stack = urls;
|
||||||
|
}
|
||||||
|
}
|
||||||
url = stack.pop();
|
url = stack.pop();
|
||||||
}
|
}
|
||||||
|
console.log("loading " + url + " of " + urls);
|
||||||
document.getElementById("reloader").src = url;
|
document.getElementById("reloader").src = url;
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
setInterval(reload, 60*secs);
|
setInterval(reload, 2*SECS);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener("load", init);
|
window.addEventListener("load", init);
|
||||||
|
|
Loading…
Reference in New Issue