2015-10-18 22:16:45 -04:00
|
|
|
var time = {
|
|
|
|
timeFormat: config.time.timeFormat || 24,
|
|
|
|
dateLocation: '.date',
|
2016-01-25 23:15:01 +01:00
|
|
|
timeLocation: '#time',
|
|
|
|
updateInterval: 10000,
|
2015-10-18 22:16:45 -04:00
|
|
|
intervalId: null
|
|
|
|
};
|
|
|
|
|
2015-10-23 17:02:03 -04:00
|
|
|
/**
|
|
|
|
* Updates the time that is shown on the screen
|
|
|
|
*/
|
2015-10-18 22:16:45 -04:00
|
|
|
time.updateTime = function () {
|
2016-01-25 23:57:28 +01:00
|
|
|
var timeLocation = this.timeLocation;
|
|
|
|
var _now = moment();
|
|
|
|
var _date = _now.format('[<span class="dayname">]dddd,[</span> <span class="longdate">]LL[</span>]');
|
2016-01-25 23:15:01 +01:00
|
|
|
|
|
|
|
$(this.dateLocation).updateWithText(_date, 1000);
|
|
|
|
$('.fade').removeClass('fade')
|
2016-01-25 23:57:28 +01:00
|
|
|
var diff = $('<div>').html(_now.format(this._timeFormat+':mm').replace(/./g, "<span>$&</span>"));
|
|
|
|
diff.children().each(function( index ) {
|
2016-01-25 23:15:01 +01:00
|
|
|
var _text = $( this ).text();
|
|
|
|
var _i = index+1;
|
2016-01-25 23:57:28 +01:00
|
|
|
var _text2 = $(timeLocation + ' span:nth-child('+_i+')').text();
|
2016-01-25 23:15:01 +01:00
|
|
|
if (_text != _text2) {
|
2016-01-25 23:57:28 +01:00
|
|
|
$(timeLocation +' span:nth-child('+_i+')').addClass('fade');
|
2016-01-25 23:15:01 +01:00
|
|
|
$(this).addClass('fade');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$('.fade').fadeTo(400, 0.25, function() {
|
2016-01-25 23:57:28 +01:00
|
|
|
$(timeLocation).html(diff.html());
|
|
|
|
$(timeLocation).children().fadeTo(400, 1).removeClass('fade');
|
|
|
|
}).bind(this);
|
2015-10-18 22:16:45 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
time.init = function () {
|
|
|
|
|
|
|
|
if (parseInt(time.timeFormat) === 12) {
|
|
|
|
time._timeFormat = 'hh'
|
|
|
|
} else {
|
|
|
|
time._timeFormat = 'HH';
|
|
|
|
}
|
2016-01-25 23:57:28 +01:00
|
|
|
$(this.timeLocation).html('<span class="fade"></span>');
|
2015-10-18 22:16:45 -04:00
|
|
|
|
|
|
|
this.intervalId = setInterval(function () {
|
|
|
|
this.updateTime();
|
|
|
|
}.bind(this), 1000);
|
|
|
|
|
|
|
|
}
|