Make the Thrimbletrimmer clock use Wubloader's bus time start setting

pull/237/head
ElementalAlchemist 3 years ago committed by Mike Lang
parent 497c7625dc
commit cf6652d3ad

@ -13,14 +13,14 @@
<div id="clock"></div>
<div><input type="number" id="delay" value="10" min="0" /> seconds of delay</div>
<script type="text/javascript">
const BUS_START_TIME = 1605290400;
let busStartTime = null;
let updateClock = () => {
function updateClock() {
let delay = parseInt(document.getElementById("delay").value);
if (isNaN(delay)) {
delay = 0;
}
let time = new Date().getTime() / 1000 - delay - BUS_START_TIME;
let time = (new Date() - busStartTime) / 1000 - delay;
let sign = "";
if (time < 0) {
@ -40,9 +40,17 @@
}
let formatted = sign + hours + ":" + mins + ":" + secs;
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>
</body>
</html>

Loading…
Cancel
Save