From 88dfb2e3a8d3c3ef5fb9007e72491baeb7f6373f Mon Sep 17 00:00:00 2001 From: Felix Favre Date: Sun, 24 Aug 2014 16:44:36 +0200 Subject: Countdown implementation --- public/js/moment-countdown.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/public/js/moment-countdown.js b/public/js/moment-countdown.js index e69de29b..999cfcf5 100644 --- a/public/js/moment-countdown.js +++ b/public/js/moment-countdown.js @@ -0,0 +1,11 @@ +$(document).ready(function() { + $.each($('.moment-countdown'), function(i, e) { + var span = $(e); + var text = span.html(); + var timestamp = moment(parseInt(span.attr("data-timestamp") * 1000)); + span.html(text.replace("%c", timestamp.fromNow())); + setInterval(function() { + span.html(text.replace("%c", timestamp.fromNow())); + }, 1000); + }); +}); \ No newline at end of file -- cgit v1.2.3-70-g09d2