From 3229b23cda6ae870270b6fa83d3dc1636c31b07f Mon Sep 17 00:00:00 2001 From: Jonathan Vogt Date: Fri, 29 Jan 2016 11:36:56 +0100 Subject: [PATCH] Made DigitFade optional --- js/time/time.js | 58 ++++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/js/time/time.js b/js/time/time.js index cf966ef4..5ba72d18 100644 --- a/js/time/time.js +++ b/js/time/time.js @@ -5,7 +5,7 @@ var time = { updateInterval: 1000, intervalId: undefined, displaySeconds: (typeof config.time.displaySeconds == 'undefined') ? true : config.time.displaySeconds, - + digitFade: (typeof config.time.digitFade == 'undefined') ? true : config.time.digitFade, }; /** @@ -38,35 +38,43 @@ time.updateTime = function () { this.updateTime(); }.bind(this), seconds*1000); } - var diff = $('
').html(html); - diff.find('.digit').each(function( index ) { - var _text = $( this ).text(); - var _i = index+1; - var liveNode = $(timeLocation).find('.digit')[index] - if (typeof liveNode != 'undefined') { - liveNode = $(liveNode); - var _text2 = liveNode.text(); - if (_text != _text2) { - - liveNode.addClass('fade'); + if (this.digitFade) { + var diff = $('
').html(html); + diff.find('.digit').each(function( index ) { + var _text = $( this ).text(); + var _i = index+1; + var liveNode = $(timeLocation).find('.digit')[index] + if (typeof liveNode != 'undefined') { + liveNode = $(liveNode); + var _text2 = liveNode.text(); + if (_text != _text2) { + + liveNode.addClass('fade'); + $(this).addClass('fade'); + } + } else { $(this).addClass('fade'); } + }); + if ($('.fade').length == 0) { + // Initial Update + $(this.timeLocation).html(diff.html()); + diff = undefined; } else { - $(this).addClass('fade'); + $('.fade').fadeTo(400, 0.25, function() { + if (typeof diff != 'undefined') { + $(this.timeLocation).html(diff.html()); + diff = undefined; + } + $('.fade').fadeTo(400, 1).removeClass('fade'); + }.bind(this)); } - }); - if ($('.fade').length == 0) { - // Initial Update - $(timeLocation).html(diff.html()); - diff = undefined; } else { - $('.fade').fadeTo(400, 0.25, function() { - if (typeof diff != 'undefined') { - $(timeLocation).html(diff.html()); - diff = undefined; - } - $('.fade').fadeTo(400, 1).removeClass('fade'); - }).bind(this); + if (this.displaySeconds) { + $(this.timeLocation).html(_now.format(this._timeFormat+':mm[]ss[]')); + } else { + $(this.timeLocation).html(_now.format(this._timeFormat+':mm')); + } } }