From c0af4a976f8e1ea9e40117e73a6455923d0d9db5 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Wed, 16 Jul 2014 17:08:10 +0200 Subject: [PATCH] rename seconds-file; add more failsafety (undefined-checks); override _getDotMinute for the second, so the dots don't show up. --- manifest.appcache | 3 +- showcase/index.html | 3 +- ...nds-de_CH_genau.js => uhr-de_CH-seconds.js | 27 +++--- uhr.js | 95 +++++++++++-------- 4 files changed, 75 insertions(+), 53 deletions(-) rename uhr-seconds-de_CH_genau.js => uhr-de_CH-seconds.js (93%) diff --git a/manifest.appcache b/manifest.appcache index 201ee99..ed2d9d3 100644 --- a/manifest.appcache +++ b/manifest.appcache @@ -1,5 +1,5 @@ CACHE MANIFEST -# 6.2.1 +# 6.3-alpha COPYING README.md @@ -13,6 +13,7 @@ uhr-black.css uhr-blue.css uhr-de.js uhr-de_CH.js +uhr-de_CH-seconds.js uhr-de_CH_genau.js uhr-en.js uhr-fr.js diff --git a/showcase/index.html b/showcase/index.html index c18666e..14e6bce 100644 --- a/showcase/index.html +++ b/showcase/index.html @@ -40,7 +40,8 @@ along with this program. If not, see .

Go back to the main page

- + + diff --git a/uhr-seconds-de_CH_genau.js b/uhr-de_CH-seconds.js similarity index 93% rename from uhr-seconds-de_CH_genau.js rename to uhr-de_CH-seconds.js index c15f525..09d1ff8 100644 --- a/uhr-seconds-de_CH_genau.js +++ b/uhr-de_CH-seconds.js @@ -163,19 +163,19 @@ var h = { } }; var layout = { - "version": 3, - "language": 'Bärndütschi Sekunde (genau)', + "version": 2, + "language": 'Bärndütschi Sekunde', "letters": [ - 'ESKISCHAFÜF', - 'VIERTUBFZÄÄ', - 'ZWÄNZGGENAU', - 'VORABOHAUBI', - 'EISZWÖISDRÜ', - 'VIERIFÜFIQT', - 'SÄCHSISIBNI', - 'ACHTINÜNIEL', - 'ZÄNIERBEUFI', - 'ZWÖUFINAUHR' + 'ESKISCHAFÜF', + 'VIERTUBFZÄÄ', + 'ZWÄNZGSIVOR', + 'ABOHAUBIEGE', + 'EISZWÖISDRÜ', + 'VIERIFÜFIQT', + 'SÄCHSISIBNI', + 'ACHTINÜNIEL', + 'ZÄNIERBEUFI', + 'ZWÖUFINAUHR' ], "seconds": { "0": [h.vorne0, h.hinten0], @@ -238,6 +238,9 @@ var layout = { "57": [h.vorne5, h.hinten7], "58": [h.vorne5, h.hinten8], "59": [h.vorne5, h.hinten9] + }, + "getDotMinute": function(time) { + return 0; } }; window,_uhr.register('de_CH_seconds', layout); diff --git a/uhr.js b/uhr.js index 21196a2..9df362a 100644 --- a/uhr.js +++ b/uhr.js @@ -131,10 +131,12 @@ along with this program. If not, see . _update: function() { if (this._isOn()) { var time = this.options.time; - if (time.getMinutes() == this._currentMinute) { - return; - } - this._currentMinute = time.getMinutes(); + if (!this._language().hasOwnProperty('seconds')) { + if (time.getMinutes() == this._currentMinute) { + return; + } + this._currentMinute = time.getMinutes(); + } this._show(time); } else { this._clear(); @@ -142,7 +144,8 @@ along with this program. If not, see . } }, _show: function(time) { - var dotMinute = this._getDotMinute(time); + var second = this._getSecond(time); + var dotMinute = this._getDotMinute(time); var hour = this._getHour(time); var coarseMinute = this._getCoarseMinute(time); this._clear(); @@ -150,7 +153,8 @@ along with this program. If not, see . for (var i = 1; i <= dotMinute; i++) { this._highlight('dot' + i); } - this._highlight('minute' + coarseMinute); + this._highlight('second' + second); + this._highlight('minute' + coarseMinute); this._highlight('hour' + hour); }, _language: function() { @@ -185,13 +189,19 @@ along with this program. If not, see . } return date.getMinutes(); }, - _getDotMinute: function(date) { - if (typeof this._language().getDotMinute === 'function') { - return this._language().getDotMinute(date); - } - var minutes = date.getMinutes(); - return minutes % 5; - }, + _getDotMinute: function(date) { + if (typeof this._language().getDotMinute === 'function') { + return this._language().getDotMinute(date); + } + var minutes = date.getMinutes(); + return minutes % 5; + }, + _getSecond: function(date) { + if (typeof this._language().getSecond === 'function') { + return this._language().getSecond(date); + } + return date.getSeconds(); + }, _create: function() { this._id = window._uhr.id++; var userTime = this.options.time; @@ -381,35 +391,41 @@ along with this program. If not, see . function _UhrRendererV2Delegate(layout) { this.layout = layout; this._parseArrayOrObject = function(letters, styleClass, input) { - if (Array.isArray(input)) { - for (var i = 0; i < input.length; i++) { - this._parseObject(letters, styleClass, input[i]); - } - } else { - this._parseObject(letters, styleClass, input); - } + if (typeof input !== 'undefined' && input !== null) { + if (Array.isArray(input)) { + for (var i = 0; i < input.length; i++) { + this._parseObject(letters, styleClass, input[i]); + } + } else { + this._parseObject(letters, styleClass, input); + } + } } this._parseObject = function(letters, styleClass, object) { - for (var line in object) { - if (object.hasOwnProperty(line)) { - var highlightLetters = object[line]; - for (var i = 0; i < highlightLetters.length; i++) { - var x = highlightLetters[i] - 1; - letters[line - 1][x].addStyle(styleClass); - } - } - } + if (typeof object !== 'undefined' && object !== null) { + for (var line in object) { + if (object.hasOwnProperty(line)) { + var highlightLetters = object[line]; + for (var i = 0; i < highlightLetters.length; i++) { + var x = highlightLetters[i] - 1; + letters[line - 1][x].addStyle(styleClass); + } + } + } + } } this._parseTimeDefinition = function(letters, styleClass, definition) { - for (var listString in definition) { - if (definition.hasOwnProperty(listString)) { - var array = listString.split(','); - var highlightLetters = definition[listString]; - for (var index = 0; index < array.length; index++) { - this._parseArrayOrObject(letters, styleClass + array[index], highlightLetters); - } - } - } + if (typeof definition !== 'undefined' && definition != null) { + for (var listString in definition) { + if (definition.hasOwnProperty(listString)) { + var array = listString.split(','); + var highlightLetters = definition[listString]; + for (var index = 0; index < array.length; index++) { + this._parseArrayOrObject(letters, styleClass + array[index], highlightLetters); + } + } + } + } } } _UhrRendererV2Delegate.prototype.parse = function() { @@ -424,7 +440,8 @@ along with this program. If not, see . letters.push(line); } this._parseArrayOrObject(letters, 'on', this.layout.permanent); - this._parseTimeDefinition(letters, 'minute', this.layout.minutes); + this._parseTimeDefinition(letters, 'second', this.layout.seconds); + this._parseTimeDefinition(letters, 'minute', this.layout.minutes); this._parseTimeDefinition(letters, 'hour', this.layout.hours); return letters; };