layouts global registrieren, nicht pro uhr

This commit is contained in:
Manuel Friedli 2013-11-27 17:36:05 +01:00
parent 1c06b7248a
commit 2fa23c2f07
5 changed files with 17 additions and 16 deletions

View file

@ -59,13 +59,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
var theme = $.cookie('theme');
var layout = $.cookie('layout');
var status = $.cookie('status');
if (theme == undefined) {
if (theme === undefined || theme == 'undefined') {
theme = 'black';
}
if(layout == undefined) {
if(layout === undefined || layout == 'undefined') {
layout = 'de_CH';
}
if (status == undefined) {
if (status === undefined || status == 'undefined') {
status = 'on';
}
$('#themeswitcher').val(theme);

View file

@ -27,4 +27,4 @@ var layout = {
[h('Z', 10), h('E', 10),h('H', 10),h('N', 9, 10),h('E', 9),h('U', 9),h('N', 9),l('K'),l('U'),l('H'),l('R')]
]
};
uhr.register('de', layout);
Uhr.register('de', layout);

View file

@ -27,4 +27,4 @@ var layout = {
[h('Z', 12), h('W', 12),h('Ö', 12),h('U', 12),h('F', 12),h('I', 12),l('N'),l('A'),l('U'),l('H'),l('R')]
]
};
uhr.register('de_CH', layout);
Uhr.register('de_CH', layout);

View file

@ -34,4 +34,4 @@ var layout = {
return hour;
}
};
uhr.register('en', layout);
Uhr.register('en', layout);

21
uhr.js
View file

@ -31,14 +31,13 @@ function Uhr(clockarea, themeElement) {
this.timer = null;
this.currentTheme = null;
this.currentLayout = null;
this.layouts = new Array();
this.currentMinute = -1;
this.register('undefined', {
language: 'Undefined',
values: []
});
this.setLayout('undefined');
}
Uhr.layouts = new Array();
Uhr.register = function (locale, layout) {
Uhr.layouts[locale] = layout;
}
Uhr.prototype.toggle = function() {
if (this.isOn()) {
this.stop();
@ -65,11 +64,8 @@ Uhr.prototype.stop = function() {
Uhr.prototype.isOn = function() {
return this.timer != null;
}
Uhr.prototype.register = function(key, layout) {
this.layouts[key] = layout;
}
Uhr.prototype.setLayout = function(locale) {
var newLayout = this.layouts[locale];
var newLayout = Uhr.layouts[locale];
if (newLayout !== undefined && newLayout != this.currentLayout) {
this.currentLayout = newLayout;
var renderer = new UhrRenderer(this.currentLayout, this.letterarea);
@ -150,6 +146,11 @@ Uhr.prototype.normalizeHour = function(hour) {
return hour;
}
Uhr.register('undefined', {
language: 'Undefined',
values: []
});
/**
* Hilfsklasse zum Rendern der Uhr.
* @param layout Layout-Objekt, das gerendert werden soll.