From 91a548285cca3e1eac5947ac6101ad5c4c56b391 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Thu, 30 Apr 2015 13:07:38 +0200 Subject: Countdown in closed-View --- assets/js/lustiges-script.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'assets/js/lustiges-script.js') diff --git a/assets/js/lustiges-script.js b/assets/js/lustiges-script.js index e886134..7ec3c6f 100644 --- a/assets/js/lustiges-script.js +++ b/assets/js/lustiges-script.js @@ -539,3 +539,23 @@ $(function() { $(this).select(); }); }); + +// closed-countdown +$(function() { + var + $el = $('.closed .countdown'), + dt = moment($el.data('dt')); + + $el.attr('title', 'on '+dt.format('dddd, MMM Do YYYY')) + function update() { + setTimeout(update, 5000); + + var now = moment('2015-03-31'); + + if(dt.dayOfYear() == now.dayOfYear() && dt.year() == now.year()) + $el.text('today'); + else + $el.text( dt.from(now) ); + } + update(); +}); -- cgit v1.2.3