rename seconds-file; add more failsafety (undefined-checks); override

_getDotMinute for the second, so the dots don't show up.
This commit is contained in:
Manuel Friedli 2014-07-16 17:08:10 +02:00
parent a0e2588d91
commit c0af4a976f
4 changed files with 75 additions and 53 deletions

View file

@ -1,5 +1,5 @@
CACHE MANIFEST CACHE MANIFEST
# 6.2.1 # 6.3-alpha
COPYING COPYING
README.md README.md
@ -13,6 +13,7 @@ uhr-black.css
uhr-blue.css uhr-blue.css
uhr-de.js uhr-de.js
uhr-de_CH.js uhr-de_CH.js
uhr-de_CH-seconds.js
uhr-de_CH_genau.js uhr-de_CH_genau.js
uhr-en.js uhr-en.js
uhr-fr.js uhr-fr.js

View file

@ -40,6 +40,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<div id="uhr"></div> <div id="uhr"></div>
<p ><a href="..">Go back to the main page</a></p> <p ><a href="..">Go back to the main page</a></p>
<script type="text/javascript" src="../uhr-de_CH.js"></script> <script type="text/javascript" src="../uhr-de_CH.js"></script>
<script type="text/javascript" src="../uhr-de_CH-seconds.js"></script>
<script type="text/javascript" src="../uhr-de_CH_genau.js"></script> <script type="text/javascript" src="../uhr-de_CH_genau.js"></script>
<script type="text/javascript" src="../uhr-de.js"></script> <script type="text/javascript" src="../uhr-de.js"></script>
<script type="text/javascript" src="../uhr-en.js"></script> <script type="text/javascript" src="../uhr-en.js"></script>

View file

@ -163,13 +163,13 @@ var h = {
} }
}; };
var layout = { var layout = {
"version": 3, "version": 2,
"language": 'Bärndütschi Sekunde (genau)', "language": 'Bärndütschi Sekunde',
"letters": [ "letters": [
'ESKISCHAFÜF', 'ESKISCHAFÜF',
'VIERTUBFZÄÄ', 'VIERTUBFZÄÄ',
'ZWÄNZGGENAU', 'ZWÄNZGSIVOR',
'VORABOHAUBI', 'ABOHAUBIEGE',
'EISZWÖISDRÜ', 'EISZWÖISDRÜ',
'VIERIFÜFIQT', 'VIERIFÜFIQT',
'SÄCHSISIBNI', 'SÄCHSISIBNI',
@ -238,6 +238,9 @@ var layout = {
"57": [h.vorne5, h.hinten7], "57": [h.vorne5, h.hinten7],
"58": [h.vorne5, h.hinten8], "58": [h.vorne5, h.hinten8],
"59": [h.vorne5, h.hinten9] "59": [h.vorne5, h.hinten9]
},
"getDotMinute": function(time) {
return 0;
} }
}; };
window,_uhr.register('de_CH_seconds', layout); window,_uhr.register('de_CH_seconds', layout);

17
uhr.js
View file

@ -131,10 +131,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
_update: function() { _update: function() {
if (this._isOn()) { if (this._isOn()) {
var time = this.options.time; var time = this.options.time;
if (!this._language().hasOwnProperty('seconds')) {
if (time.getMinutes() == this._currentMinute) { if (time.getMinutes() == this._currentMinute) {
return; return;
} }
this._currentMinute = time.getMinutes(); this._currentMinute = time.getMinutes();
}
this._show(time); this._show(time);
} else { } else {
this._clear(); this._clear();
@ -142,6 +144,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
} }
}, },
_show: function(time) { _show: function(time) {
var second = this._getSecond(time);
var dotMinute = this._getDotMinute(time); var dotMinute = this._getDotMinute(time);
var hour = this._getHour(time); var hour = this._getHour(time);
var coarseMinute = this._getCoarseMinute(time); var coarseMinute = this._getCoarseMinute(time);
@ -150,6 +153,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
for (var i = 1; i <= dotMinute; i++) { for (var i = 1; i <= dotMinute; i++) {
this._highlight('dot' + i); this._highlight('dot' + i);
} }
this._highlight('second' + second);
this._highlight('minute' + coarseMinute); this._highlight('minute' + coarseMinute);
this._highlight('hour' + hour); this._highlight('hour' + hour);
}, },
@ -191,6 +195,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
} }
var minutes = date.getMinutes(); var minutes = date.getMinutes();
return minutes % 5; return minutes % 5;
},
_getSecond: function(date) {
if (typeof this._language().getSecond === 'function') {
return this._language().getSecond(date);
}
return date.getSeconds();
}, },
_create: function() { _create: function() {
this._id = window._uhr.id++; this._id = window._uhr.id++;
@ -381,6 +391,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
function _UhrRendererV2Delegate(layout) { function _UhrRendererV2Delegate(layout) {
this.layout = layout; this.layout = layout;
this._parseArrayOrObject = function(letters, styleClass, input) { this._parseArrayOrObject = function(letters, styleClass, input) {
if (typeof input !== 'undefined' && input !== null) {
if (Array.isArray(input)) { if (Array.isArray(input)) {
for (var i = 0; i < input.length; i++) { for (var i = 0; i < input.length; i++) {
this._parseObject(letters, styleClass, input[i]); this._parseObject(letters, styleClass, input[i]);
@ -388,8 +399,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
} else { } else {
this._parseObject(letters, styleClass, input); this._parseObject(letters, styleClass, input);
} }
}
} }
this._parseObject = function(letters, styleClass, object) { this._parseObject = function(letters, styleClass, object) {
if (typeof object !== 'undefined' && object !== null) {
for (var line in object) { for (var line in object) {
if (object.hasOwnProperty(line)) { if (object.hasOwnProperty(line)) {
var highlightLetters = object[line]; var highlightLetters = object[line];
@ -399,8 +412,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
} }
} }
} }
}
} }
this._parseTimeDefinition = function(letters, styleClass, definition) { this._parseTimeDefinition = function(letters, styleClass, definition) {
if (typeof definition !== 'undefined' && definition != null) {
for (var listString in definition) { for (var listString in definition) {
if (definition.hasOwnProperty(listString)) { if (definition.hasOwnProperty(listString)) {
var array = listString.split(','); var array = listString.split(',');
@ -412,6 +427,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
} }
} }
} }
}
_UhrRendererV2Delegate.prototype.parse = function() { _UhrRendererV2Delegate.prototype.parse = function() {
var letters = []; var letters = [];
for (var i = 0; i < this.layout.letters.length; i++) { for (var i = 0; i < this.layout.letters.length; i++) {
@ -424,6 +440,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
letters.push(line); letters.push(line);
} }
this._parseArrayOrObject(letters, 'on', this.layout.permanent); this._parseArrayOrObject(letters, 'on', this.layout.permanent);
this._parseTimeDefinition(letters, 'second', this.layout.seconds);
this._parseTimeDefinition(letters, 'minute', this.layout.minutes); this._parseTimeDefinition(letters, 'minute', this.layout.minutes);
this._parseTimeDefinition(letters, 'hour', this.layout.hours); this._parseTimeDefinition(letters, 'hour', this.layout.hours);
return letters; return letters;