From afff6a5a1b25729f6be3f3b565d61ff3e56d9c36 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Wed, 13 Jun 2018 12:53:21 +0100 Subject: Add JavaScript linting --- static/js/countdown.js | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'static/js/countdown.js') diff --git a/static/js/countdown.js b/static/js/countdown.js index be4a11c9..8ba2e58d 100644 --- a/static/js/countdown.js +++ b/static/js/countdown.js @@ -1,16 +1,16 @@ "use strict"; -(function(){ // Use a closure to avoid polluting global scope +(function(){ // Use a closure to avoid polluting global scope const startjam = new Date(Date.UTC(2018, 2, 23)); const endjam = new Date(Date.UTC(2018, 2, 26)); - let now = Date.now(); + 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 + if (now + 1000 < endjam.getTime()) { // Only do anything if the jam hasn't ended + UIkit.notification( // Spawn the notification { - message: "" + "message": "" + "
" + " " + " Code Jam Countdown" @@ -18,14 +18,14 @@ + "

...

" + "(Tap/click to dismiss)" + "
", - pos: "bottom-right", - timeout: endjam - now + "pos": "bottom-right", + "timeout": endjam - now } ); const heading = document.getElementById("countdown-title"); - if (now > startjam.getTime()) { // Jam's already started + if (now > startjam.getTime()) { // Jam's already started heading.innerHTML = "Current code jam ends in..."; goal = endjam.getTime(); } else { @@ -33,46 +33,46 @@ goal = startjam.getTime(); } - let refreshCountdown = setInterval(function() { // Create a repeating task - let delta = goal - Date.now(); // Time until the goal is met + 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 + 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 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 hours = Math.floor(delta / (60 * 60 * 1000)); + delta -= hours * (60 * 60 * 1000); - let minutes = Math.floor(delta / (60*1000)); - delta -= minutes * (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; + days = `0${days}`; } if (hours < 10) { - hours = "0"+hours; + hours = `0${hours}`; } if (minutes < 10) { - minutes = "0"+minutes; + minutes = `0${minutes}`; } if (seconds < 10) { - seconds = "0"+seconds; + seconds = `0${seconds}`; } try { - document.getElementById('countdown-remaining').innerHTML = `${days}:${hours}:${minutes}:${seconds}`; - } catch (e) { // Notification was probably closed, so we can stop counting + document.getElementById("countdown-remaining").innerHTML = `${days}:${hours}:${minutes}:${seconds}`; + } catch (e) { // Notification was probably closed, so we can stop counting return clearInterval(refreshCountdown); } }, 500); } -}()); +})(); -- cgit v1.2.3