about summary refs log tree commit diff
path: root/public/clock.js
diff options
context:
space:
mode:
authorChronister <andrewlchronister@gmail.com>2017-05-29 00:09:12 +0000
committerbeatrix-bitrot <beatrix.bitrot@gmail.com>2017-06-23 21:45:14 +0000
commit65528fc54e2943aa259ec9129781d3fb1161ec63 (patch)
tree53b63cac8e8cdc66c1479a639a62348cd48560fd /public/clock.js
parent382572c2132b797719555e7591853c045a1ff216 (diff)
All cybrespace changes through 5/28
Diffstat (limited to 'public/clock.js')
-rw-r--r--public/clock.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/public/clock.js b/public/clock.js
new file mode 100644
index 000000000..63cee1e1b
--- /dev/null
+++ b/public/clock.js
@@ -0,0 +1,22 @@
+document.addEventListener("DOMContentLoaded", function(event) { 
+  updateClock();
+  setInterval(updateClock, 1000);
+});
+
+function updateClock() {
+    var clock = document.querySelector(".closed-registrations-message .clock");
+    var now = new Date();
+    var open = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate());
+    var ts = open.setUTCHours(19);
+    if (open - now < 0) {
+      open = new Date(ts + 24*60*60*1000);
+    }
+    var until = open - now;
+    var ms = until % 1000;
+    var s =  Math.floor((until / 1000)) % 60;
+    var m =  Math.floor((until / 1000 / 60)) % 60;
+    var h =  Math.floor((until / 1000 / 60 / 60));
+    if (m < 10) m = "0" + m;
+    if (s < 10) s = "0" + s;
+    clock.innerHTML = h + ":" + m + ":" + s;
+}