moth/www/projector.html

74 lines
1.5 KiB
HTML
Raw Normal View History

2015-06-04 00:02:51 -06:00
<!DOCTYPE html>
<html>
<head>
<title>Scoreboard</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script src="scoreboard.js" async></script>
<style>
body, html {
width: 100%;
height: 100%;
overflow: hidden;
cursor: none;
}
iframe {
width: 100%;
height: 100%;
border: none;
margin: 0;
padding: 0;
}
</style>
<script>
2015-06-04 07:05:20 -06:00
var SECS = 1000, DELAY = 30*SECS;
var urls = ["scoreboard.html"];
2015-06-04 00:02:51 -06:00
var stack = [];
var i = 0;
var xmlhttp;
if (window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
}
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
2015-06-04 07:05:20 -06:00
// update urls
urls = JSON.parse(xmlhttp.responseText);
2015-06-04 07:05:20 -06:00
console.log("new urls:", urls);
}
}
2015-06-04 07:05:20 -06:00
xmlhttp.open("GET", "projections.json", true);
xmlhttp.send();
2015-06-04 00:02:51 -06:00
function reload() {
// alternate between scoreboard and other things
if (i%2){
url = urls[0];
}
else {
if (stack.length === 0){
xmlhttp.open("GET", "projections.json", true);
xmlhttp.send();
if (urls.length > 1){
stack = urls.slice(1);
}
else {
stack = urls;
}
2015-06-04 00:02:51 -06:00
}
url = stack.pop();
2015-06-04 07:05:20 -06:00
console.log("loading " + url + " of " + urls);
2015-06-04 00:02:51 -06:00
}
document.getElementById("reloader").src = url;
i++;
2015-06-04 00:02:51 -06:00
}
function init() {
2015-06-04 07:05:20 -06:00
setInterval(reload, DELAY);
2015-06-04 00:02:51 -06:00
}
window.addEventListener("load", init);
</script>
</head>
<body>
<iframe id="reloader" src="scoreboard.html"></iframe>
</body>
</html>