diff options
author | 2018-08-22 19:59:51 +0200 | |
---|---|---|
committer | 2018-08-22 19:59:51 +0200 | |
commit | 8ef1cd50a0bf34adc3033706a2eeadd4339daa67 (patch) | |
tree | 8885bc6035dbf664cff573fba56822cec6f3128d /js/src/countdown.js | |
parent | Use `postgres` service on CI. (diff) |
Remove unused files.
Diffstat (limited to 'js/src/countdown.js')
-rw-r--r-- | js/src/countdown.js | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/js/src/countdown.js b/js/src/countdown.js deleted file mode 100644 index 7eaa650c..00000000 --- a/js/src/countdown.js +++ /dev/null @@ -1,79 +0,0 @@ -"use strict"; - -(function(){ // Use a closure to avoid polluting global scope - // TODO: This needs to be built into the jams system - const startjam = new Date(Date.UTC(2018, 2, 23)); - const endjam = new Date(Date.UTC(2018, 2, 26)); - - const now = Date.now(); - let goal; - - if (now + 1000 < endjam.getTime()) { // Only do anything if the jam hasn't ended - UIkit.notification( // Spawn the notification - { - "message": "" - + "<div class='uk-text-center'>" - + " <span id=\"countdown-title\" class=\"uk-text-center\">" - + " <a href=\"/info/jams\">Code Jam</a> Countdown" - + " </span>" - + " <p class='uk-text-large' id=\"countdown-remaining\">...</p>" - + "<small style='font-size: 0.6em;'>(Tap/click to dismiss)</small>" - + "</div>", - "pos": "bottom-right", - "timeout": endjam - now - } - ); - - const heading = document.getElementById("countdown-title"); - - if (now > startjam.getTime()) { // Jam's already started - heading.innerHTML = "Current <a href=\"/info/jams\">code jam</a> ends in..."; - goal = endjam.getTime(); - } else { - heading.innerHTML = "Next <a href=\"/info/jams\">code jam</a> starts in..."; - goal = startjam.getTime(); - } - - const refreshCountdown = setInterval(() => { // Create a repeating task - let delta = goal - Date.now(); // Time until the goal is met - - if (delta <= 1000) { // Goal has been met, best reload - clearInterval(refreshCountdown); - return location.reload(); - } - - let days = Math.floor(delta / (24 * 60 * 60 * 1000)); - delta -= days * (24 * 60 * 60 * 1000); - - let hours = Math.floor(delta / (60 * 60 * 1000)); - delta -= hours * (60 * 60 * 1000); - - let minutes = Math.floor(delta / (60 * 1000)); - delta -= minutes * (60 * 1000); - - let seconds = Math.floor(delta / 1000); - - if (days < 10) { - days = `0${days}`; - } - - if (hours < 10) { - hours = `0${hours}`; - } - - if (minutes < 10) { - minutes = `0${minutes}`; - } - - if (seconds < 10) { - seconds = `0${seconds}`; - } - - try { - document.getElementById("countdown-remaining").innerHTML = `${days}:${hours}:${minutes}:${seconds}`; - } catch (e) { // Notification was probably closed, so we can stop counting - return clearInterval(refreshCountdown); - } - }, 500); - } -})(); |