summaryrefslogtreecommitdiff
path: root/js/app
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2017-03-26 18:37:53 +0200
committerJonas Smedegaard <dr@jones.dk>2017-03-26 18:37:53 +0200
commit7fed15b0fdbc32500cd601be5de275e6ee5abb20 (patch)
treee8b87744ebf7d3760135006573d0712a0cbf484b /js/app
parentedb317740843720c9bb979e030c12dc346b3c6a5 (diff)
Add countdown.js.
Diffstat (limited to 'js/app')
-rw-r--r--js/app/counter.js24
1 files changed, 24 insertions, 0 deletions
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();
+})();