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
# 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

View file

@ -40,7 +40,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<div id="uhr"></div>
<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_genau.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.js"></script>
<script type="text/javascript" src="../uhr-en.js"></script>
<script type="text/javascript" src="../uhr-fr.js"></script>

View file

@ -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);

95
uhr.js
View file

@ -131,10 +131,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
_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 <http://www.gnu.org/licenses/>.
}
},
_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 <http://www.gnu.org/licenses/>.
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 <http://www.gnu.org/licenses/>.
}
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 <http://www.gnu.org/licenses/>.
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 <http://www.gnu.org/licenses/>.
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;
};