re-indented the code

This commit is contained in:
Manuel Friedli 2014-07-04 00:52:09 +02:00
parent de75a3bdaf
commit 6f6feb5cf5

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
(function ($) {
'use strict';
'use strict';
var uhrGlobals = {
"id": 0,
"languages": [],
@ -33,7 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
}
};
// 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 <http://www.gnu.org/licenses/>.
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 <http://www.gnu.org/licenses/>.
"_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 <http://www.gnu.org/licenses/>.
});
};
}
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 <http://www.gnu.org/licenses/>.
});
});
}
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 <http://www.gnu.org/licenses/>.
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 <http://www.gnu.org/licenses/>.
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 <http://www.gnu.org/licenses/>.
this.toString = function () {
return '<span class="item letter ' + myStyle + '">' + myValue + '</span>';
};
}
}
})(jQuery);