From 6d588aa08ba50581eaec6f017571dfb09a127fc4 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Thu, 26 Jun 2014 14:41:56 +0200 Subject: [PATCH] bugfix for update in relation to fixed time; slight change in format of layout definition. --- uhr-de_CH_new.js | 24 ++++++++++++------------ uhr.js | 31 +++++++++++++++++++------------ 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/uhr-de_CH_new.js b/uhr-de_CH_new.js index 6283f2d..f755aec 100644 --- a/uhr-de_CH_new.js +++ b/uhr-de_CH_new.js @@ -41,18 +41,18 @@ var layout = { "permanent": h._es_isch, "minutes": { "0": h._genau, - "1": {}, - "5": [h._5, h._ab], - "10": [h._10, h._ab], - "15": [h._15, h._ab], - "20": [h._20, h._ab], - "25": [h._5, h._vor, h._haubi], - "30": [h._haubi], - "35": [h._5, h._ab, h._haubi], - "40": [h._20, h._vor], - "45": [h._15, h._vor], - "50": [h._10, h._vor], - "55": [h._5, h._vor] + "1,2,3,4": {}, + "5,6,7,8,9": [h._5, h._ab], + "10,11,12,13,14": [h._10, h._ab], + "15,16,17,18,19": [h._15, h._ab], + "20,21,22,23,24": [h._20, h._ab], + "25,26,27,28,29": [h._5, h._vor, h._haubi], + "30,31,32,33,34": [h._haubi], + "35,36,37,38,39": [h._5, h._ab, h._haubi], + "40,41,42,43,44": [h._20, h._vor], + "45,46,47,48,48": [h._15, h._vor], + "50,51,52,53,54": [h._10, h._vor], + "55,56,57,58,59": [h._5, h._vor] }, "hours": { "1": {5:[1,2,3]}, diff --git a/uhr.js b/uhr.js index 75849af..fa0d70e 100644 --- a/uhr.js +++ b/uhr.js @@ -30,8 +30,7 @@ along with this program. If not, see . language: 'de_CH', theme: 'black', force: false, - controls: true, - time: new Date() + controls: true }, start: function() { if (!this._isOn()) { @@ -153,8 +152,7 @@ along with this program. If not, see . if (typeof this._language().getCoarseMinute === 'function') { return this._language().getCoarseMinute(date); } - var minutes = date.getMinutes(); - return minutes - this._getDotMinute(date); + return date.getMinutes(); }, _getDotMinute: function(date) { if (typeof this._language().getDotMinute === 'function') { @@ -174,10 +172,14 @@ along with this program. If not, see . }, _create: function() { this._id = window._uhr.id++; + var userTime = this.options.time; + if (this.options.time === undefined) { + this.options.time = new Date(); + } this._setupHTML(); this._wireFunctionality(); - if (this.options.time !== undefined) { - this.time(this.options.time); + if (userTime !== undefined) { + this.time(userTime); } }, _setupHTML: function() { @@ -302,16 +304,21 @@ function UhrRenderer(layout, renderarea) { } else { this._parseObject(letters, 'on', permanent); } - var minutes = this.layout.minutes; - for (minute in minutes) { - if (minutes.hasOwnProperty(minute)) { - var highlightLetters = minutes[minute]; + var minuteDefinitions = this.layout.minutes; + for (minutes in minuteDefinitions) { + if (minuteDefinitions.hasOwnProperty(minutes)) { + var highlightLetters = minuteDefinitions[minutes]; + var minuteArray = minutes.split(','); if (Array.isArray(highlightLetters)) { for (var i = 0; i < highlightLetters.length; i++) { - this._parseObject(letters, 'minute' + minute, highlightLetters[i]); + for (var j = 0; j < minuteArray.length; j++) { + this._parseObject(letters, 'minute' + minuteArray[j], highlightLetters[i]); + } } } else { - this._parseObject(letters, 'minute' + minute, highlightLetters); + for (var i = 0; i < minuteArray.length; i++) { + this._parseObject(letters, 'minute' + minuteArray[i], highlightLetters); + } } } }