|
|
@ -13,14 +13,14 @@
|
|
|
|
<div id="clock"></div>
|
|
|
|
<div id="clock"></div>
|
|
|
|
<div><input type="number" id="delay" value="10" min="0" /> seconds of delay</div>
|
|
|
|
<div><input type="number" id="delay" value="10" min="0" /> seconds of delay</div>
|
|
|
|
<script type="text/javascript">
|
|
|
|
<script type="text/javascript">
|
|
|
|
const BUS_START_TIME = 1605290400;
|
|
|
|
let busStartTime = null;
|
|
|
|
|
|
|
|
|
|
|
|
let updateClock = () => {
|
|
|
|
function updateClock() {
|
|
|
|
let delay = parseInt(document.getElementById("delay").value);
|
|
|
|
let delay = parseInt(document.getElementById("delay").value);
|
|
|
|
if (isNaN(delay)) {
|
|
|
|
if (isNaN(delay)) {
|
|
|
|
delay = 0;
|
|
|
|
delay = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let time = new Date().getTime() / 1000 - delay - BUS_START_TIME;
|
|
|
|
let time = (new Date() - busStartTime) / 1000 - delay;
|
|
|
|
|
|
|
|
|
|
|
|
let sign = "";
|
|
|
|
let sign = "";
|
|
|
|
if (time < 0) {
|
|
|
|
if (time < 0) {
|
|
|
@ -40,9 +40,17 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let formatted = sign + hours + ":" + mins + ":" + secs;
|
|
|
|
let formatted = sign + hours + ":" + mins + ":" + secs;
|
|
|
|
document.getElementById("clock").innerText = formatted;
|
|
|
|
document.getElementById("clock").innerText = formatted;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function initialize() {
|
|
|
|
|
|
|
|
const dataResponse = await fetch("/thrimshim/defaults");
|
|
|
|
|
|
|
|
const data = await dataResponse.json();
|
|
|
|
|
|
|
|
busStartTime = new Date(data.bustime_start);
|
|
|
|
|
|
|
|
|
|
|
|
setInterval(updateClock, 1000);
|
|
|
|
setInterval(updateClock, 1000);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initialize();
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
</html>
|
|
|
|