var timeInformer = (function () {
var date = null,
data = {},
informersCount = 4;
return {
initInformer: function () {
timeInformer.initDate();
for (var i = 0; i < informersCount; i++) {
timeInformer.initElements(data[i].GMT, i);
}
},
setData: function(response) {
data = response;
},
initDate: function () {
date = moment(new Date()).utc();
},
update: function () {
date = moment(new Date()).utc();
for (var i = 0; i < informersCount; i++) {
timeInformer.updateElements(data[i].GMT, i);
}
},
initElements: function (gmt, i) {
$('#timeInformer' + (i + 1) + ' .city').html(data[i].Title);
$('#timeInformer' + (i + 1) + ' .city-time').html(date.add(gmt, 'h').format('HH:mm:ss'));
date.add(-(gmt), 'h');
},
updateElements: function (gmt, i) {
$('#timeInformer' + (i + 1) + ' .city-time').html(date.add(gmt, 'h').format('HH:mm:ss'));
date.add(-(gmt), 'h');
}
}
})();