refactor: move every helper function inside the scope-limiting block in order not to pollute world

This commit is contained in:
Manuel Friedli 2014-06-28 15:53:08 +02:00
parent ffcf8fa2f2
commit 480736e877

18
uhr.js
View file

@ -34,7 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
if (name === undefined) {
name = styleClass;
}
window._uhr.themes.push({'class': styleClass, 'name': name});
window._uhr.themes.push({'styleClass': styleClass, 'name': name});
}
}
// fall-back if no theme was included
@ -46,7 +46,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
width: '100%',
status: 'on',
language: 'de_CH',
theme: window._uhr.themes[0].class,
theme: window._uhr.themes[0].styleClass,
force: false,
controls: true
},
@ -248,7 +248,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
var themeChooser = $('<select id="uhr-themechooser' + this._id + '"></select>');
for (var i = 0; i < window._uhr.themes.length; i++) {
var theme = window._uhr.themes[i];
themeChooser.append('<option value="' + theme.class + '">' + theme.name + '</option>');
themeChooser.append('<option value="' + theme.styleClass + '">' + theme.name + '</option>');
}
e.after(themeChooser);
}
@ -297,14 +297,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
}
var found = false;
for (var i = 0; i < window._uhr.themes.length; i++) {
var styleClass = window._uhr.themes[i].class;
var styleClass = window._uhr.themes[i].styleClass;
if (selectedTheme == styleClass) {
found = true;
break;
}
}
if (!found) {
var fallback = window._uhr.themes[0].class;
var fallback = window._uhr.themes[0].styleClass;
console.warn("Theme " + selectedTheme + " not found! Using fallback: " + fallback);
selectedTheme = fallback;
}
@ -313,8 +313,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
this.theme(selectedTheme);
}
});
})(jQuery);
/**
* Hilfsklasse zum Rendern der Uhr.
* @param layout Layout-Objekt, das gerendert werden soll.
@ -367,7 +365,7 @@ function _UhrRendererV2Delegate(layout) {
}
}
this._parseObject = function(letters, styleClass, object) {
for (line in object) {
for (var line in object) {
if (object.hasOwnProperty(line)) {
var highlightLetters = object[line];
for (var i = 0; i < highlightLetters.length; i++) {
@ -378,7 +376,7 @@ function _UhrRendererV2Delegate(layout) {
}
}
this._parseTimeDefinition = function(letters, styleClass, definition) {
for (listString in definition) {
for (var listString in definition) {
if (definition.hasOwnProperty(listString)) {
var array = listString.split(',');
var highlightLetters = definition[listString];
@ -430,3 +428,5 @@ function Letter(value, style) {
Letter.prototype.toString = function letterToString() {
return '<span class="' + this.getStyle() + '">' + this.getValue() + '</span>';
};
})(jQuery);