From 7fed15b0fdbc32500cd601be5de275e6ee5abb20 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sun, 26 Mar 2017 18:37:53 +0200 Subject: Add countdown.js. --- js/app/counter.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 js/app/counter.js (limited to 'js/app') diff --git a/js/app/counter.js b/js/app/counter.js new file mode 100644 index 0000000..dad6ec4 --- /dev/null +++ b/js/app/counter.js @@ -0,0 +1,24 @@ +(function() { + // UTC milliseconds since 1970 + // Example conversion: date --date 2017-05-16T17:00Z+2 +%s000 + var SHOWTIME = new Date(1494946800000), + DEMO_PAST = 'Last FREE Live Webinar began', + DEMO_CURRENT = 'FREE Live Webinar began', + DEMO_FUTURE = 'Next FREE Live Webinar begins'; + + function update() { + var ts = countdown(SHOWTIME, null); + + var counter = document.getElementById('counter'), + msg = ts.toHTML('strong', null); + + msg = (ts.value > 0) ? + DEMO_PAST+' '+msg+' ago!' : + DEMO_FUTURE+' in '+msg+'!'; + + counter.innerHTML = msg; + + requestAnimationFrame(update, counter.parentNode); + } + update(); +})(); -- cgit v1.2.3