about summary refs log tree commit diff
path: root/public
diff options
context:
space:
mode:
authorChronister <andrewlchronister@gmail.com>2017-06-14 22:25:10 +0000
committerbeatrix-bitrot <beatrix.bitrot@gmail.com>2017-06-23 21:45:14 +0000
commit39b6b37b74a9aeecc35d4a68fb1d0bf058350dbd (patch)
tree2c8616207e8100881c1878e992d8a91a45ef84f0 /public
parent65528fc54e2943aa259ec9129781d3fb1161ec63 (diff)
cybrespace to 1.4.2
Diffstat (limited to 'public')
-rw-r--r--public/clock.js40
-rw-r--r--public/riot-glitch.pngbin0 -> 24926 bytes
2 files changed, 36 insertions, 4 deletions
diff --git a/public/clock.js b/public/clock.js
index 63cee1e1b..ffb9beae8 100644
--- a/public/clock.js
+++ b/public/clock.js
@@ -3,14 +3,46 @@ document.addEventListener("DOMContentLoaded", function(event) {
   setInterval(updateClock, 1000);
 });
 
+function getNextOpen(now) {
+    var days = [[0, 14], [4, 18], [8, 22], [12], [2, 16], [6, 20], [10]]
+    var nowday = now.getUTCDay();
+    var nour = now.getUTCHours();
+
+    var open_hour = -1;
+    var d = 0;
+
+    while (open_hour == -1) {
+        var times = days[(nowday + d) % 7];
+        for (var i = 0; i < times.length; ++i) {
+            var time = times[i];
+            if (time == nour) {
+                return "refresh";
+            } else if (time > nour || d > 0) {
+                open_hour = time;
+                break;
+            }
+        }
+        if (open_hour == -1) {
+            d += 1;
+            nour = -1;
+        }
+    }
+
+    var open = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() + d));
+    var ts = open.setUTCHours(open_hour);
+    return open;
+}
+
 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 open = getNextOpen(now);
+
+    if (open == "refresh") {
+        location.reload();
+        return;
     }
+
     var until = open - now;
     var ms = until % 1000;
     var s =  Math.floor((until / 1000)) % 60;
diff --git a/public/riot-glitch.png b/public/riot-glitch.png
new file mode 100644
index 000000000..1c97ce5f1
--- /dev/null
+++ b/public/riot-glitch.png
Binary files differ