first working version with some bugfixes! refactoring ensues ...
This commit is contained in:
parent
9a1160f66e
commit
eff9700864
2 changed files with 66 additions and 6 deletions
|
@ -36,7 +36,7 @@ var layout = {
|
||||||
'SÄCHSISIBNI',
|
'SÄCHSISIBNI',
|
||||||
'ACHTINÜNIEL',
|
'ACHTINÜNIEL',
|
||||||
'ZÄNIERBEUFI',
|
'ZÄNIERBEUFI',
|
||||||
'ZWÜUFINAUHR'
|
'ZWÖUFINAUHR'
|
||||||
],
|
],
|
||||||
"permanent": h._es_isch,
|
"permanent": h._es_isch,
|
||||||
"minutes": {
|
"minutes": {
|
||||||
|
@ -55,7 +55,6 @@ var layout = {
|
||||||
"55": [h._5, h._vor]
|
"55": [h._5, h._vor]
|
||||||
},
|
},
|
||||||
"hours": {
|
"hours": {
|
||||||
"0": {10:[1,2,3,4,5,6]},
|
|
||||||
"1": {5:[1,2,3]},
|
"1": {5:[1,2,3]},
|
||||||
"2": {5:[4,5,6,7]},
|
"2": {5:[4,5,6,7]},
|
||||||
"3": {5:[9,10,11]},
|
"3": {5:[9,10,11]},
|
||||||
|
@ -66,7 +65,8 @@ var layout = {
|
||||||
"8": {8:[1,2,3,4,5]},
|
"8": {8:[1,2,3,4,5]},
|
||||||
"9": {8:[6,7,8,9]},
|
"9": {8:[6,7,8,9]},
|
||||||
"10": {9:[1,2,3,4]},
|
"10": {9:[1,2,3,4]},
|
||||||
"11": {9:[8,9,10,11]}
|
"11": {9:[8,9,10,11]},
|
||||||
|
"12": {10:[1,2,3,4,5,6]}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
window._uhr.languages['de_CH_new'] = layout;
|
window._uhr.languages['de_CH_new'] = layout;
|
||||||
|
|
66
uhr.js
66
uhr.js
|
@ -287,11 +287,63 @@ function UhrRenderer(layout, renderarea) {
|
||||||
this.layout = layout;
|
this.layout = layout;
|
||||||
this.renderarea = renderarea;
|
this.renderarea = renderarea;
|
||||||
this._parseLayoutV2 = function() {
|
this._parseLayoutV2 = function() {
|
||||||
console.log("attempting to parse layout v2");
|
|
||||||
var letters = [];
|
var letters = [];
|
||||||
console.log(this.layout);
|
for (var i = 0; i < this.layout.letters.length; i++) {
|
||||||
|
var line = [];
|
||||||
|
var string = this.layout.letters[i];
|
||||||
|
for (var c = 0; c < string.length; c++) {
|
||||||
|
var character = new Letter(string[c]);
|
||||||
|
line.push(character);
|
||||||
|
}
|
||||||
|
letters.push(line);
|
||||||
|
}
|
||||||
|
var permanent = this.layout.permanent;
|
||||||
|
if (Array.isArray(permanent)) {
|
||||||
|
for (var i = 0; i < permanent.length; i++) {
|
||||||
|
this._parseObject(letters, 'on', permanent[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this._parseObject(letters, 'on', permanent);
|
||||||
|
}
|
||||||
|
var minutes = this.layout.minutes;
|
||||||
|
for (minute in minutes) {
|
||||||
|
if (minutes.hasOwnProperty(minute)) {
|
||||||
|
var highlightLetters = minutes[minute];
|
||||||
|
if (Array.isArray(highlightLetters)) {
|
||||||
|
for (var i = 0; i < highlightLetters.length; i++) {
|
||||||
|
this._parseObject(letters, 'minute' + minute, highlightLetters[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this._parseObject(letters, 'minute' + minute, highlightLetters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var hours = this.layout.hours;
|
||||||
|
for (hour in hours) {
|
||||||
|
if (hours.hasOwnProperty(hour)) {
|
||||||
|
var highlightLetters = hours[hour];
|
||||||
|
if (Array.isArray(highlightLetters)) {
|
||||||
|
for (var i = 0; i < highlightLetters.length; i++) {
|
||||||
|
this._parseObject(letters, 'hour' + hour, highlightLetters[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this._parseObject(letters, 'hour' + hour, highlightLetters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return letters;
|
return letters;
|
||||||
}
|
}
|
||||||
|
this._parseObject = function(letters, styleClass, object) {
|
||||||
|
for (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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
UhrRenderer.prototype.render = function(uhr, beforeshow) {
|
UhrRenderer.prototype.render = function(uhr, beforeshow) {
|
||||||
var renderer = this;
|
var renderer = this;
|
||||||
|
@ -336,11 +388,19 @@ function Letter(value, style) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.style = style || '';
|
this.style = style || '';
|
||||||
this.getStyle = function() {
|
this.getStyle = function() {
|
||||||
return 'item letter ' + style;
|
return 'item letter ' + this.style;
|
||||||
};
|
};
|
||||||
this.getValue = function() {
|
this.getValue = function() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
this.addStyle = function(style) {
|
||||||
|
if (this.style == '') {
|
||||||
|
this.style = style;
|
||||||
|
} else {
|
||||||
|
this.style += ' ' + style;
|
||||||
|
}
|
||||||
|
console.log(this.getStyle());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Letter.prototype.toString = function letterToString() {
|
Letter.prototype.toString = function letterToString() {
|
||||||
return '<span class="' + this.getStyle() + '">' + this.getValue() + '</span>';
|
return '<span class="' + this.getStyle() + '">' + this.getValue() + '</span>';
|
||||||
|
|
Loading…
Reference in a new issue