2018-05-03 17:33:49 +02:00
|
|
|
/*
|
|
|
|
* Initialize all moment countdowns on the page. A moment countdown has the
|
2018-08-11 22:16:57 +02:00
|
|
|
* class 'moment-countdown' and the attribute 'data-timestamp' which defines the
|
2018-05-03 17:33:49 +02:00
|
|
|
* countdown's time goal.
|
|
|
|
*/
|
2018-02-08 23:01:43 +01:00
|
|
|
$(document).ready(function () {
|
2018-08-11 22:16:57 +02:00
|
|
|
if (typeof moment !== 'undefined') {
|
2018-12-28 18:34:41 +01:00
|
|
|
moment.locale($('html').attr('lang'));
|
|
|
|
|
2018-08-11 22:16:57 +02:00
|
|
|
$.each($('.moment-countdown'), function (i, e) {
|
2018-02-08 23:01:43 +01:00
|
|
|
var span = $(e);
|
|
|
|
var text = span.html();
|
|
|
|
/* global moment */
|
2018-08-11 22:16:57 +02:00
|
|
|
var timestamp = moment(parseInt(span.attr('data-timestamp') * 1000));
|
|
|
|
span.html(text.replace('%c', timestamp.fromNow()));
|
2018-02-08 23:01:43 +01:00
|
|
|
setInterval(function () {
|
2018-08-11 22:16:57 +02:00
|
|
|
span.html(text.replace('%c', timestamp.fromNow()));
|
2018-02-08 23:01:43 +01:00
|
|
|
}, 1000);
|
|
|
|
});
|
|
|
|
}
|
2018-05-03 17:33:49 +02:00
|
|
|
});
|