Make the clock page prettier (as in, with the prettier tool, not UI)

pull/237/head
ElementalAlchemist 3 years ago committed by Mike Lang
parent 3fe2848e60
commit a0d2dc99e1

@ -1,50 +1,48 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>Stream Time</title> <title>Stream Time</title>
<style type="text/css"> <style type="text/css">
#clock { #clock {
margin-bottom: 3px; margin-bottom: 3px;
}
</style>
</head>
<body>
<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 updateClock = () => {
let delay = parseInt(document.getElementById("delay").value);
if (isNaN(delay)) {
delay = 0;
} }
let time = (new Date().getTime()) / 1000 - delay - BUS_START_TIME; </style>
</head>
<body>
<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 sign = ""; let updateClock = () => {
if (time < 0) { let delay = parseInt(document.getElementById("delay").value);
time = -time if (isNaN(delay)) {
sign = "-"; delay = 0;
} }
let time = new Date().getTime() / 1000 - delay - BUS_START_TIME;
let hours = Math.trunc(time / 3600).toString(); let sign = "";
let mins = Math.trunc((time % 3600) / 60).toString(); if (time < 0) {
let secs = Math.trunc(time % 60).toString(); time = -time;
sign = "-";
}
if (mins.length < 2) { let hours = Math.trunc(time / 3600).toString();
mins = "0" + mins; let mins = Math.trunc((time % 3600) / 60).toString();
} let secs = Math.trunc(time % 60).toString();
if (secs.length < 2) {
secs = "0" + secs; if (mins.length < 2) {
} mins = "0" + mins;
let formatted = sign + hours + ":" + mins + ":" + secs; }
document.getElementById("clock").innerText = formatted; if (secs.length < 2) {
}; secs = "0" + secs;
}
let formatted = sign + hours + ":" + mins + ":" + secs;
document.getElementById("clock").innerText = formatted;
};
setInterval(updateClock, 1000); setInterval(updateClock, 1000);
</script> </script>
</body> </body>
</html> </html>

Loading…
Cancel
Save