diff --git a/js/uhr.js b/js/uhr.js index 485d815..7e638a1 100644 --- a/js/uhr.js +++ b/js/uhr.js @@ -1,19 +1,19 @@ /* -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ (function ($) { - 'use strict'; + 'use strict'; var uhrGlobals = { "id": 0, "languages": [], @@ -33,7 +33,7 @@ along with this program. If not, see . } }; - // auto-detect themes + // auto-detect themes $('link[rel=stylesheet]').each(function (index, item) { var styleSheet = $(item); var styleClass = styleSheet.attr('data-class'); @@ -45,10 +45,10 @@ along with this program. If not, see . uhrGlobals.themes.push({'styleClass': styleClass, 'name': name}); } }); - // fall-back if no theme was included - if (uhrGlobals.themes.length === 0) { - uhrGlobals.themes.push({}); - } + // fall-back if no theme was included + if (uhrGlobals.themes.length === 0) { + uhrGlobals.themes.push({}); + } // public interface methods (exported later) var start = function start() { @@ -339,13 +339,13 @@ along with this program. If not, see . "_create": create }); $.fritteli.uhr.register = uhrGlobals.registerLanguage; - /** - * Hilfsklasse zum Rendern der Uhr. - * @param layout Layout-Objekt, das gerendert werden soll. - * @param renderarea Das jQuery-gewrappte HTML-Element, auf dem gerendert werden soll. - */ - function UhrRenderer(layout, renderarea) { - this.render = function render(uhr, beforeshow) { + /** + * Hilfsklasse zum Rendern der Uhr. + * @param layout Layout-Objekt, das gerendert werden soll. + * @param renderarea Das jQuery-gewrappte HTML-Element, auf dem gerendert werden soll. + */ + function UhrRenderer(layout, renderarea) { + this.render = function render(uhr, beforeshow) { if (layout.parsed === undefined) { switch (layout.version) { case 2: @@ -376,16 +376,18 @@ along with this program. If not, see . }); }; } - function UhrRendererV2Delegate(layout) { - function parseArrayOrObject(letters, styleClass, input) { - if (Array.isArray(input)) { + + function UhrRendererV2Delegate(layout) { + function parseArrayOrObject(letters, styleClass, input) { + if (Array.isArray(input)) { input.forEach(function (item) { parseObject(letters, styleClass, item); }); - } else { - parseObject(letters, styleClass, input); - } - } + } else { + parseObject(letters, styleClass, input); + } + } + function parseObject(letters, styleClass, object) { Object.keys(object).forEach(function (y) { var highlightLetters = object[y]; @@ -394,7 +396,8 @@ along with this program. If not, see . }); }); } - function parseTimeDefinition(letters, styleClass, definition) { + + function parseTimeDefinition(letters, styleClass, definition) { Object.keys(definition).forEach(function (listString) { var array = listString.split(','); var highlightLetters = definition[listString]; @@ -402,7 +405,8 @@ along with this program. If not, see . parseArrayOrObject(letters, styleClass + item, highlightLetters); }); }); - } + } + this.parse = function parse() { var letters = []; layout.letters.forEach(function (string) { @@ -418,13 +422,14 @@ along with this program. If not, see . parseTimeDefinition(letters, 'hour', layout.hours); return letters; }; - } - /** - * Ein Buchstabe. Hilfsklasse für den Renderer und Inhalt der Layout-Arrays. - * @param value Der Buchstabe, der Dargestellt werden soll. - * @param style Die CSS-Styleklassen des Buchstabens. - */ - function Letter(value, style) { + } + + /** + * Ein Buchstabe. Hilfsklasse für den Renderer und Inhalt der Layout-Arrays. + * @param value Der Buchstabe, der Dargestellt werden soll. + * @param style Die CSS-Styleklassen des Buchstabens. + */ + function Letter(value, style) { var myValue = value; var myStyle = style || ''; this.addStyle = function (style) { @@ -437,5 +442,5 @@ along with this program. If not, see . this.toString = function () { return '' + myValue + ''; }; - } + } })(jQuery); \ No newline at end of file