2018-12-31 20:26:36 +11:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
2018-12-31 20:45:40 +11:00
|
|
|
<title>Virtual Metro</title>
|
2018-12-31 20:26:36 +11:00
|
|
|
<style type="text/css">
|
|
|
|
#mainsvg {
|
|
|
|
width: 100vw;
|
|
|
|
height: 100vh;
|
|
|
|
max-width: 100vw;
|
|
|
|
max-height: 100vh;
|
|
|
|
}
|
2019-01-01 02:32:17 +11:00
|
|
|
#topbar {
|
|
|
|
position: absolute;
|
|
|
|
left: 0;
|
|
|
|
top: 0;
|
|
|
|
z-index: 999;
|
|
|
|
font-size: small;
|
|
|
|
}
|
2018-12-31 20:26:36 +11:00
|
|
|
body, html {
|
2019-01-01 02:32:17 +11:00
|
|
|
color: #ccc;
|
2018-12-31 20:26:36 +11:00
|
|
|
background-color: black;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
2019-01-01 02:32:17 +11:00
|
|
|
a, a:active, a:visited {
|
|
|
|
color: #99f;
|
|
|
|
}
|
2018-12-31 20:26:36 +11:00
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/nunjucks/3.0.1/nunjucks.min.js"></script>
|
|
|
|
<script>
|
2019-01-01 02:32:17 +11:00
|
|
|
function getQueryVariable(variable, def) {
|
|
|
|
var vars = window.location.search.substring(1).split("&");
|
|
|
|
for (var i = 0; i < vars.length; i++) {
|
|
|
|
var bits = vars[i].split("=");
|
|
|
|
if (decodeURIComponent(bits[0]) == variable) {
|
|
|
|
return decodeURIComponent(bits[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
|
|
|
var stop_id = parseInt(getQueryVariable("stop_id", 1099));
|
|
|
|
var plat_id = parseInt(getQueryVariable("plat_id", 1));
|
|
|
|
|
2018-12-31 20:26:36 +11:00
|
|
|
function start() {
|
|
|
|
var svg = document.getElementById("mainsvg").getSVGDocument().querySelector("svg");
|
|
|
|
var template = svg.innerHTML;
|
|
|
|
|
2018-12-31 20:45:40 +11:00
|
|
|
svg.innerHTML = nunjucks.renderString(template, {"dest": "Loading..."});
|
2018-12-31 20:26:36 +11:00
|
|
|
|
|
|
|
function tick() {
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
xhr.addEventListener("load", function() {
|
2019-01-01 02:32:17 +11:00
|
|
|
var result = JSON.parse(xhr.responseText);
|
|
|
|
svg.innerHTML = nunjucks.renderString(template, result);
|
|
|
|
document.getElementById("stopinfo").innerText = stop_id + " (" + result.stop_name + ")";
|
2018-12-31 20:26:36 +11:00
|
|
|
});
|
2019-01-01 02:32:17 +11:00
|
|
|
xhr.open("GET", "latest?stop_id=" + stop_id + "&plat_id=" + plat_id);
|
2018-12-31 20:26:36 +11:00
|
|
|
xhr.send();
|
|
|
|
}
|
|
|
|
|
|
|
|
tick();
|
|
|
|
window.setInterval(tick, 30000);
|
|
|
|
}
|
2019-01-01 02:32:17 +11:00
|
|
|
|
|
|
|
function changePlatform() {
|
|
|
|
var new_plat = parseInt(window.prompt("Enter new platform number:", plat_id));
|
|
|
|
window.location = "?stop_id=" + stop_id + "&plat_id=" + new_plat;
|
|
|
|
return false;
|
|
|
|
}
|
2018-12-31 20:26:36 +11:00
|
|
|
</script>
|
2019-01-01 02:32:17 +11:00
|
|
|
<div id="topbar">Stop <span id="stopinfo">?</span> [change] Platform <span id="platinfo">?</span> [<a href="#" onclick="return changePlatform();">change</a>]</div>
|
2018-12-31 20:26:36 +11:00
|
|
|
<object id="mainsvg" data="static/template.svg" type="image/svg+xml" onload="start();"></object>
|
2019-01-01 02:32:17 +11:00
|
|
|
<script>
|
|
|
|
document.getElementById("stopinfo").innerText = stop_id;
|
|
|
|
document.getElementById("platinfo").innerText = plat_id;
|
|
|
|
</script>
|
2018-12-31 20:26:36 +11:00
|
|
|
</body>
|
|
|
|
</html>
|