From afe923c1367b4054aba20b66e475b4eaf7cf8c61 Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 3 Jul 2014 16:53:07 +0200 Subject: [PATCH 01/30] some JSHint'ing and reorganizing of the project-structure --- .jshintrc | 78 +++++++++++ uhr-black.css => css/uhr-black.css | 0 uhr-blue.css => css/uhr-blue.css | 0 uhr-green.css => css/uhr-green.css | 0 uhr-pink.css => css/uhr-pink.css | 0 uhr-red.css => css/uhr-red.css | 0 uhr-white.css => css/uhr-white.css | 0 uhr-yellow.css => css/uhr-yellow.css | 0 uhr.css => css/uhr.css | 0 index.html | 18 +-- info/index.html | 16 +-- uhr-de.js => js/uhr-de.js | 2 +- uhr-de_CH.js => js/uhr-de_CH.js | 2 +- uhr-de_CH_genau.js => js/uhr-de_CH_genau.js | 2 +- uhr-en.js => js/uhr-en.js | 2 +- uhr-fr.js => js/uhr-fr.js | 2 +- uhr-it.js => js/uhr-it.js | 2 +- uhr.js => js/uhr.js | 126 +++++++++--------- .../jquery-2.1.0.min.js | 0 .../jquery-cookie-1.4.0.js | 0 .../jquery-ui-1.10.4.custom.min.js | 0 .../apple-touch-icon-precomposed.png | Bin favicon.png => resources/favicon.png | Bin uhr.woff => resources/uhr.woff | Bin showcase/index.html | 36 ++--- 25 files changed, 182 insertions(+), 104 deletions(-) create mode 100644 .jshintrc rename uhr-black.css => css/uhr-black.css (100%) rename uhr-blue.css => css/uhr-blue.css (100%) rename uhr-green.css => css/uhr-green.css (100%) rename uhr-pink.css => css/uhr-pink.css (100%) rename uhr-red.css => css/uhr-red.css (100%) rename uhr-white.css => css/uhr-white.css (100%) rename uhr-yellow.css => css/uhr-yellow.css (100%) rename uhr.css => css/uhr.css (100%) rename uhr-de.js => js/uhr-de.js (98%) rename uhr-de_CH.js => js/uhr-de_CH.js (98%) rename uhr-de_CH_genau.js => js/uhr-de_CH_genau.js (97%) rename uhr-en.js => js/uhr-en.js (98%) rename uhr-fr.js => js/uhr-fr.js (98%) rename uhr-it.js => js/uhr-it.js (98%) rename uhr.js => js/uhr.js (81%) rename jquery-2.1.0.min.js => lib/jquery-2.1.0.min.js (100%) rename jquery-cookie-1.4.0.js => lib/jquery-cookie-1.4.0.js (100%) rename jquery-ui-1.10.4.custom.min.js => lib/jquery-ui-1.10.4.custom.min.js (100%) rename apple-touch-icon-precomposed.png => resources/apple-touch-icon-precomposed.png (100%) rename favicon.png => resources/favicon.png (100%) rename uhr.woff => resources/uhr.woff (100%) diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..01ed15d --- /dev/null +++ b/.jshintrc @@ -0,0 +1,78 @@ +{ + // Settings + "passfail" : false, // Stop on first error. + "maxerr" : 100, // Maximum error before stopping. + + + // Predefined globals whom JSHint will ignore. + "browser" : true, // Standard browser globals e.g. `window`, `document`. + + "node" : false, + "rhino" : false, + "couch" : false, + "wsh" : true, // Windows Scripting Host. + + "jquery" : true, + "ender" : true, + "prototypejs" : false, + "mootools" : false, + "dojo" : false, + + "predef" : [ +// "define", +// "suite", +// "test", +// "teardown", +// "setup", +// "sinon", +// "mocha", +// "requirejs" + ], + + + // Development. + "debug" : false, // Allow debugger statements e.g. browser breakpoints. + "devel" : true, // Allow developments statements e.g. `console.log();`. + + + // ECMAScript 5. + "es5" : true, // Allow ECMAScript 5 syntax. + "strict" : true, // Require `use strict` pragma in every file. + "globalstrict" : true, // Allow global "use strict" (also enables 'strict'). + + + // The Good Parts. + "asi" : false, // Tolerate Automatic Semicolon Insertion (no semicolons). + "laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons. + "bitwise" : true, // Prohibit bitwise operators (&, |, ^, etc.). + "boss" : false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments. + "curly" : true, // Require {} for every new block or scope. + "eqeqeq" : true, // Require triple equals i.e. `===`. + "eqnull" : false, // Tolerate use of `== null`. + "evil" : false, // Tolerate use of `eval`. + "expr" : false, // Tolerate `ExpressionStatement` as Programs. + "forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`. + "immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );` + "latedef" : true, // Prohipit variable use before definition. + "loopfunc" : false, // Allow functions to be defined within loops. + "noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`. + "regexp" : true, // Prohibit `.` and `[^...]` in regular expressions. + "regexdash" : false, // Tolerate unescaped last dash i.e. `[-...]`. + "scripturl" : true, // Tolerate script-targeted URLs. + "shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`. + "supernew" : false, // Tolerate `new function () { ... };` and `new Object;`. + "undef" : true, // Require all non-global variables be declared before they are used. + + + // Personal styling preferences. + "newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`. + "noempty" : true, // Prohibit use of empty blocks. + "nonew" : true, // Prohibit use of constructors for side-effects. + "nomen" : true, // Prohibit use of initial or trailing underbars in names. + "onevar" : false, // Allow only one `var` statement per function. + "plusplus" : false, // Prohibit use of `++` & `--`. + "sub" : false, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`. + "trailing" : true, // Prohibit trailing whitespaces. + "white" : true, // Check against strict whitespace and indentation rules. + "indent" : 0 // Specify indentation spacing +} \ No newline at end of file diff --git a/uhr-black.css b/css/uhr-black.css similarity index 100% rename from uhr-black.css rename to css/uhr-black.css diff --git a/uhr-blue.css b/css/uhr-blue.css similarity index 100% rename from uhr-blue.css rename to css/uhr-blue.css diff --git a/uhr-green.css b/css/uhr-green.css similarity index 100% rename from uhr-green.css rename to css/uhr-green.css diff --git a/uhr-pink.css b/css/uhr-pink.css similarity index 100% rename from uhr-pink.css rename to css/uhr-pink.css diff --git a/uhr-red.css b/css/uhr-red.css similarity index 100% rename from uhr-red.css rename to css/uhr-red.css diff --git a/uhr-white.css b/css/uhr-white.css similarity index 100% rename from uhr-white.css rename to css/uhr-white.css diff --git a/uhr-yellow.css b/css/uhr-yellow.css similarity index 100% rename from uhr-yellow.css rename to css/uhr-yellow.css diff --git a/uhr.css b/css/uhr.css similarity index 100% rename from uhr.css rename to css/uhr.css diff --git a/index.html b/index.html index 8762468..ab07b0b 100644 --- a/index.html +++ b/index.html @@ -21,19 +21,19 @@ along with this program. If not, see . - - - - - - - - + + + + + + + +

Created by fritteli, inspired by QLOCKTWO. Read more! - View full showcase!

- + - - - - + + + + + +

Die Zeit im Wort

diff --git a/uhr-de.js b/js/uhr-de.js similarity index 98% rename from uhr-de.js rename to js/uhr-de.js index 0ddf05f..9d04411 100644 --- a/uhr-de.js +++ b/js/uhr-de.js @@ -67,4 +67,4 @@ var layout = { "11,23": {5:[6,7,8]} } }; -window,_uhr.register('de', layout); +window,uhr.register('de', layout); diff --git a/uhr-de_CH.js b/js/uhr-de_CH.js similarity index 98% rename from uhr-de_CH.js rename to js/uhr-de_CH.js index a2d85c9..c01523f 100644 --- a/uhr-de_CH.js +++ b/js/uhr-de_CH.js @@ -93,4 +93,4 @@ var layout = { } }; // Das Layout bei der Uhr unter dem Code "de_CH" registrieren. -window,_uhr.register('de_CH', layout); +window,uhr.register('de_CH', layout); diff --git a/uhr-de_CH_genau.js b/js/uhr-de_CH_genau.js similarity index 97% rename from uhr-de_CH_genau.js rename to js/uhr-de_CH_genau.js index 7d396c3..5ff9ec7 100644 --- a/uhr-de_CH_genau.js +++ b/js/uhr-de_CH_genau.js @@ -68,4 +68,4 @@ var layout = { "11,23": {9:[8,9,10,11]} } }; -window,_uhr.register('de_CH_genau', layout); +window,uhr.register('de_CH_genau', layout); diff --git a/uhr-en.js b/js/uhr-en.js similarity index 98% rename from uhr-en.js rename to js/uhr-en.js index 4ababd1..d271bc6 100644 --- a/uhr-en.js +++ b/js/uhr-en.js @@ -76,4 +76,4 @@ var layout = { return hour; } }; -window,_uhr.register('en', layout); +window,uhr.register('en', layout); diff --git a/uhr-fr.js b/js/uhr-fr.js similarity index 98% rename from uhr-fr.js rename to js/uhr-fr.js index cf0bbce..9ec0e51 100644 --- a/uhr-fr.js +++ b/js/uhr-fr.js @@ -78,4 +78,4 @@ var layout = { return hour; } }; -window,_uhr.register('fr', layout); +window,uhr.register('fr', layout); diff --git a/uhr-it.js b/js/uhr-it.js similarity index 98% rename from uhr-it.js rename to js/uhr-it.js index 6666a0a..267d2b2 100644 --- a/uhr-it.js +++ b/js/uhr-it.js @@ -75,4 +75,4 @@ var layout = { return hour; } }; -window,_uhr.register('it', layout); +window,uhr.register('it', layout); diff --git a/uhr.js b/js/uhr.js similarity index 81% rename from uhr.js rename to js/uhr.js index 21196a2..76e7fd6 100644 --- a/uhr.js +++ b/js/uhr.js @@ -12,20 +12,20 @@ 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 . */ -(function($) { +(function ($) { 'use strict'; - if (window._uhr !== undefined) { + if (window.uhr !== undefined) { return; } - window._uhr = { + window.uhr = { id: 0, languages: [], themes: [], - register: function(code, language) { + register: function (code, language) { for (var i = 0; i < this.languages.length; i++) { - if (code == this.languages[i].code) { + if (code === this.languages[i].code) { console.error('Error: Language code ' + code + ' cannot be registered for language "' + language.language + '" because it is already registered for language "' + this.languages[i].language + '"!'); return false; } @@ -44,23 +44,23 @@ along with this program. If not, see . if (name === undefined) { name = styleClass; } - window._uhr.themes.push({'styleClass': styleClass, 'name': name}); + window.uhr.themes.push({'styleClass': styleClass, 'name': name}); } } // fall-back if no theme was included - if (window._uhr.themes.length == 0) { - window._uhr.themes.push({}); + if (window.uhr.themes.length === 0) { + window.uhr.themes.push({}); } $.widget("fritteli.uhr", { options: { width: '100%', status: 'on', language: 'de_CH', - theme: window._uhr.themes[0].styleClass, + theme: window.uhr.themes[0].styleClass, force: false, controls: true }, - start: function() { + start: function () { if (!this._isOn()) { var uhr = this; this._timer = window.setInterval(function() { @@ -72,22 +72,22 @@ along with this program. If not, see . } else { } }, - stop: function() { - if(this._isOn()) { + stop: function () { + if (this._isOn()) { window.clearInterval(this._timer); this._timer = null; this._update(); this._setCookie('uhr-status', 'off'); } }, - toggle: function() { - if(this._isOn()) { + toggle: function () { + if (this._isOn()) { this.stop(); } else { this.start(); } }, - language: function(languageKey) { + language: function (languageKey) { if (languageKey !== this.options.language) { this.options.language = languageKey; var renderer = new UhrRenderer(this._language(), this.element.find('.letterarea')); @@ -100,20 +100,20 @@ along with this program. If not, see . this._update(); } }, - theme: function(theme) { - if (theme != this.options.theme) { + theme: function (theme) { + if (theme !== this.options.theme) { this.element.removeClass(this.options.theme).addClass(theme); $('#uhr-onoffswitch' + this._id).removeClass(this.options.theme).addClass(theme); this.options.theme = theme; this._setCookie('uhr-theme', theme); } }, - time: function(time) { + time: function (time) { this._currentMinute = -1; - if (time == null) { + if (time === null) { this.options.time = new Date(); } else { - if (this._timer != null) { + if (this._timer !== null) { window.clearInterval(this._timer); } this.options.time = time; @@ -125,13 +125,13 @@ along with this program. If not, see . _timer: null, _currentMinute: -1, // private methods - _isOn: function() { + _isOn: function () { return this._timer !== null; }, - _update: function() { + _update: function () { if (this._isOn()) { var time = this.options.time; - if (time.getMinutes() == this._currentMinute) { + if (time.getMinutes() === this._currentMinute) { return; } this._currentMinute = time.getMinutes(); @@ -141,7 +141,7 @@ along with this program. If not, see . this._currentMinute = -1; } }, - _show: function(time) { + _show: function (time) { var dotMinute = this._getDotMinute(time); var hour = this._getHour(time); var coarseMinute = this._getCoarseMinute(time); @@ -153,9 +153,9 @@ along with this program. If not, see . this._highlight('minute' + coarseMinute); this._highlight('hour' + hour); }, - _language: function() { - for (var i = 0; i < window._uhr.languages.length; i++) { - var language = window._uhr.languages[i]; + _language: function () { + for (var i = 0; i < window.uhr.languages.length; i++) { + var language = window.uhr.languages[i]; if (language.code == this.options.language) { return language; } @@ -163,13 +163,13 @@ along with this program. If not, see . // fallback: return empty object return {}; }, - _highlight: function(itemClass) { + _highlight: function (itemClass) { this.element.find('.item.' + itemClass).addClass('active'); }, - _clear: function() { + _clear: function () { this.element.find('.item').removeClass('active'); }, - _getHour: function(date) { + _getHour: function (date) { if (typeof this._language().getHour === 'function') { return this._language().getHour(date); } @@ -179,21 +179,21 @@ along with this program. If not, see . } return hour; }, - _getCoarseMinute: function(date) { + _getCoarseMinute: function (date) { if (typeof this._language().getCoarseMinute === 'function') { return this._language().getCoarseMinute(date); } return date.getMinutes(); }, - _getDotMinute: function(date) { + _getDotMinute: function (date) { if (typeof this._language().getDotMinute === 'function') { return this._language().getDotMinute(date); } var minutes = date.getMinutes(); return minutes % 5; }, - _create: function() { - this._id = window._uhr.id++; + _create: function () { + this._id = window.uhr.id++; var userTime = this.options.time; if (this.options.time === undefined) { this.options.time = new Date(); @@ -204,7 +204,7 @@ along with this program. If not, see . this.time(userTime); } }, - _setupHTML: function() { + _setupHTML: function () { var e = this.element; // Base clock area e.addClass('uhr'); @@ -232,40 +232,40 @@ along with this program. If not, see . e.after(toggleSwitch); // language chooser - if (window._uhr.languages.length > 1) { + if (window.uhr.languages.length > 1) { var languageChooser = $(''); - for (var i = 0; i < window._uhr.languages.length; i++) { - var language = window._uhr.languages[i]; + for (var i = 0; i < window.uhr.languages.length; i++) { + var language = window.uhr.languages[i]; languageChooser.append(''); } e.after(languageChooser); } // theme chooser - if (window._uhr.themes.length > 1) { + if (window.uhr.themes.length > 1) { var themeChooser = $(''); - for (var i = 0; i < window._uhr.themes.length; i++) { - var theme = window._uhr.themes[i]; + for (var i = 0; i < window.uhr.themes.length; i++) { + var theme = window.uhr.themes[i]; themeChooser.append(''); } e.after(themeChooser); } } }, - _wireFunctionality: function() { + _wireFunctionality: function () { var uhr = this; // on/off switch var toggleSwitch = $('#uhr-onoffswitch-checkbox' + this._id); - toggleSwitch.on('click', function() { + toggleSwitch.on('click', function () { uhr.toggle(); }); var status = $.cookie('uhr-status' + this._id); - if (status == undefined || this.options.force) { + if (status === undefined || this.options.force) { status = this.options.status; } - toggleSwitch.prop('checked', status == 'on'); - if (status == 'on') { + toggleSwitch.prop('checked', status === 'on'); + if (status === 'on') { this.start(); } else { this.stop(); @@ -273,25 +273,25 @@ along with this program. If not, see . // language chooser var languageChooser = $('#uhr-languagechooser' + this._id); - languageChooser.on('change', function() { + languageChooser.on('change', function () { uhr.language(this.value); }); var selectedLanguage = $.cookie('uhr-language' + this._id); - if (selectedLanguage == undefined || this.options.force) { + if (selectedLanguage === undefined || this.options.force) { selectedLanguage = this.options.language; } var found = false; - for (var i = 0; i < window._uhr.languages.length; i++) { - var code = window._uhr.languages[i].code; - if (selectedLanguage == code) { + for (var i = 0; i < window.uhr.languages.length; i++) { + var code = window.uhr.languages[i].code; + if (selectedLanguage === code) { found = true; break; } } if (!found) { var fallback; - if (window._uhr.languages.length > 0) { - fallback = window._uhr.languages[0].code; + if (window.uhr.languages.length > 0) { + fallback = window.uhr.languages[0].code; } else { fallback = ''; } @@ -304,23 +304,23 @@ along with this program. If not, see . // theme chooser var themeChooser = $('#uhr-themechooser' + this._id); - themeChooser.on('change', function() { + themeChooser.on('change', function () { uhr.theme(this.value); }); var selectedTheme = $.cookie('uhr-theme' + this._id); - if (selectedTheme == undefined || this.options.force) { + if (selectedTheme === undefined || this.options.force) { selectedTheme = this.options.theme; } found = false; - for (var i = 0; i < window._uhr.themes.length; i++) { - var styleClass = window._uhr.themes[i].styleClass; - if (selectedTheme == styleClass) { + for (var i = 0; i < window.uhr.themes.length; i++) { + var styleClass = window.uhr.themes[i].styleClass; + if (selectedTheme === styleClass) { found = true; break; } } if (!found) { - var fallback = window._uhr.themes[0].styleClass; + var fallback = window.uhr.themes[0].styleClass; console.warn("Theme " + selectedTheme + " not found! Using fallback: " + fallback); selectedTheme = fallback; } @@ -328,7 +328,7 @@ along with this program. If not, see . this.options.theme = ""; this.theme(selectedTheme); }, - _setCookie: function(cookieName, cookieValue) { + _setCookie: function (cookieName, cookieValue) { var options = {}; if (this.options.cookiePath !== undefined) { options = {expires: 365, path: this.options.cookiePath}; @@ -347,7 +347,7 @@ along with this program. If not, see . this.layout = layout; this.renderarea = renderarea; } - UhrRenderer.prototype.render = function(uhr, beforeshow) { + UhrRenderer.prototype.render = function (uhr, beforeshow) { var renderer = this; if (this.layout._parsed === undefined) { switch (this.layout.version) { @@ -361,7 +361,7 @@ along with this program. If not, see . } } var letters = this.layout._parsed; - this.renderarea.fadeOut('fast', function() { + this.renderarea.fadeOut('fast', function () { renderer.renderarea.empty(); for (var y = 0; y < letters.length; y++) { for (var x = 0; x < letters[y].length; x++) { @@ -380,7 +380,7 @@ along with this program. If not, see . }; function _UhrRendererV2Delegate(layout) { this.layout = layout; - this._parseArrayOrObject = function(letters, styleClass, input) { + this._parseArrayOrObject = function (letters, styleClass, input) { if (Array.isArray(input)) { for (var i = 0; i < input.length; i++) { this._parseObject(letters, styleClass, input[i]); diff --git a/jquery-2.1.0.min.js b/lib/jquery-2.1.0.min.js similarity index 100% rename from jquery-2.1.0.min.js rename to lib/jquery-2.1.0.min.js diff --git a/jquery-cookie-1.4.0.js b/lib/jquery-cookie-1.4.0.js similarity index 100% rename from jquery-cookie-1.4.0.js rename to lib/jquery-cookie-1.4.0.js diff --git a/jquery-ui-1.10.4.custom.min.js b/lib/jquery-ui-1.10.4.custom.min.js similarity index 100% rename from jquery-ui-1.10.4.custom.min.js rename to lib/jquery-ui-1.10.4.custom.min.js diff --git a/apple-touch-icon-precomposed.png b/resources/apple-touch-icon-precomposed.png similarity index 100% rename from apple-touch-icon-precomposed.png rename to resources/apple-touch-icon-precomposed.png diff --git a/favicon.png b/resources/favicon.png similarity index 100% rename from favicon.png rename to resources/favicon.png diff --git a/uhr.woff b/resources/uhr.woff similarity index 100% rename from uhr.woff rename to resources/uhr.woff diff --git a/showcase/index.html b/showcase/index.html index c18666e..77a7bd1 100644 --- a/showcase/index.html +++ b/showcase/index.html @@ -21,30 +21,30 @@ along with this program. If not, see . - - - - - - - - + + + + + + + + - - - - + + + +

Go back to the main page

- - - - - - + + + + + + + + + + + + + + +
+
+
+ + + \ No newline at end of file From 218a0f40e55c777ad869ede1b395d41b47d90e89 Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 3 Jul 2014 20:06:37 +0200 Subject: [PATCH 03/30] fixed the path to the font --- css/uhr.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css/uhr.css b/css/uhr.css index 45c84e4..7c90817 100644 --- a/css/uhr.css +++ b/css/uhr.css @@ -14,7 +14,7 @@ along with this program. If not, see . */ @font-face { font-family: 'Uhrenfont'; - src: url('uhr.woff') format('woff'); + src: url('../resources/uhr.woff') format('woff'); } body { font-family: 'Uhrenfont', sans-serif; From 7b0e77f16fbb0af0a49c1e1e984877cd00587c95 Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 3 Jul 2014 20:09:01 +0200 Subject: [PATCH 04/30] fixed syntax error. was probably introduced while refactoring --- js/uhr-de.js | 2 +- js/uhr-de_CH.js | 2 +- js/uhr-de_CH_genau.js | 2 +- js/uhr-en.js | 2 +- js/uhr-fr.js | 2 +- js/uhr-it.js | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/js/uhr-de.js b/js/uhr-de.js index 9d04411..cb01ab9 100644 --- a/js/uhr-de.js +++ b/js/uhr-de.js @@ -67,4 +67,4 @@ var layout = { "11,23": {5:[6,7,8]} } }; -window,uhr.register('de', layout); +window.uhr.register('de', layout); diff --git a/js/uhr-de_CH.js b/js/uhr-de_CH.js index c01523f..6afbf23 100644 --- a/js/uhr-de_CH.js +++ b/js/uhr-de_CH.js @@ -93,4 +93,4 @@ var layout = { } }; // Das Layout bei der Uhr unter dem Code "de_CH" registrieren. -window,uhr.register('de_CH', layout); +window.uhr.register('de_CH', layout); diff --git a/js/uhr-de_CH_genau.js b/js/uhr-de_CH_genau.js index 5ff9ec7..2f00090 100644 --- a/js/uhr-de_CH_genau.js +++ b/js/uhr-de_CH_genau.js @@ -68,4 +68,4 @@ var layout = { "11,23": {9:[8,9,10,11]} } }; -window,uhr.register('de_CH_genau', layout); +window.uhr.register('de_CH_genau', layout); diff --git a/js/uhr-en.js b/js/uhr-en.js index d271bc6..7fc5fd8 100644 --- a/js/uhr-en.js +++ b/js/uhr-en.js @@ -76,4 +76,4 @@ var layout = { return hour; } }; -window,uhr.register('en', layout); +window.uhr.register('en', layout); diff --git a/js/uhr-fr.js b/js/uhr-fr.js index 9ec0e51..c9fa8ab 100644 --- a/js/uhr-fr.js +++ b/js/uhr-fr.js @@ -78,4 +78,4 @@ var layout = { return hour; } }; -window,uhr.register('fr', layout); +window.uhr.register('fr', layout); diff --git a/js/uhr-it.js b/js/uhr-it.js index 267d2b2..0f26df0 100644 --- a/js/uhr-it.js +++ b/js/uhr-it.js @@ -75,4 +75,4 @@ var layout = { return hour; } }; -window,uhr.register('it', layout); +window.uhr.register('it', layout); From 5a9ec0e0df064157d4c57ff83aba089656333501 Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 3 Jul 2014 20:10:55 +0200 Subject: [PATCH 05/30] basically the whole thing is rewritten :) --- js/uhr.js | 619 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 320 insertions(+), 299 deletions(-) diff --git a/js/uhr.js b/js/uhr.js index 25bd705..8e9044c 100644 --- a/js/uhr.js +++ b/js/uhr.js @@ -18,34 +18,32 @@ along with this program. If not, see . "id": 0, "languages": [], "themes": [], - register: function register(code, language) { - this.languages.reduce(function(element) { + registerLanguage: function registerLanguage(code, language) { + var alreadyExists = this.languages.reduce(function (exists, element) { + if (exists) { + return true; + } if (code === element.code) { console.error("Error: Language code '" + code + "' cannot be registered for language '" + language.language + "' because it is already registered for language '" + element.language + "'!"); - return false; + return true; } - return true; - }, true); + return false; + }, false); + if (!alreadyExists) { + language.code = code; + this.languages.push(language); + } } }; - if (window.uhr !== undefined) { - return; - } + if (window.uhr !== undefined) { + return; + } window.uhr = { id: 0, languages: [], themes: [], - register: function (code, language) { - for (var i = 0; i < this.languages.length; i++) { - if (code === this.languages[i].code) { - console.error('Error: Language code ' + code + ' cannot be registered for language "' + language.language + '" because it is already registered for language "' + this.languages[i].language + '"!'); - return false; - } - } - language.code = code; - this.languages.push(language); - } + register: uhrGlobals.registerLanguage }; // auto-detect themes var styleSheets = $('link[rel=stylesheet]'); @@ -64,293 +62,316 @@ along with this program. If not, see . if (window.uhr.themes.length === 0) { window.uhr.themes.push({}); } - $.widget("fritteli.uhr", { - options: { - width: '100%', - status: 'on', - language: 'de_CH', - theme: window.uhr.themes[0].styleClass, - force: false, - controls: true - }, - start: function () { - if (!this._isOn()) { - var uhr = this; - this._timer = window.setInterval(function() { - uhr.options.time = new Date(); - uhr._update(); - }, 1000); - this._update(); - this._setCookie('uhr-status', 'on'); - } else { - } - }, - stop: function () { - if (this._isOn()) { - window.clearInterval(this._timer); - this._timer = null; - this._update(); - this._setCookie('uhr-status', 'off'); - } - }, - toggle: function () { - if (this._isOn()) { - this.stop(); - } else { - this.start(); - } - }, - language: function (languageKey) { - if (languageKey !== this.options.language) { - this.options.language = languageKey; - var renderer = new UhrRenderer(this._language(), this.element.find('.letterarea')); - var uhr = this; - renderer.render(this, function() { - uhr._currentMinute = -1; - uhr._update(); - }); - this._setCookie('uhr-language', languageKey); - this._update(); - } - }, - theme: function (theme) { - if (theme !== this.options.theme) { - this.element.removeClass(this.options.theme).addClass(theme); - $('#uhr-onoffswitch' + this._id).removeClass(this.options.theme).addClass(theme); - this.options.theme = theme; - this._setCookie('uhr-theme', theme); - } - }, - time: function (time) { - this._currentMinute = -1; - if (time === null) { - this.options.time = new Date(); - } else { - if (this._timer !== null) { - window.clearInterval(this._timer); - } - this.options.time = time; - } - this._update(); - }, - // private variables - _id: -1, - _timer: null, - _currentMinute: -1, - // private methods - _isOn: function () { - return this._timer !== null; - }, - _update: function () { - if (this._isOn()) { - var time = this.options.time; - if (time.getMinutes() === this._currentMinute) { - return; - } - this._currentMinute = time.getMinutes(); - this._show(time); - } else { - this._clear(); - this._currentMinute = -1; - } - }, - _show: function (time) { - var dotMinute = this._getDotMinute(time); - var hour = this._getHour(time); - var coarseMinute = this._getCoarseMinute(time); - this._clear(); - this._highlight('on'); - for (var i = 1; i <= dotMinute; i++) { - this._highlight('dot' + i); - } - this._highlight('minute' + coarseMinute); - this._highlight('hour' + hour); - }, - _language: function () { - for (var i = 0; i < window.uhr.languages.length; i++) { - var language = window.uhr.languages[i]; - if (language.code == this.options.language) { - return language; - } - } - // fallback: return empty object - return {}; - }, - _highlight: function (itemClass) { - this.element.find('.item.' + itemClass).addClass('active'); - }, - _clear: function () { - this.element.find('.item').removeClass('active'); - }, - _getHour: function (date) { - if (typeof this._language().getHour === 'function') { - return this._language().getHour(date); - } - var hour = date.getHours(); - if (date.getMinutes() >= 25) { - return (hour + 1) % 24; - } - return hour; - }, - _getCoarseMinute: function (date) { - if (typeof this._language().getCoarseMinute === 'function') { - return this._language().getCoarseMinute(date); - } - return date.getMinutes(); - }, - _getDotMinute: function (date) { - if (typeof this._language().getDotMinute === 'function') { - return this._language().getDotMinute(date); - } - var minutes = date.getMinutes(); - return minutes % 5; - }, - _create: function () { - this._id = window.uhr.id++; - var userTime = this.options.time; - if (this.options.time === undefined) { - this.options.time = new Date(); - } - this._setupHTML(); - this._wireFunctionality(); - if (userTime !== undefined) { - this.time(userTime); - } - }, - _setupHTML: function () { - var e = this.element; - // Base clock area - e.addClass('uhr'); - e.empty(); - e.append(''); - e.append(''); - e.append(''); - e.append(''); - e.append('
'); - e.append('
'); - e.css('width', this.options.width); - var realWidth = e.width(); - e.width(realWidth); - e.height(realWidth); - e.css('font-size', (realWidth / 40) + 'px'); - if (this.options.controls) { - // on/off switch - var toggleSwitch = $('
'); - toggleSwitch.append(''); - toggleSwitch.append(''); - e.after(toggleSwitch); + // public interface methods (exported later) + var start = function start() { + if (!isOn(this)) { + var uhr = this; + this._timer = window.setInterval(function uhrTimer() { + uhr.options.time = new Date(); + update(uhr); + }, 1000); + update(this); + setCookie(this, 'uhr-status', 'on'); + } + }; + var stop = function stop() { + if (isOn(this)) { + window.clearInterval(this._timer); + this._timer = null; + update(this); + setCookie(this, 'uhr-status', 'off'); + } + }; + var toggle = function toggle() { + if (isOn(this)) { + this.stop(); + } else { + this.start(); + } + }; + var setLanguage = function setLanugage(languageKey) { + if (languageKey !== this.options.language) { + this.options.language = languageKey; + var renderer = new UhrRenderer(language(this), this.element.find('.letterarea')); + var uhr = this; + renderer.render(this, function () { + uhr._currentMinute = -1; + update(uhr); + }); + setCookie(this, 'uhr-language', languageKey); + update(this); + } + }; + var setTheme = function setTheme(theme) { + if (theme !== this.options.theme) { + this.element.removeClass(this.options.theme).addClass(theme); + $('#uhr-onoffswitch' + this._id).removeClass(this.options.theme).addClass(theme); + this.options.theme = theme; + setCookie(this, 'uhr-theme', theme); + } + }; + var setTime = function setTime(time) { + this._currentMinute = -1; + if (time === null) { + this.options.time = new Date(); + } else { + if (this._timer !== null) { + window.clearInterval(this._timer); + } + this.options.time = time; + } + update(this); + }; - // language chooser - if (window.uhr.languages.length > 1) { - var languageChooser = $(''); - for (var i = 0; i < window.uhr.languages.length; i++) { - var language = window.uhr.languages[i]; - languageChooser.append(''); - } - e.after(languageChooser); - } + // private interface methods + var create = function create() { + this._id = window.uhr.id++; + var userTime = this.options.time; + if (this.options.time === undefined) { + this.options.time = new Date(); + } + setupHTML(this); + wireFunctionality(this); + if (userTime !== undefined) { + this.time(userTime); + } + }; + // private helper methods (not exported) + // set up + var setupHTML = function setupHTML(uhr) { + var e = uhr.element; + // Base clock area + e.addClass('uhr'); + e.empty(); + e.append(''); + e.append(''); + e.append(''); + e.append(''); + e.append('
'); + e.append('
'); + e.css('width', uhr.options.width); + var realWidth = e.width(); + e.width(realWidth); + e.height(realWidth); + e.css('font-size', (realWidth / 40) + 'px'); - // theme chooser - if (window.uhr.themes.length > 1) { - var themeChooser = $(''); - for (var i = 0; i < window.uhr.themes.length; i++) { - var theme = window.uhr.themes[i]; - themeChooser.append(''); - } - e.after(themeChooser); - } - } - }, - _wireFunctionality: function () { - var uhr = this; + if (uhr.options.controls) { + // on/off switch + var toggleSwitch = $('
'); + toggleSwitch.append(''); + toggleSwitch.append(''); + e.after(toggleSwitch); - // on/off switch - var toggleSwitch = $('#uhr-onoffswitch-checkbox' + this._id); - toggleSwitch.on('click', function () { - uhr.toggle(); - }); - var status = $.cookie('uhr-status' + this._id); - if (status === undefined || this.options.force) { - status = this.options.status; - } - toggleSwitch.prop('checked', status === 'on'); - if (status === 'on') { - this.start(); - } else { - this.stop(); - } + // language chooser + if (window.uhr.languages.length > 1) { + var languageChooser = $(''); + for (var i = 0; i < window.uhr.languages.length; i++) { + var language = window.uhr.languages[i]; + languageChooser.append(''); + } + e.after(languageChooser); + } - // language chooser - var languageChooser = $('#uhr-languagechooser' + this._id); - languageChooser.on('change', function () { - uhr.language(this.value); - }); - var selectedLanguage = $.cookie('uhr-language' + this._id); - if (selectedLanguage === undefined || this.options.force) { - selectedLanguage = this.options.language; - } - var found = false; - for (var i = 0; i < window.uhr.languages.length; i++) { - var code = window.uhr.languages[i].code; - if (selectedLanguage === code) { - found = true; - break; - } - } - if (!found) { - var fallback; - if (window.uhr.languages.length > 0) { - fallback = window.uhr.languages[0].code; - } else { - fallback = ''; - } - console.warn("Language " + selectedLanguage + " not found! Using fallback: " + fallback); - selectedLanguage = fallback; - } - languageChooser.val(selectedLanguage); - this.options.language = ""; - this.language(selectedLanguage); + // theme chooser + if (window.uhr.themes.length > 1) { + var themeChooser = $(''); + for (var i = 0; i < window.uhr.themes.length; i++) { + var theme = window.uhr.themes[i]; + themeChooser.append(''); + } + e.after(themeChooser); + } + } + }; + var wireFunctionality = function wireFunctionality(uhr) { - // theme chooser - var themeChooser = $('#uhr-themechooser' + this._id); - themeChooser.on('change', function () { - uhr.theme(this.value); - }); - var selectedTheme = $.cookie('uhr-theme' + this._id); - if (selectedTheme === undefined || this.options.force) { - selectedTheme = this.options.theme; - } - found = false; - for (var i = 0; i < window.uhr.themes.length; i++) { - var styleClass = window.uhr.themes[i].styleClass; - if (selectedTheme === styleClass) { - found = true; - break; - } - } - if (!found) { - var fallback = window.uhr.themes[0].styleClass; - console.warn("Theme " + selectedTheme + " not found! Using fallback: " + fallback); - selectedTheme = fallback; - } - themeChooser.val(selectedTheme); - this.options.theme = ""; - this.theme(selectedTheme); - }, - _setCookie: function (cookieName, cookieValue) { - var options = {}; - if (this.options.cookiePath !== undefined) { - options = {expires: 365, path: this.options.cookiePath}; - } else { - options = {expires: 365}; - } - $.cookie(cookieName + this._id, cookieValue, options); - } - }); + // on/off switch + var toggleSwitch = $('#uhr-onoffswitch-checkbox' + uhr._id); + toggleSwitch.on('click', function () { + uhr.toggle(); + }); + var status = $.cookie('uhr-status' + uhr._id); + if (status === undefined || uhr.options.force) { + status = uhr.options.status; + } + toggleSwitch.prop('checked', status === 'on'); + if (status === 'on') { + uhr.start(); + } else { + uhr.stop(); + } + + // language chooser + var languageChooser = $('#uhr-languagechooser' + uhr._id); + languageChooser.on('change', function () { + uhr.language(this.value); + }); + var selectedLanguage = $.cookie('uhr-language' + uhr._id); + if (selectedLanguage === undefined || uhr.options.force) { + selectedLanguage = uhr.options.language; + } + var found = false; + for (var i = 0; i < window.uhr.languages.length; i++) { + var code = window.uhr.languages[i].code; + if (selectedLanguage === code) { + found = true; + break; + } + } + if (!found) { + var fallback; + if (window.uhr.languages.length > 0) { + fallback = window.uhr.languages[0].code; + } else { + fallback = ''; + } + console.warn("Language " + selectedLanguage + " not found! Using fallback: " + fallback); + selectedLanguage = fallback; + } + languageChooser.val(selectedLanguage); + uhr.options.language = ""; + uhr.language(selectedLanguage); + + // theme chooser + var themeChooser = $('#uhr-themechooser' + uhr._id); + themeChooser.on('change', function () { + uhr.theme(this.value); + }); + var selectedTheme = $.cookie('uhr-theme' + uhr._id); + if (selectedTheme === undefined || uhr.options.force) { + selectedTheme = uhr.options.theme; + } + found = false; + for (var i = 0; i < window.uhr.themes.length; i++) { + var styleClass = window.uhr.themes[i].styleClass; + if (selectedTheme === styleClass) { + found = true; + break; + } + } + if (!found) { + var fallback = window.uhr.themes[0].styleClass; + console.warn("Theme " + selectedTheme + " not found! Using fallback: " + fallback); + selectedTheme = fallback; + } + themeChooser.val(selectedTheme); + uhr.options.theme = ""; + uhr.theme(selectedTheme); + }; + var setCookie = function setCookie(uhr, cookieName, cookieValue) { + var options = {}; + if (uhr.options.cookiePath !== undefined) { + options = {expires: 365, path: uhr.options.cookiePath}; + } else { + options = {expires: 365}; + } + $.cookie(cookieName + uhr._id, cookieValue, options); + }; + + // business logic + var isOn = function isOn(uhr) { + return uhr._timer !== null; + }; + var update = function update(uhr) { + if (isOn(uhr)) { + var time = uhr.options.time; + if (time.getMinutes() === uhr._currentMinute) { + return; + } + uhr._currentMinute = time.getMinutes(); + show(uhr, time); + } else { + clear(uhr); + uhr._currentMinute = -1; + } + }; + var show = function show(uhr, time) { + var dotMinute = getDotMinute(uhr, time); + var hour = getHour(uhr, time); + var coarseMinute = getCoarseMinute(uhr, time); + clear(uhr); + highlight(uhr, 'on'); + for (var i = 1; i <= dotMinute; i++) { + highlight(uhr, 'dot' + i); + } + highlight(uhr, 'minute' + coarseMinute); + highlight(uhr, 'hour' + hour); + }; + var highlight = function highlight(uhr, itemClass) { + uhr.element.find('.item.' + itemClass).addClass('active'); + }; + var clear = function clear(uhr) { + uhr.element.find('.item').removeClass('active'); + }; + var getDotMinute = function getDotMinute(uhr, date) { + if (typeof language(uhr).getDotMinute === 'function') { + return language(uhr).getDotMinute(date); + } + var minutes = date.getMinutes(); + return minutes % 5; + }; + var getCoarseMinute = function getCoarseMinute(uhr, date) { + if (typeof language(uhr).getCoarseMinute === 'function') { + return language(uhr).getCoarseMinute(date); + } + return date.getMinutes(); + }; + var getHour = function getHour(uhr, date) { + if (typeof language(uhr).getHour === 'function') { + return language(uhr).getHour(date); + } + var hour = date.getHours(); + if (date.getMinutes() >= 25) { + return (hour + 1) % 24; + } + return hour; + }; + + var language = function language(uhr) { + var matchingLanguages = window.uhr.languages.filter(function (element) { + return (element.code === this.options.language) + }, uhr); + if (matchingLanguages.length > 0) { + return matchingLanguages[0]; + } + // fallback: return empty object + return {}; +/* for (var i = 0; i < window.uhr.languages.length; i++) { + var language = window.uhr.languages[i]; + if (language.code == uhr.options.language) { + return language; + } + } + // fallback: return empty object + return {};*/ + }; + + $.widget("fritteli.uhr", { + "options": { + width: '100%', + status: 'on', + language: 'de_CH', + theme: window.uhr.themes[0].styleClass, + force: false, + controls: true + }, + "start": start, + "stop": stop, + "toggle": toggle, + "language": setLanguage, + "theme": setTheme, + "time": setTime, + // constructor method + "_create": create, + // private variables + "_id": -1, + "_timer": null, + "_currentMinute": -1 + }); /** * Hilfsklasse zum Rendern der Uhr. * @param layout Layout-Objekt, das gerendert werden soll. From 85b5670dfcf6af9586c8c1e46f5a7960bd556db1 Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 3 Jul 2014 20:33:26 +0200 Subject: [PATCH 06/30] removed the window.uhr global variable! hooray! --- js/uhr-de.js | 3 ++- js/uhr-de_CH.js | 3 ++- js/uhr-de_CH_genau.js | 3 ++- js/uhr-en.js | 3 ++- js/uhr-fr.js | 3 ++- js/uhr-it.js | 3 ++- js/uhr.js | 60 ++++++++++++++++--------------------------- test/test.html | 11 ++++++-- 8 files changed, 43 insertions(+), 46 deletions(-) diff --git a/js/uhr-de.js b/js/uhr-de.js index cb01ab9..0975ff3 100644 --- a/js/uhr-de.js +++ b/js/uhr-de.js @@ -12,6 +12,7 @@ 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 . */ +'use strict'; var h = { "_es_ist": {1:[1,2,4,5,6]}, "_nach": {4:[8,9,10,11]}, @@ -67,4 +68,4 @@ var layout = { "11,23": {5:[6,7,8]} } }; -window.uhr.register('de', layout); +$.fritteli.uhr.register('de', layout); diff --git a/js/uhr-de_CH.js b/js/uhr-de_CH.js index 6afbf23..30a4245 100644 --- a/js/uhr-de_CH.js +++ b/js/uhr-de_CH.js @@ -12,6 +12,7 @@ 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 . */ +'use strict'; // hilfsvariablen var h = { "_es_isch": {1:[1,2,4,5,6,7]}, @@ -93,4 +94,4 @@ var layout = { } }; // Das Layout bei der Uhr unter dem Code "de_CH" registrieren. -window.uhr.register('de_CH', layout); +$.fritteli.uhr.register('de_CH', layout); diff --git a/js/uhr-de_CH_genau.js b/js/uhr-de_CH_genau.js index 2f00090..f21dfed 100644 --- a/js/uhr-de_CH_genau.js +++ b/js/uhr-de_CH_genau.js @@ -12,6 +12,7 @@ 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 . */ +'use strict'; var h = { "_es_isch": {1:[1,2,4,5,6,7]}, "_genau": {3:[7,8,9,10,11]}, @@ -68,4 +69,4 @@ var layout = { "11,23": {9:[8,9,10,11]} } }; -window.uhr.register('de_CH_genau', layout); +$.fritteli.uhr.register('de_CH_genau', layout); diff --git a/js/uhr-en.js b/js/uhr-en.js index 7fc5fd8..e1d422e 100644 --- a/js/uhr-en.js +++ b/js/uhr-en.js @@ -12,6 +12,7 @@ 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 . */ +'use strict'; var h = { "_it_is": {1:[1,2,4,5]}, "_half": {4:[1,2,3,4]}, @@ -76,4 +77,4 @@ var layout = { return hour; } }; -window.uhr.register('en', layout); +$.fritteli.uhr.register('en', layout); diff --git a/js/uhr-fr.js b/js/uhr-fr.js index c9fa8ab..14e9be1 100644 --- a/js/uhr-fr.js +++ b/js/uhr-fr.js @@ -13,6 +13,7 @@ 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 . */ +'use strict'; var h = { "_il_est": {1:[1,2,4,5,6]}, "_et": {8:[1,2]}, @@ -78,4 +79,4 @@ var layout = { return hour; } }; -window.uhr.register('fr', layout); +$.fritteli.uhr.register('fr', layout); diff --git a/js/uhr-it.js b/js/uhr-it.js index 0f26df0..29dee3e 100644 --- a/js/uhr-it.js +++ b/js/uhr-it.js @@ -12,6 +12,7 @@ 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 . */ +'use strict'; var h = { "_sono_le": {1:[1,2,3,4,6,7]}, "_e_l": {2:[1,3,4]}, @@ -75,4 +76,4 @@ var layout = { return hour; } }; -window.uhr.register('it', layout); +$.fritteli.uhr.register('it', layout); diff --git a/js/uhr.js b/js/uhr.js index 8e9044c..20a6485 100644 --- a/js/uhr.js +++ b/js/uhr.js @@ -19,7 +19,7 @@ along with this program. If not, see . "languages": [], "themes": [], registerLanguage: function registerLanguage(code, language) { - var alreadyExists = this.languages.reduce(function (exists, element) { + var alreadyExists = uhrGlobals.languages.reduce(function (exists, element) { if (exists) { return true; } @@ -31,20 +31,11 @@ along with this program. If not, see . }, false); if (!alreadyExists) { language.code = code; - this.languages.push(language); + uhrGlobals.languages.push(language); } } }; - if (window.uhr !== undefined) { - return; - } - window.uhr = { - id: 0, - languages: [], - themes: [], - register: uhrGlobals.registerLanguage - }; // auto-detect themes var styleSheets = $('link[rel=stylesheet]'); for (var i = 0; i < styleSheets.length; i++) { @@ -55,12 +46,12 @@ along with this program. If not, see . if (name === undefined) { name = styleClass; } - window.uhr.themes.push({'styleClass': styleClass, 'name': name}); + uhrGlobals.themes.push({'styleClass': styleClass, 'name': name}); } } // fall-back if no theme was included - if (window.uhr.themes.length === 0) { - window.uhr.themes.push({}); + if (uhrGlobals.themes.length === 0) { + uhrGlobals.themes.push({}); } // public interface methods (exported later) @@ -126,7 +117,7 @@ along with this program. If not, see . // private interface methods var create = function create() { - this._id = window.uhr.id++; + this._id = uhrGlobals.id++; var userTime = this.options.time; if (this.options.time === undefined) { this.options.time = new Date(); @@ -167,20 +158,20 @@ along with this program. If not, see . e.after(toggleSwitch); // language chooser - if (window.uhr.languages.length > 1) { + if (uhrGlobals.languages.length > 1) { var languageChooser = $(''); - for (var i = 0; i < window.uhr.languages.length; i++) { - var language = window.uhr.languages[i]; + for (var i = 0; i < uhrGlobals.languages.length; i++) { + var language = uhrGlobals.languages[i]; languageChooser.append(''); } e.after(languageChooser); } // theme chooser - if (window.uhr.themes.length > 1) { + if (uhrGlobals.themes.length > 1) { var themeChooser = $(''); - for (var i = 0; i < window.uhr.themes.length; i++) { - var theme = window.uhr.themes[i]; + for (var i = 0; i < uhrGlobals.themes.length; i++) { + var theme = uhrGlobals.themes[i]; themeChooser.append(''); } e.after(themeChooser); @@ -215,8 +206,8 @@ along with this program. If not, see . selectedLanguage = uhr.options.language; } var found = false; - for (var i = 0; i < window.uhr.languages.length; i++) { - var code = window.uhr.languages[i].code; + for (var i = 0; i < uhrGlobals.languages.length; i++) { + var code = uhrGlobals.languages[i].code; if (selectedLanguage === code) { found = true; break; @@ -224,8 +215,8 @@ along with this program. If not, see . } if (!found) { var fallback; - if (window.uhr.languages.length > 0) { - fallback = window.uhr.languages[0].code; + if (uhrGlobals.languages.length > 0) { + fallback = uhrGlobals.languages[0].code; } else { fallback = ''; } @@ -246,15 +237,15 @@ along with this program. If not, see . selectedTheme = uhr.options.theme; } found = false; - for (var i = 0; i < window.uhr.themes.length; i++) { - var styleClass = window.uhr.themes[i].styleClass; + for (var i = 0; i < uhrGlobals.themes.length; i++) { + var styleClass = uhrGlobals.themes[i].styleClass; if (selectedTheme === styleClass) { found = true; break; } } if (!found) { - var fallback = window.uhr.themes[0].styleClass; + var fallback = uhrGlobals.themes[0].styleClass; console.warn("Theme " + selectedTheme + " not found! Using fallback: " + fallback); selectedTheme = fallback; } @@ -332,7 +323,7 @@ along with this program. If not, see . }; var language = function language(uhr) { - var matchingLanguages = window.uhr.languages.filter(function (element) { + var matchingLanguages = uhrGlobals.languages.filter(function (element) { return (element.code === this.options.language) }, uhr); if (matchingLanguages.length > 0) { @@ -340,14 +331,6 @@ along with this program. If not, see . } // fallback: return empty object return {}; -/* for (var i = 0; i < window.uhr.languages.length; i++) { - var language = window.uhr.languages[i]; - if (language.code == uhr.options.language) { - return language; - } - } - // fallback: return empty object - return {};*/ }; $.widget("fritteli.uhr", { @@ -355,7 +338,7 @@ along with this program. If not, see . width: '100%', status: 'on', language: 'de_CH', - theme: window.uhr.themes[0].styleClass, + theme: uhrGlobals.themes[0].styleClass, force: false, controls: true }, @@ -372,6 +355,7 @@ along with this program. If not, see . "_timer": null, "_currentMinute": -1 }); + $.fritteli.uhr.register = uhrGlobals.registerLanguage; /** * Hilfsklasse zum Rendern der Uhr. * @param layout Layout-Objekt, das gerendert werden soll. diff --git a/test/test.html b/test/test.html index 74b56da..8b3df81 100644 --- a/test/test.html +++ b/test/test.html @@ -5,8 +5,12 @@ Test - + + + + + @@ -14,6 +18,9 @@ + + +
@@ -21,7 +28,7 @@
From 3d0245abfabfd69423397a859a3d51d3e6f78677 Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 3 Jul 2014 20:37:34 +0200 Subject: [PATCH 07/30] wrap the layout definitions in immediately executing anonymous functions --- js/uhr-de.js | 116 +++++++++++++++-------------- js/uhr-de_CH.js | 164 ++++++++++++++++++++-------------------- js/uhr-de_CH_genau.js | 118 ++++++++++++++--------------- js/uhr-en.js | 134 ++++++++++++++++----------------- js/uhr-fr.js | 169 +++++++++++++++++++++++++----------------- js/uhr-it.js | 132 +++++++++++++++++---------------- js/uhr.js | 2 +- 7 files changed, 440 insertions(+), 395 deletions(-) diff --git a/js/uhr-de.js b/js/uhr-de.js index 0975ff3..c75a487 100644 --- a/js/uhr-de.js +++ b/js/uhr-de.js @@ -12,60 +12,62 @@ 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 . */ -'use strict'; -var h = { - "_es_ist": {1:[1,2,4,5,6]}, - "_nach": {4:[8,9,10,11]}, - "_vor": {4:[1,2,3]}, - "_halb": {5:[1,2,3,4]}, - "_5": {1:[8,9,10,11]}, - "_10": {2:[1,2,3,4]}, - "_15": {3:[5,6,7,8,9,10,11]}, - "_20": {2:[5,6,7,8,9,10,11]}, - "_45": {3:[1,2,3,4,5,6,7,8,9,10,11]} -}; -var layout = { - "version": 2, - "language": 'Deutsch', - "letters": [ - 'ESKISTAFÜNF', - 'ZEHNZWANZIG', - 'DREIVIERTEL', - 'VORFUNKNACH', - 'HALBAELFÜNF', - 'EINSXAMZWEI', - 'DREIPMJVIER', - 'SECHSNLACHT', - 'SIEBENZWÖLF', - 'ZEHNEUNKUHR' - ], - "permanent": h._es_ist, - "minutes": { - "5,6,7,8,9": [h._5, h._nach], - "10,11,12,13,14": [h._10, h._nach], - "15,16,17,18,19": [h._15, h._nach], - "20,21,22,23,24": [h._20, h._nach], - "25,26,27,28,29": [h._5, h._vor, h._halb], - "30,31,32,33,34": h._halb, - "35,36,37,38,39": [h._5, h._nach, h._halb], - "40,41,42,43,44": [h._20, h._vor], - "45,46,47,48,49": h._45, - "50,51,52,53,54": [h._10, h._vor], - "55,56,57,58,59": [h._5, h._vor] - }, - "hours": { - "0,12": {9:[7,8,9,10,11]}, - "1,13": {6:[1,2,3,4]}, - "2,14": {6:[8,9,10,11]}, - "3,15": {7:[1,2,3,4]}, - "4,16": {7:[8,9,10,11]}, - "5,17": {5:[8,9,10,11]}, - "6,18": {8:[1,2,3,4,5]}, - "7,19": {9:[1,2,3,4,5,6]}, - "8,20": {8:[8,9,10,11]}, - "9,21": {10:[4,5,6,7]}, - "10,22": {10:[1,2,3,4]}, - "11,23": {5:[6,7,8]} - } -}; -$.fritteli.uhr.register('de', layout); +(function () { + 'use strict'; + var h = { + "_es_ist": {1:[1,2,4,5,6]}, + "_nach": {4:[8,9,10,11]}, + "_vor": {4:[1,2,3]}, + "_halb": {5:[1,2,3,4]}, + "_5": {1:[8,9,10,11]}, + "_10": {2:[1,2,3,4]}, + "_15": {3:[5,6,7,8,9,10,11]}, + "_20": {2:[5,6,7,8,9,10,11]}, + "_45": {3:[1,2,3,4,5,6,7,8,9,10,11]} + }; + var layout = { + "version": 2, + "language": 'Deutsch', + "letters": [ + 'ESKISTAFÜNF', + 'ZEHNZWANZIG', + 'DREIVIERTEL', + 'VORFUNKNACH', + 'HALBAELFÜNF', + 'EINSXAMZWEI', + 'DREIPMJVIER', + 'SECHSNLACHT', + 'SIEBENZWÖLF', + 'ZEHNEUNKUHR' + ], + "permanent": h._es_ist, + "minutes": { + "5,6,7,8,9": [h._5, h._nach], + "10,11,12,13,14": [h._10, h._nach], + "15,16,17,18,19": [h._15, h._nach], + "20,21,22,23,24": [h._20, h._nach], + "25,26,27,28,29": [h._5, h._vor, h._halb], + "30,31,32,33,34": h._halb, + "35,36,37,38,39": [h._5, h._nach, h._halb], + "40,41,42,43,44": [h._20, h._vor], + "45,46,47,48,49": h._45, + "50,51,52,53,54": [h._10, h._vor], + "55,56,57,58,59": [h._5, h._vor] + }, + "hours": { + "0,12": {9:[7,8,9,10,11]}, + "1,13": {6:[1,2,3,4]}, + "2,14": {6:[8,9,10,11]}, + "3,15": {7:[1,2,3,4]}, + "4,16": {7:[8,9,10,11]}, + "5,17": {5:[8,9,10,11]}, + "6,18": {8:[1,2,3,4,5]}, + "7,19": {9:[1,2,3,4,5,6]}, + "8,20": {8:[8,9,10,11]}, + "9,21": {10:[4,5,6,7]}, + "10,22": {10:[1,2,3,4]}, + "11,23": {5:[6,7,8]} + } + }; + $.fritteli.uhr.register('de', layout); +}()); \ No newline at end of file diff --git a/js/uhr-de_CH.js b/js/uhr-de_CH.js index 30a4245..2f80062 100644 --- a/js/uhr-de_CH.js +++ b/js/uhr-de_CH.js @@ -12,86 +12,88 @@ 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 . */ -'use strict'; +(function () { + 'use strict'; // hilfsvariablen -var h = { - "_es_isch": {1:[1,2,4,5,6,7]}, - "_ab": {4:[1,2]}, - "_vor": {3:[9,10,11]}, - "_haubi": {4:[4,5,6,7,8]}, - "_5": {1:[9,10,11]}, - "_10": {2:[9,10,11]}, - "_15": {2:[1,2,3,4,5,6]}, - "_20": {3:[1,2,3,4,5,6]} -}; -var layout = { - // version: zur Zeit immer 2 (Pflichtattribut) - "version": 2, - // Sprechender Name der Sprache - "language": 'Bärndütsch', - // Buchstabenfeld als Array von Strings. - "letters": [ - 'ESKISCHAFÜF', - 'VIERTUBFZÄÄ', - 'ZWÄNZGSIVOR', - 'ABOHAUBIEGE', - 'EISZWÖISDRÜ', - 'VIERIFÜFIQT', - 'SÄCHSISIBNI', - 'ACHTINÜNIEL', - 'ZÄNIERBEUFI', - 'ZWÖUFINAUHR' - ], - // Permanent aktive Buchstaben. , vgl. ausführliche Beschreibung bei "minutes". - "permanent": h._es_isch, - /* - * Minuten: Objekt im folgenden Format: - * { - * : , - * ... - * } - * : String von Komma-separierten Minutenwerten, zu welchem die in angegebenen Buchstaben aktiv sein sollen - * : [ , ...] | - * : { : [ , ... ] } - * : Die Zeile, in welcher die Buchstaben liegen; von oben gezählt, oben ist 1. - * : Die Spalte, in der ein einzelner Buchstabe liegt; von links gezählt, links ist 1. - * Beispiel: - * "minutes": { - * "0,1": {1: [6, 7, 9]}, - * "5": [ {3: [1, 2]}, {4: [10, 11]} ] - * } - * Erklärung: - * Bei Minuten 0 und 1 sind die Buchstaben 6, 7 und 9 der ersten Zeile aktiv. - * Bei Minute 5 sind die Buchstaben 1 und 2 der Zeile 3 sowie die Buchstaben 10 und 11 der Zeile 4 aktiv. - */ - "minutes": { - "5,6,7,8,9": [h._5, h._ab], - "10,11,12,13,14": [h._10, h._ab], - "15,16,17,18,19": [h._15, h._ab], - "20,21,22,23,24": [h._20, h._ab], - "25,26,27,28,29": [h._5, h._vor, h._haubi], - "30,31,32,33,34": h._haubi, - "35,36,37,38,39": [h._5, h._ab, h._haubi], - "40,41,42,43,44": [h._20, h._vor], - "45,46,47,48,49": [h._15, h._vor], - "50,51,52,53,54": [h._10, h._vor], - "55,56,57,58,59": [h._5, h._vor] - }, - // Die Stunden; gleiches Format wie bei den Minuten - "hours": { - "0,12": {10:[1,2,3,4,5,6]}, - "1,13": {5:[1,2,3]}, - "2,14": {5:[4,5,6,7]}, - "3,15": {5:[9,10,11]}, - "4,16": {6:[1,2,3,4,5]}, - "5,17": {6:[6,7,8,9]}, - "6,18": {7:[1,2,3,4,5,6]}, - "7,19": {7:[7,8,9,10,11]}, - "8,20": {8:[1,2,3,4,5]}, - "9,21": {8:[6,7,8,9]}, - "10,22": {9:[1,2,3,4]}, - "11,23": {9:[8,9,10,11]} - } -}; + var h = { + "_es_isch": {1: [1, 2, 4, 5, 6, 7]}, + "_ab": {4: [1, 2]}, + "_vor": {3: [9, 10, 11]}, + "_haubi": {4: [4, 5, 6, 7, 8]}, + "_5": {1: [9, 10, 11]}, + "_10": {2: [9, 10, 11]}, + "_15": {2: [1, 2, 3, 4, 5, 6]}, + "_20": {3: [1, 2, 3, 4, 5, 6]} + }; + var layout = { + // version: zur Zeit immer 2 (Pflichtattribut) + "version": 2, + // Sprechender Name der Sprache + "language": 'Bärndütsch', + // Buchstabenfeld als Array von Strings. + "letters": [ + 'ESKISCHAFÜF', + 'VIERTUBFZÄÄ', + 'ZWÄNZGSIVOR', + 'ABOHAUBIEGE', + 'EISZWÖISDRÜ', + 'VIERIFÜFIQT', + 'SÄCHSISIBNI', + 'ACHTINÜNIEL', + 'ZÄNIERBEUFI', + 'ZWÖUFINAUHR' + ], + // Permanent aktive Buchstaben. , vgl. ausführliche Beschreibung bei "minutes". + "permanent": h._es_isch, + /* + * Minuten: Objekt im folgenden Format: + * { + * : , + * ... + * } + * : String von Komma-separierten Minutenwerten, zu welchem die in angegebenen Buchstaben aktiv sein sollen + * : [ , ...] | + * : { : [ , ... ] } + * : Die Zeile, in welcher die Buchstaben liegen; von oben gezählt, oben ist 1. + * : Die Spalte, in der ein einzelner Buchstabe liegt; von links gezählt, links ist 1. + * Beispiel: + * "minutes": { + * "0,1": {1: [6, 7, 9]}, + * "5": [ {3: [1, 2]}, {4: [10, 11]} ] + * } + * Erklärung: + * Bei Minuten 0 und 1 sind die Buchstaben 6, 7 und 9 der ersten Zeile aktiv. + * Bei Minute 5 sind die Buchstaben 1 und 2 der Zeile 3 sowie die Buchstaben 10 und 11 der Zeile 4 aktiv. + */ + "minutes": { + "5,6,7,8,9": [h._5, h._ab], + "10,11,12,13,14": [h._10, h._ab], + "15,16,17,18,19": [h._15, h._ab], + "20,21,22,23,24": [h._20, h._ab], + "25,26,27,28,29": [h._5, h._vor, h._haubi], + "30,31,32,33,34": h._haubi, + "35,36,37,38,39": [h._5, h._ab, h._haubi], + "40,41,42,43,44": [h._20, h._vor], + "45,46,47,48,49": [h._15, h._vor], + "50,51,52,53,54": [h._10, h._vor], + "55,56,57,58,59": [h._5, h._vor] + }, + // Die Stunden; gleiches Format wie bei den Minuten + "hours": { + "0,12": {10: [1, 2, 3, 4, 5, 6]}, + "1,13": {5: [1, 2, 3]}, + "2,14": {5: [4, 5, 6, 7]}, + "3,15": {5: [9, 10, 11]}, + "4,16": {6: [1, 2, 3, 4, 5]}, + "5,17": {6: [6, 7, 8, 9]}, + "6,18": {7: [1, 2, 3, 4, 5, 6]}, + "7,19": {7: [7, 8, 9, 10, 11]}, + "8,20": {8: [1, 2, 3, 4, 5]}, + "9,21": {8: [6, 7, 8, 9]}, + "10,22": {9: [1, 2, 3, 4]}, + "11,23": {9: [8, 9, 10, 11]} + } + }; // Das Layout bei der Uhr unter dem Code "de_CH" registrieren. -$.fritteli.uhr.register('de_CH', layout); + $.fritteli.uhr.register('de_CH', layout); +}()); \ No newline at end of file diff --git a/js/uhr-de_CH_genau.js b/js/uhr-de_CH_genau.js index f21dfed..9d45598 100644 --- a/js/uhr-de_CH_genau.js +++ b/js/uhr-de_CH_genau.js @@ -12,61 +12,63 @@ 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 . */ -'use strict'; -var h = { - "_es_isch": {1:[1,2,4,5,6,7]}, - "_genau": {3:[7,8,9,10,11]}, - "_ab": {4:[4,5]}, - "_vor": {4:[1,2,3]}, - "_haubi": {4:[7,8,9,10,11]}, - "_5": {1:[9,10,11]}, - "_10": {2:[9,10,11]}, - "_15": {2:[1,2,3,4,5,6]}, - "_20": {3:[1,2,3,4,5,6]} -}; -var layout = { - "version": 2, - "language": 'Bärndütsch (genau)', - "letters": [ - 'ESKISCHAFÜF', - 'VIERTUBFZÄÄ', - 'ZWÄNZGGENAU', - 'VORABOHAUBI', - 'EISZWÖISDRÜ', - 'VIERIFÜFIQT', - 'SÄCHSISIBNI', - 'ACHTINÜNIEL', - 'ZÄNIERBEUFI', - 'ZWÖUFINAUHR' - ], - "permanent": h._es_isch, - "minutes": { - "0": h._genau, - "5,6,7,8,9": [h._5, h._ab], - "10,11,12,13,14": [h._10, h._ab], - "15,16,17,18,19": [h._15, h._ab], - "20,21,22,23,24": [h._20, h._ab], - "25,26,27,28,29": [h._5, h._vor, h._haubi], - "30,31,32,33,34": h._haubi, - "35,36,37,38,39": [h._5, h._ab, h._haubi], - "40,41,42,43,44": [h._20, h._vor], - "45,46,47,48,49": [h._15, h._vor], - "50,51,52,53,54": [h._10, h._vor], - "55,56,57,58,59": [h._5, h._vor] - }, - "hours": { - "0,12": {10:[1,2,3,4,5,6]}, - "1,13": {5:[1,2,3]}, - "2,14": {5:[4,5,6,7]}, - "3,15": {5:[9,10,11]}, - "4,16": {6:[1,2,3,4,5]}, - "5,17": {6:[6,7,8,9]}, - "6,18": {7:[1,2,3,4,5,6]}, - "7,19": {7:[7,8,9,10,11]}, - "8,20": {8:[1,2,3,4,5]}, - "9,21": {8:[6,7,8,9]}, - "10,22": {9:[1,2,3,4]}, - "11,23": {9:[8,9,10,11]} - } -}; -$.fritteli.uhr.register('de_CH_genau', layout); +(function () { + 'use strict'; + var h = { + "_es_isch": {1: [1, 2, 4, 5, 6, 7]}, + "_genau": {3: [7, 8, 9, 10, 11]}, + "_ab": {4: [4, 5]}, + "_vor": {4: [1, 2, 3]}, + "_haubi": {4: [7, 8, 9, 10, 11]}, + "_5": {1: [9, 10, 11]}, + "_10": {2: [9, 10, 11]}, + "_15": {2: [1, 2, 3, 4, 5, 6]}, + "_20": {3: [1, 2, 3, 4, 5, 6]} + }; + var layout = { + "version": 2, + "language": 'Bärndütsch (genau)', + "letters": [ + 'ESKISCHAFÜF', + 'VIERTUBFZÄÄ', + 'ZWÄNZGGENAU', + 'VORABOHAUBI', + 'EISZWÖISDRÜ', + 'VIERIFÜFIQT', + 'SÄCHSISIBNI', + 'ACHTINÜNIEL', + 'ZÄNIERBEUFI', + 'ZWÖUFINAUHR' + ], + "permanent": h._es_isch, + "minutes": { + "0": h._genau, + "5,6,7,8,9": [h._5, h._ab], + "10,11,12,13,14": [h._10, h._ab], + "15,16,17,18,19": [h._15, h._ab], + "20,21,22,23,24": [h._20, h._ab], + "25,26,27,28,29": [h._5, h._vor, h._haubi], + "30,31,32,33,34": h._haubi, + "35,36,37,38,39": [h._5, h._ab, h._haubi], + "40,41,42,43,44": [h._20, h._vor], + "45,46,47,48,49": [h._15, h._vor], + "50,51,52,53,54": [h._10, h._vor], + "55,56,57,58,59": [h._5, h._vor] + }, + "hours": { + "0,12": {10: [1, 2, 3, 4, 5, 6]}, + "1,13": {5: [1, 2, 3]}, + "2,14": {5: [4, 5, 6, 7]}, + "3,15": {5: [9, 10, 11]}, + "4,16": {6: [1, 2, 3, 4, 5]}, + "5,17": {6: [6, 7, 8, 9]}, + "6,18": {7: [1, 2, 3, 4, 5, 6]}, + "7,19": {7: [7, 8, 9, 10, 11]}, + "8,20": {8: [1, 2, 3, 4, 5]}, + "9,21": {8: [6, 7, 8, 9]}, + "10,22": {9: [1, 2, 3, 4]}, + "11,23": {9: [8, 9, 10, 11]} + } + }; + $.fritteli.uhr.register('de_CH_genau', layout); +}()); \ No newline at end of file diff --git a/js/uhr-en.js b/js/uhr-en.js index e1d422e..d88a7db 100644 --- a/js/uhr-en.js +++ b/js/uhr-en.js @@ -12,69 +12,71 @@ 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 . */ -'use strict'; -var h = { - "_it_is": {1:[1,2,4,5]}, - "_half": {4:[1,2,3,4]}, - "_to": {4:[10,11]}, - "_past": {5:[1,2,3,4]}, - "_o_clock": {10:[6,7,8,9,10,11]}, - "_5": {3:[7,8,9,10]}, - "_10": {4:[6,7,8]}, - "_15": {2:[1,3,4,5,6,7,8,9]}, - "_20": {3:[1,2,3,4,5,6]}, - "_25": {3:[1,2,3,4,5,6,7,8,9,10]} -}; -var layout = { - "version": 2, - "language": 'English', - "letters": [ - 'ITLISBFAMPM', - 'ACQUARTERDC', - 'TWENTYFIVEX', - 'HALFBTENFTO', - 'PASTERUNINE', - 'ONESIXTHREE', - 'FOURFIVETWO', - 'EIGHTELEVEN', - 'SEVENTWELVE', - 'TENSEOCLOCK' - ], - "permanent": h._it_is, - "minutes": { - "0,1,2,3,4": h._o_clock, - "5,6,7,8,9": [h._5, h._past], - "10,11,12,13,14": [h._10, h._past], - "15,16,17,18,19": [h._15, h._past], - "20,21,22,23,24": [h._20, h._past], - "25,26,27,28,29": [h._25, h._past], - "30,31,32,33,34": [h._half, h._past], - "35,36,37,38,39": [h._25, h._to], - "40,41,42,43,44": [h._20, h._to], - "45,46,47,48,49": [h._15, h._to], - "50,51,52,53,54": [h._10, h._to], - "55,56,57,58,59": [h._5, h._to] - }, - "hours": { - "0,12": {9:[6,7,8,9,10,11]}, - "1,13": {6:[1,2,3]}, - "2,14": {7:[9,10,11]}, - "3,15": {6:[7,8,9,10,11]}, - "4,16": {7:[1,2,3,4]}, - "5,17": {7:[5,6,7,8]}, - "6,18": {6:[4,5,6]}, - "7,19": {9:[1,2,3,4,5]}, - "8,20": {8:[1,2,3,4,5]}, - "9,21": {5:[8,9,10,11]}, - "10,22": {10:[1,2,3]}, - "11,23": {8:[6,7,8,9,10,11]} - }, - "getHour": function(date) { - var hour = date.getHours(); - if (date.getMinutes() >= 35) { - return (hour + 1) % 24; - } - return hour; - } -}; -$.fritteli.uhr.register('en', layout); +(function () { + 'use strict'; + var h = { + "_it_is": {1: [1, 2, 4, 5]}, + "_half": {4: [1, 2, 3, 4]}, + "_to": {4: [10, 11]}, + "_past": {5: [1, 2, 3, 4]}, + "_o_clock": {10: [6, 7, 8, 9, 10, 11]}, + "_5": {3: [7, 8, 9, 10]}, + "_10": {4: [6, 7, 8]}, + "_15": {2: [1, 3, 4, 5, 6, 7, 8, 9]}, + "_20": {3: [1, 2, 3, 4, 5, 6]}, + "_25": {3: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]} + }; + var layout = { + "version": 2, + "language": 'English', + "letters": [ + 'ITLISBFAMPM', + 'ACQUARTERDC', + 'TWENTYFIVEX', + 'HALFBTENFTO', + 'PASTERUNINE', + 'ONESIXTHREE', + 'FOURFIVETWO', + 'EIGHTELEVEN', + 'SEVENTWELVE', + 'TENSEOCLOCK' + ], + "permanent": h._it_is, + "minutes": { + "0,1,2,3,4": h._o_clock, + "5,6,7,8,9": [h._5, h._past], + "10,11,12,13,14": [h._10, h._past], + "15,16,17,18,19": [h._15, h._past], + "20,21,22,23,24": [h._20, h._past], + "25,26,27,28,29": [h._25, h._past], + "30,31,32,33,34": [h._half, h._past], + "35,36,37,38,39": [h._25, h._to], + "40,41,42,43,44": [h._20, h._to], + "45,46,47,48,49": [h._15, h._to], + "50,51,52,53,54": [h._10, h._to], + "55,56,57,58,59": [h._5, h._to] + }, + "hours": { + "0,12": {9: [6, 7, 8, 9, 10, 11]}, + "1,13": {6: [1, 2, 3]}, + "2,14": {7: [9, 10, 11]}, + "3,15": {6: [7, 8, 9, 10, 11]}, + "4,16": {7: [1, 2, 3, 4]}, + "5,17": {7: [5, 6, 7, 8]}, + "6,18": {6: [4, 5, 6]}, + "7,19": {9: [1, 2, 3, 4, 5]}, + "8,20": {8: [1, 2, 3, 4, 5]}, + "9,21": {5: [8, 9, 10, 11]}, + "10,22": {10: [1, 2, 3]}, + "11,23": {8: [6, 7, 8, 9, 10, 11]} + }, + "getHour": function (date) { + var hour = date.getHours(); + if (date.getMinutes() >= 35) { + return (hour + 1) % 24; + } + return hour; + } + }; + $.fritteli.uhr.register('en', layout); +}()); \ No newline at end of file diff --git a/js/uhr-fr.js b/js/uhr-fr.js index 14e9be1..f751b2b 100644 --- a/js/uhr-fr.js +++ b/js/uhr-fr.js @@ -13,70 +13,105 @@ 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 . */ -'use strict'; -var h = { - "_il_est": {1:[1,2,4,5,6]}, - "_et": {8:[1,2]}, - "_moins": {7:[1,2,3,4,5]}, - "_demie": {10:[4,5,6,7,8]}, - "_heures": {6:[6,7,8,9,10,11]}, - "_le": {7:[7,8]}, - "_5": {9:[7,8,9,10]}, - "_10": {7:[9,10,11]}, - "_15": {8:[4,5,6,7,8]}, - "_20": {9:[1,2,3,4,5]}, - "_25": {9:[1,2,3,4,5,6,7,8,9,10]} -}; -var layout = { - "version": 2, - "language": 'Français', - "letters": [ - 'ILNESTODEUX', - 'QUATRETROIS', - 'NEUFUNESEPT', - 'HUITSIXCINQ', - 'MIDIXMINUIT', - 'ONZERHEURES', - 'MOINSOLEDIX', - 'ETRQUARTPMD', - 'VINGT-CINQU', - 'ETSDEMIEPAM' - ], - "permanent": h._il_est, - "minutes": { - "5,6,7,8,9": h._5, - "10,11,12,13,14": h._10, - "15,16,17,18,19": [h._et, h._15], - "20,21,22,23,24": h._20, - "25,26,27,28,29": h._25, - "30,31,32,33,34": [h._et, h._demie], - "35,36,37,38,39": [h._moins, h._25], - "40,41,42,43,44": [h._moins, h._20], - "45,46,47,48,49": [h._moins, h._le, h._15], - "50,51,52,53,54": [h._moins, h._10], - "55,56,57,58,59": [h._moins, h._5] - }, - "hours": { - "0": {5:[6,7,8,9,10,11]}, - "1,13": [{3:[5,6,7]}, h._heures], - "2,14": [{1:[8,9,10,11]}, h._heures], - "3,15": [{2:[7,8,9,10,11]}, h._heures], - "4,16": [{2:[1,2,3,4,5,6]}, h._heures], - "5,17": [{4:[8,9,10,11]}, h._heures], - "6,18": [{4:[5,6,7]}, h._heures], - "7,19": [{3:[8,9,10,11]}, h._heures], - "8,20": [{4:[1,2,3,4]}, h._heures], - "9,21": [{3:[1,2,3,4]}, h._heures], - "10,22": [{5:[3,4,5]}, h._heures], - "11,23": [{6:[1,2,3,4]}, h._heures], - "12": {5:[1,2,3,4]} - }, - "getHour": function(date) { - var hour = date.getHours(); - if (date.getMinutes() >= 35) { - return (hour + 1) % 24; - } - return hour; - } -}; -$.fritteli.uhr.register('fr', layout); +(function () { + 'use strict'; + var h = { + "_il_est": {1: [1, 2, 4, 5, 6]}, + "_et": {8: [1, 2]}, + "_moins": {7: [1, 2, 3, 4, 5]}, + "_demie": {10: [4, 5, 6, 7, 8]}, + "_heures": {6: [6, 7, 8, 9, 10, 11]}, + "_le": {7: [7, 8]}, + "_5": {9: [7, 8, 9, 10]}, + "_10": {7: [9, 10, 11]}, + "_15": {8: [4, 5, 6, 7, 8]}, + "_20": {9: [1, 2, 3, 4, 5]}, + "_25": {9: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]} + }; + var layout = { + "version": 2, + "language": 'Français', + "letters": [ + 'ILNESTODEUX', + 'QUATRETROIS', + 'NEUFUNESEPT', + 'HUITSIXCINQ', + 'MIDIXMINUIT', + 'ONZERHEURES', + 'MOINSOLEDIX', + 'ETRQUARTPMD', + 'VINGT-CINQU', + 'ETSDEMIEPAM' + ], + "permanent": h._il_est, + "minutes": { + "5,6,7,8,9": h._5, + "10,11,12,13,14": h._10, + "15,16,17,18,19": [h._et, h._15], + "20,21,22,23,24": h._20, + "25,26,27,28,29": h._25, + "30,31,32,33,34": [h._et, h._demie], + "35,36,37,38,39": [h._moins, h._25], + "40,41,42,43,44": [h._moins, h._20], + "45,46,47,48,49": [h._moins, h._le, h._15], + "50,51,52,53,54": [h._moins, h._10], + "55,56,57,58,59": [h._moins, h._5] + }, + "hours": { + "0": {5: [6, 7, 8, 9, 10, 11]}, + "1,13": [ + {3: [5, 6, 7]}, + h._heures + ], + "2,14": [ + {1: [8, 9, 10, 11]}, + h._heures + ], + "3,15": [ + {2: [7, 8, 9, 10, 11]}, + h._heures + ], + "4,16": [ + {2: [1, 2, 3, 4, 5, 6]}, + h._heures + ], + "5,17": [ + {4: [8, 9, 10, 11]}, + h._heures + ], + "6,18": [ + {4: [5, 6, 7]}, + h._heures + ], + "7,19": [ + {3: [8, 9, 10, 11]}, + h._heures + ], + "8,20": [ + {4: [1, 2, 3, 4]}, + h._heures + ], + "9,21": [ + {3: [1, 2, 3, 4]}, + h._heures + ], + "10,22": [ + {5: [3, 4, 5]}, + h._heures + ], + "11,23": [ + {6: [1, 2, 3, 4]}, + h._heures + ], + "12": {5: [1, 2, 3, 4]} + }, + "getHour": function (date) { + var hour = date.getHours(); + if (date.getMinutes() >= 35) { + return (hour + 1) % 24; + } + return hour; + } + }; + $.fritteli.uhr.register('fr', layout); +}()); \ No newline at end of file diff --git a/js/uhr-it.js b/js/uhr-it.js index 29dee3e..0353be3 100644 --- a/js/uhr-it.js +++ b/js/uhr-it.js @@ -12,68 +12,70 @@ 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 . */ -'use strict'; -var h = { - "_sono_le": {1:[1,2,3,4,6,7]}, - "_e_l": {2:[1,3,4]}, - "_e": {8:[1]}, - "_meno": {7:[8,9,10,11]}, - "_mezza": {10:[7,8,9,10,11]}, - "_5": {9:[6,7,8,9,10,11]}, - "_10": {10:[1,2,3,4,5]}, - "_un_quarto": {8:[3,4,6,7,8,9,10,11]}, - "_20": {9:[1,2,3,4,5]}, - "_25": {9:[1,2,3,4,5,6,7,8,9,10,11]} -}; -var layout = { - "version": 2, - "language": 'Italiano', - "letters": [ - 'SONORLEBORE', - 'ÈRL\'UNASDUE', - 'TREOTTONOVE', - 'DIECIUNDICI', - 'DODICISETTE', - 'QUATTROCSEI', - 'CINQUEAMENO', - 'ECUNOQUARTO', - 'VENTICINQUE', - 'DIECIPMEZZA' - ], - "permanent": [], - "minutes": { - "5,6,7,8,9": [h._e, h._5], - "10,11,12,13,14": [h._e, h._10], - "15,16,17,18,19": [h._e, h._un_quarto], - "20,21,22,23,24": [h._e, h._20], - "25,26,27,28,29": [h._e, h._25], - "30,31,32,33,34": [h._e, h._mezza], - "35,36,37,38,39": [h._meno, h._25], - "40,41,42,43,44": [h._meno, h._20], - "45,46,47,48,49": [h._meno, h._un_quarto], - "50,51,52,53,54": [h._meno, h._10], - "55,56,57,58,59": [h._meno, h._5] - }, - "hours": { - "0,12": [h._sono_le, {5:[1,2,3,4,5,6]}], - "1,13": [h._e_l, {2:[5,6,7]}], - "2,14": [h._sono_le, {2:[9,10,11]}], - "3,15": [h._sono_le, {3:[1,2,3]}], - "4,16": [h._sono_le, {6:[1,2,3,4,5,6,7]}], - "5,17": [h._sono_le, {7:[1,2,3,4,5,6]}], - "6,18": [h._sono_le, {6:[9,10,11]}], - "7,19": [h._sono_le, {5:[7,8,9,10,11]}], - "8,20": [h._sono_le, {3:[4,5,6,7]}], - "9,21": [h._sono_le, {3:[8,9,10,11]}], - "10,22": [h._sono_le, {4:[1,2,3,4,5]}], - "11,23": [h._sono_le, {4:[6,7,8,9,10,11]}] - }, - "getHour": function(date) { - var hour = date.getHours(); - if (date.getMinutes() >= 35) { - return (hour + 1) % 24; - } - return hour; - } -}; -$.fritteli.uhr.register('it', layout); +(function () { + 'use strict'; + var h = { + "_sono_le": {1: [1, 2, 3, 4, 6, 7]}, + "_e_l": {2: [1, 3, 4]}, + "_e": {8: [1]}, + "_meno": {7: [8, 9, 10, 11]}, + "_mezza": {10: [7, 8, 9, 10, 11]}, + "_5": {9: [6, 7, 8, 9, 10, 11]}, + "_10": {10: [1, 2, 3, 4, 5]}, + "_un_quarto": {8: [3, 4, 6, 7, 8, 9, 10, 11]}, + "_20": {9: [1, 2, 3, 4, 5]}, + "_25": {9: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]} + }; + var layout = { + "version": 2, + "language": 'Italiano', + "letters": [ + 'SONORLEBORE', + 'ÈRL\'UNASDUE', + 'TREOTTONOVE', + 'DIECIUNDICI', + 'DODICISETTE', + 'QUATTROCSEI', + 'CINQUEAMENO', + 'ECUNOQUARTO', + 'VENTICINQUE', + 'DIECIPMEZZA' + ], + "permanent": [], + "minutes": { + "5,6,7,8,9": [h._e, h._5], + "10,11,12,13,14": [h._e, h._10], + "15,16,17,18,19": [h._e, h._un_quarto], + "20,21,22,23,24": [h._e, h._20], + "25,26,27,28,29": [h._e, h._25], + "30,31,32,33,34": [h._e, h._mezza], + "35,36,37,38,39": [h._meno, h._25], + "40,41,42,43,44": [h._meno, h._20], + "45,46,47,48,49": [h._meno, h._un_quarto], + "50,51,52,53,54": [h._meno, h._10], + "55,56,57,58,59": [h._meno, h._5] + }, + "hours": { + "0,12": [h._sono_le, {5: [1, 2, 3, 4, 5, 6]}], + "1,13": [h._e_l, {2: [5, 6, 7]}], + "2,14": [h._sono_le, {2: [9, 10, 11]}], + "3,15": [h._sono_le, {3: [1, 2, 3]}], + "4,16": [h._sono_le, {6: [1, 2, 3, 4, 5, 6, 7]}], + "5,17": [h._sono_le, {7: [1, 2, 3, 4, 5, 6]}], + "6,18": [h._sono_le, {6: [9, 10, 11]}], + "7,19": [h._sono_le, {5: [7, 8, 9, 10, 11]}], + "8,20": [h._sono_le, {3: [4, 5, 6, 7]}], + "9,21": [h._sono_le, {3: [8, 9, 10, 11]}], + "10,22": [h._sono_le, {4: [1, 2, 3, 4, 5]}], + "11,23": [h._sono_le, {4: [6, 7, 8, 9, 10, 11]}] + }, + "getHour": function (date) { + var hour = date.getHours(); + if (date.getMinutes() >= 35) { + return (hour + 1) % 24; + } + return hour; + } + }; + $.fritteli.uhr.register('it', layout); +}()); \ No newline at end of file diff --git a/js/uhr.js b/js/uhr.js index 20a6485..4ede129 100644 --- a/js/uhr.js +++ b/js/uhr.js @@ -465,4 +465,4 @@ along with this program. If not, see . return '' + myValue + ''; }; } -})(jQuery); +})(jQuery); \ No newline at end of file From 08cca0a915b3e0b0e93eb8ba8da1732d49b8ea22 Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 3 Jul 2014 21:06:06 +0200 Subject: [PATCH 08/30] helper variables don't need to be wrapped in their own object. --- js/uhr-de.js | 93 ++++++++++++++++--------------- js/uhr-de_CH.js | 64 +++++++++++---------- js/uhr-de_CH_genau.js | 68 +++++++++++----------- js/uhr-en.js | 73 ++++++++++++------------ js/uhr-fr.js | 127 +++++++++++++++--------------------------- js/uhr-it.js | 91 +++++++++++++++--------------- 6 files changed, 238 insertions(+), 278 deletions(-) diff --git a/js/uhr-de.js b/js/uhr-de.js index c75a487..93331b1 100644 --- a/js/uhr-de.js +++ b/js/uhr-de.js @@ -1,30 +1,30 @@ /* -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'; - var h = { - "_es_ist": {1:[1,2,4,5,6]}, - "_nach": {4:[8,9,10,11]}, - "_vor": {4:[1,2,3]}, - "_halb": {5:[1,2,3,4]}, - "_5": {1:[8,9,10,11]}, - "_10": {2:[1,2,3,4]}, - "_15": {3:[5,6,7,8,9,10,11]}, - "_20": {2:[5,6,7,8,9,10,11]}, - "_45": {3:[1,2,3,4,5,6,7,8,9,10,11]} - }; + var es_ist = {1: [1, 2, 4, 5, 6]}; + var uhr = {10: [9, 10, 11]}; + var nach = {4: [8, 9, 10, 11]}; + var vor = {4: [1, 2, 3]}; + var halb = {5: [1, 2, 3, 4]}; + var fuenf = {1: [8, 9, 10, 11]}; + var zehn = {2: [1, 2, 3, 4]}; + var viertel = {3: [5, 6, 7, 8, 9, 10, 11]}; + var zwanzig = {2: [5, 6, 7, 8, 9, 10, 11]}; + var dreiviertel = {3: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]}; + var layout = { "version": 2, "language": 'Deutsch', @@ -40,33 +40,34 @@ along with this program. If not, see . 'SIEBENZWÖLF', 'ZEHNEUNKUHR' ], - "permanent": h._es_ist, + "permanent": es_ist, "minutes": { - "5,6,7,8,9": [h._5, h._nach], - "10,11,12,13,14": [h._10, h._nach], - "15,16,17,18,19": [h._15, h._nach], - "20,21,22,23,24": [h._20, h._nach], - "25,26,27,28,29": [h._5, h._vor, h._halb], - "30,31,32,33,34": h._halb, - "35,36,37,38,39": [h._5, h._nach, h._halb], - "40,41,42,43,44": [h._20, h._vor], - "45,46,47,48,49": h._45, - "50,51,52,53,54": [h._10, h._vor], - "55,56,57,58,59": [h._5, h._vor] + "0,1,2,3,4": uhr, + "5,6,7,8,9": [fuenf, nach], + "10,11,12,13,14": [zehn, nach], + "15,16,17,18,19": [viertel, nach], + "20,21,22,23,24": [zwanzig, nach], + "25,26,27,28,29": [fuenf, vor, halb], + "30,31,32,33,34": halb, + "35,36,37,38,39": [fuenf, nach, halb], + "40,41,42,43,44": [zwanzig, vor], + "45,46,47,48,49": dreiviertel, + "50,51,52,53,54": [zehn, vor], + "55,56,57,58,59": [fuenf, vor] }, "hours": { - "0,12": {9:[7,8,9,10,11]}, - "1,13": {6:[1,2,3,4]}, - "2,14": {6:[8,9,10,11]}, - "3,15": {7:[1,2,3,4]}, - "4,16": {7:[8,9,10,11]}, - "5,17": {5:[8,9,10,11]}, - "6,18": {8:[1,2,3,4,5]}, - "7,19": {9:[1,2,3,4,5,6]}, - "8,20": {8:[8,9,10,11]}, - "9,21": {10:[4,5,6,7]}, - "10,22": {10:[1,2,3,4]}, - "11,23": {5:[6,7,8]} + "0,12": {9: [7, 8, 9, 10, 11]}, + "1,13": {6: [1, 2, 3, 4]}, + "2,14": {6: [8, 9, 10, 11]}, + "3,15": {7: [1, 2, 3, 4]}, + "4,16": {7: [8, 9, 10, 11]}, + "5,17": {5: [8, 9, 10, 11]}, + "6,18": {8: [1, 2, 3, 4, 5]}, + "7,19": {9: [1, 2, 3, 4, 5, 6]}, + "8,20": {8: [8, 9, 10, 11]}, + "9,21": {10: [4, 5, 6, 7]}, + "10,22": {10: [1, 2, 3, 4]}, + "11,23": {5: [6, 7, 8]} } }; $.fritteli.uhr.register('de', layout); diff --git a/js/uhr-de_CH.js b/js/uhr-de_CH.js index 2f80062..279a430 100644 --- a/js/uhr-de_CH.js +++ b/js/uhr-de_CH.js @@ -1,30 +1,28 @@ /* -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'; // hilfsvariablen - var h = { - "_es_isch": {1: [1, 2, 4, 5, 6, 7]}, - "_ab": {4: [1, 2]}, - "_vor": {3: [9, 10, 11]}, - "_haubi": {4: [4, 5, 6, 7, 8]}, - "_5": {1: [9, 10, 11]}, - "_10": {2: [9, 10, 11]}, - "_15": {2: [1, 2, 3, 4, 5, 6]}, - "_20": {3: [1, 2, 3, 4, 5, 6]} - }; + var es_isch = {1: [1, 2, 4, 5, 6, 7]}; + var ab = {4: [1, 2]}; + var vor = {3: [9, 10, 11]}; + var haubi = {4: [4, 5, 6, 7, 8]}; + var fuef = {1: [9, 10, 11]}; + var zae = {2: [9, 10, 11]}; + var viertu = {2: [1, 2, 3, 4, 5, 6]}; + var zwaenzg = {3: [1, 2, 3, 4, 5, 6]}; var layout = { // version: zur Zeit immer 2 (Pflichtattribut) "version": 2, @@ -44,7 +42,7 @@ along with this program. If not, see . 'ZWÖUFINAUHR' ], // Permanent aktive Buchstaben. , vgl. ausführliche Beschreibung bei "minutes". - "permanent": h._es_isch, + "permanent": es_isch, /* * Minuten: Objekt im folgenden Format: * { @@ -66,17 +64,17 @@ along with this program. If not, see . * Bei Minute 5 sind die Buchstaben 1 und 2 der Zeile 3 sowie die Buchstaben 10 und 11 der Zeile 4 aktiv. */ "minutes": { - "5,6,7,8,9": [h._5, h._ab], - "10,11,12,13,14": [h._10, h._ab], - "15,16,17,18,19": [h._15, h._ab], - "20,21,22,23,24": [h._20, h._ab], - "25,26,27,28,29": [h._5, h._vor, h._haubi], - "30,31,32,33,34": h._haubi, - "35,36,37,38,39": [h._5, h._ab, h._haubi], - "40,41,42,43,44": [h._20, h._vor], - "45,46,47,48,49": [h._15, h._vor], - "50,51,52,53,54": [h._10, h._vor], - "55,56,57,58,59": [h._5, h._vor] + "5,6,7,8,9": [fuef, ab], + "10,11,12,13,14": [zae, ab], + "15,16,17,18,19": [viertu, ab], + "20,21,22,23,24": [zwaenzg, ab], + "25,26,27,28,29": [fuef, vor, haubi], + "30,31,32,33,34": haubi, + "35,36,37,38,39": [fuef, ab, haubi], + "40,41,42,43,44": [zwaenzg, vor], + "45,46,47,48,49": [viertu, vor], + "50,51,52,53,54": [zae, vor], + "55,56,57,58,59": [fuef, vor] }, // Die Stunden; gleiches Format wie bei den Minuten "hours": { diff --git a/js/uhr-de_CH_genau.js b/js/uhr-de_CH_genau.js index 9d45598..301852c 100644 --- a/js/uhr-de_CH_genau.js +++ b/js/uhr-de_CH_genau.js @@ -1,30 +1,28 @@ /* -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'; - var h = { - "_es_isch": {1: [1, 2, 4, 5, 6, 7]}, - "_genau": {3: [7, 8, 9, 10, 11]}, - "_ab": {4: [4, 5]}, - "_vor": {4: [1, 2, 3]}, - "_haubi": {4: [7, 8, 9, 10, 11]}, - "_5": {1: [9, 10, 11]}, - "_10": {2: [9, 10, 11]}, - "_15": {2: [1, 2, 3, 4, 5, 6]}, - "_20": {3: [1, 2, 3, 4, 5, 6]} - }; + var es_isch = {1: [1, 2, 4, 5, 6, 7]}; + var genau = {3: [7, 8, 9, 10, 11]}; + var ab = {4: [4, 5]}; + var vor = {4: [1, 2, 3]}; + var haubi = {4: [7, 8, 9, 10, 11]}; + var fuef = {1: [9, 10, 11]}; + var zae = {2: [9, 10, 11]}; + var viertu = {2: [1, 2, 3, 4, 5, 6]}; + var zwaenzg = {3: [1, 2, 3, 4, 5, 6]}; var layout = { "version": 2, "language": 'Bärndütsch (genau)', @@ -40,20 +38,20 @@ along with this program. If not, see . 'ZÄNIERBEUFI', 'ZWÖUFINAUHR' ], - "permanent": h._es_isch, + "permanent": es_isch, "minutes": { - "0": h._genau, - "5,6,7,8,9": [h._5, h._ab], - "10,11,12,13,14": [h._10, h._ab], - "15,16,17,18,19": [h._15, h._ab], - "20,21,22,23,24": [h._20, h._ab], - "25,26,27,28,29": [h._5, h._vor, h._haubi], - "30,31,32,33,34": h._haubi, - "35,36,37,38,39": [h._5, h._ab, h._haubi], - "40,41,42,43,44": [h._20, h._vor], - "45,46,47,48,49": [h._15, h._vor], - "50,51,52,53,54": [h._10, h._vor], - "55,56,57,58,59": [h._5, h._vor] + "0": genau, + "5,6,7,8,9": [fuef, ab], + "10,11,12,13,14": [zae, ab], + "15,16,17,18,19": [viertu, ab], + "20,21,22,23,24": [zwaenzg, ab], + "25,26,27,28,29": [fuef, vor, haubi], + "30,31,32,33,34": haubi, + "35,36,37,38,39": [fuef, ab, haubi], + "40,41,42,43,44": [zwaenzg, vor], + "45,46,47,48,49": [viertu, vor], + "50,51,52,53,54": [zae, vor], + "55,56,57,58,59": [fuef, vor] }, "hours": { "0,12": {10: [1, 2, 3, 4, 5, 6]}, diff --git a/js/uhr-en.js b/js/uhr-en.js index d88a7db..863c40f 100644 --- a/js/uhr-en.js +++ b/js/uhr-en.js @@ -1,31 +1,30 @@ /* -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'; - var h = { - "_it_is": {1: [1, 2, 4, 5]}, - "_half": {4: [1, 2, 3, 4]}, - "_to": {4: [10, 11]}, - "_past": {5: [1, 2, 3, 4]}, - "_o_clock": {10: [6, 7, 8, 9, 10, 11]}, - "_5": {3: [7, 8, 9, 10]}, - "_10": {4: [6, 7, 8]}, - "_15": {2: [1, 3, 4, 5, 6, 7, 8, 9]}, - "_20": {3: [1, 2, 3, 4, 5, 6]}, - "_25": {3: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]} - }; + var it_is = {1: [1, 2, 4, 5]}; + var half = {4: [1, 2, 3, 4]}; + var to = {4: [10, 11]}; + var past = {5: [1, 2, 3, 4]}; + var o_clock = {10: [5, 6, 7, 8, 9, 10, 11]}; + var five = {3: [7, 8, 9, 10]}; + var ten = {4: [6, 7, 8]}; + var a_quarter = {2: [1, 3, 4, 5, 6, 7, 8, 9]}; + var twenty = {3: [1, 2, 3, 4, 5, 6]}; + var twentyfive = {3: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}; + var layout = { "version": 2, "language": 'English', @@ -39,22 +38,22 @@ along with this program. If not, see . 'FOURFIVETWO', 'EIGHTELEVEN', 'SEVENTWELVE', - 'TENSEOCLOCK' + 'TENSO\'CLOCK' ], - "permanent": h._it_is, + "permanent": it_is, "minutes": { - "0,1,2,3,4": h._o_clock, - "5,6,7,8,9": [h._5, h._past], - "10,11,12,13,14": [h._10, h._past], - "15,16,17,18,19": [h._15, h._past], - "20,21,22,23,24": [h._20, h._past], - "25,26,27,28,29": [h._25, h._past], - "30,31,32,33,34": [h._half, h._past], - "35,36,37,38,39": [h._25, h._to], - "40,41,42,43,44": [h._20, h._to], - "45,46,47,48,49": [h._15, h._to], - "50,51,52,53,54": [h._10, h._to], - "55,56,57,58,59": [h._5, h._to] + "0,1,2,3,4": o_clock, + "5,6,7,8,9": [five, past], + "10,11,12,13,14": [ten, past], + "15,16,17,18,19": [a_quarter, past], + "20,21,22,23,24": [twenty, past], + "25,26,27,28,29": [twentyfive, past], + "30,31,32,33,34": [half, past], + "35,36,37,38,39": [twentyfive, to], + "40,41,42,43,44": [twenty, to], + "45,46,47,48,49": [a_quarter, to], + "50,51,52,53,54": [ten, to], + "55,56,57,58,59": [five, to] }, "hours": { "0,12": {9: [6, 7, 8, 9, 10, 11]}, diff --git a/js/uhr-fr.js b/js/uhr-fr.js index f751b2b..c4fed2c 100644 --- a/js/uhr-fr.js +++ b/js/uhr-fr.js @@ -1,33 +1,31 @@ - /* -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'; - var h = { - "_il_est": {1: [1, 2, 4, 5, 6]}, - "_et": {8: [1, 2]}, - "_moins": {7: [1, 2, 3, 4, 5]}, - "_demie": {10: [4, 5, 6, 7, 8]}, - "_heures": {6: [6, 7, 8, 9, 10, 11]}, - "_le": {7: [7, 8]}, - "_5": {9: [7, 8, 9, 10]}, - "_10": {7: [9, 10, 11]}, - "_15": {8: [4, 5, 6, 7, 8]}, - "_20": {9: [1, 2, 3, 4, 5]}, - "_25": {9: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]} - }; + var il_est = {1: [1, 2, 4, 5, 6]}; + var et = {8: [1, 2]}; + var moins = {7: [1, 2, 3, 4, 5]}; + var demie = {10: [4, 5, 6, 7, 8]}; + var heures = {6: [6, 7, 8, 9, 10, 11]}; + var le = {7: [7, 8]}; + var cinq = {9: [7, 8, 9, 10]}; + var dix = {7: [9, 10, 11]}; + var quart = {8: [4, 5, 6, 7, 8]}; + var vingt = {9: [1, 2, 3, 4, 5]}; + var vingtcinq = {9: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}; + var layout = { "version": 2, "language": 'Français', @@ -43,66 +41,33 @@ along with this program. If not, see . 'VINGT-CINQU', 'ETSDEMIEPAM' ], - "permanent": h._il_est, + "permanent": il_est, "minutes": { - "5,6,7,8,9": h._5, - "10,11,12,13,14": h._10, - "15,16,17,18,19": [h._et, h._15], - "20,21,22,23,24": h._20, - "25,26,27,28,29": h._25, - "30,31,32,33,34": [h._et, h._demie], - "35,36,37,38,39": [h._moins, h._25], - "40,41,42,43,44": [h._moins, h._20], - "45,46,47,48,49": [h._moins, h._le, h._15], - "50,51,52,53,54": [h._moins, h._10], - "55,56,57,58,59": [h._moins, h._5] + "5,6,7,8,9": cinq, + "10,11,12,13,14": dix, + "15,16,17,18,19": [et, quart], + "20,21,22,23,24": vingt, + "25,26,27,28,29": vingtcinq, + "30,31,32,33,34": [et, demie], + "35,36,37,38,39": [moins, vingtcinq], + "40,41,42,43,44": [moins, vingt], + "45,46,47,48,49": [moins, le, quart], + "50,51,52,53,54": [moins, dix], + "55,56,57,58,59": [moins, cinq] }, "hours": { "0": {5: [6, 7, 8, 9, 10, 11]}, - "1,13": [ - {3: [5, 6, 7]}, - h._heures - ], - "2,14": [ - {1: [8, 9, 10, 11]}, - h._heures - ], - "3,15": [ - {2: [7, 8, 9, 10, 11]}, - h._heures - ], - "4,16": [ - {2: [1, 2, 3, 4, 5, 6]}, - h._heures - ], - "5,17": [ - {4: [8, 9, 10, 11]}, - h._heures - ], - "6,18": [ - {4: [5, 6, 7]}, - h._heures - ], - "7,19": [ - {3: [8, 9, 10, 11]}, - h._heures - ], - "8,20": [ - {4: [1, 2, 3, 4]}, - h._heures - ], - "9,21": [ - {3: [1, 2, 3, 4]}, - h._heures - ], - "10,22": [ - {5: [3, 4, 5]}, - h._heures - ], - "11,23": [ - {6: [1, 2, 3, 4]}, - h._heures - ], + "1,13": [{3: [5, 6, 7]}, heures], + "2,14": [{1: [8, 9, 10, 11]}, heures], + "3,15": [{2: [7, 8, 9, 10, 11]}, heures], + "4,16": [{2: [1, 2, 3, 4, 5, 6]}, heures], + "5,17": [{4: [8, 9, 10, 11]}, heures], + "6,18": [{4: [5, 6, 7]}, heures], + "7,19": [{3: [8, 9, 10, 11]}, heures], + "8,20": [{4: [1, 2, 3, 4]}, heures], + "9,21": [{3: [1, 2, 3, 4]}, heures], + "10,22": [{5: [3, 4, 5]}, heures], + "11,23": [{6: [1, 2, 3, 4]}, heures], "12": {5: [1, 2, 3, 4]} }, "getHour": function (date) { diff --git a/js/uhr-it.js b/js/uhr-it.js index 0353be3..65e33af 100644 --- a/js/uhr-it.js +++ b/js/uhr-it.js @@ -1,31 +1,30 @@ /* -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'; - var h = { - "_sono_le": {1: [1, 2, 3, 4, 6, 7]}, - "_e_l": {2: [1, 3, 4]}, - "_e": {8: [1]}, - "_meno": {7: [8, 9, 10, 11]}, - "_mezza": {10: [7, 8, 9, 10, 11]}, - "_5": {9: [6, 7, 8, 9, 10, 11]}, - "_10": {10: [1, 2, 3, 4, 5]}, - "_un_quarto": {8: [3, 4, 6, 7, 8, 9, 10, 11]}, - "_20": {9: [1, 2, 3, 4, 5]}, - "_25": {9: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]} - }; + var sono_le = {1: [1, 2, 3, 4, 6, 7]}; + var e_l = {2: [1, 3, 4]}; + var e = {8: [1]}; + var meno = {7: [8, 9, 10, 11]}; + var mezza = {10: [7, 8, 9, 10, 11]}; + var cinque = {9: [6, 7, 8, 9, 10, 11]}; + var dieci = {10: [1, 2, 3, 4, 5]}; + var un_quarto = {8: [3, 4, 6, 7, 8, 9, 10, 11]}; + var venti = {9: [1, 2, 3, 4, 5]}; + var venticinque = {9: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]}; + var layout = { "version": 2, "language": 'Italiano', @@ -43,31 +42,31 @@ along with this program. If not, see . ], "permanent": [], "minutes": { - "5,6,7,8,9": [h._e, h._5], - "10,11,12,13,14": [h._e, h._10], - "15,16,17,18,19": [h._e, h._un_quarto], - "20,21,22,23,24": [h._e, h._20], - "25,26,27,28,29": [h._e, h._25], - "30,31,32,33,34": [h._e, h._mezza], - "35,36,37,38,39": [h._meno, h._25], - "40,41,42,43,44": [h._meno, h._20], - "45,46,47,48,49": [h._meno, h._un_quarto], - "50,51,52,53,54": [h._meno, h._10], - "55,56,57,58,59": [h._meno, h._5] + "5,6,7,8,9": [e, cinque], + "10,11,12,13,14": [e, dieci], + "15,16,17,18,19": [e, un_quarto], + "20,21,22,23,24": [e, venti], + "25,26,27,28,29": [e, venticinque], + "30,31,32,33,34": [e, mezza], + "35,36,37,38,39": [meno, venticinque], + "40,41,42,43,44": [meno, venti], + "45,46,47,48,49": [meno, un_quarto], + "50,51,52,53,54": [meno, dieci], + "55,56,57,58,59": [meno, cinque] }, "hours": { - "0,12": [h._sono_le, {5: [1, 2, 3, 4, 5, 6]}], - "1,13": [h._e_l, {2: [5, 6, 7]}], - "2,14": [h._sono_le, {2: [9, 10, 11]}], - "3,15": [h._sono_le, {3: [1, 2, 3]}], - "4,16": [h._sono_le, {6: [1, 2, 3, 4, 5, 6, 7]}], - "5,17": [h._sono_le, {7: [1, 2, 3, 4, 5, 6]}], - "6,18": [h._sono_le, {6: [9, 10, 11]}], - "7,19": [h._sono_le, {5: [7, 8, 9, 10, 11]}], - "8,20": [h._sono_le, {3: [4, 5, 6, 7]}], - "9,21": [h._sono_le, {3: [8, 9, 10, 11]}], - "10,22": [h._sono_le, {4: [1, 2, 3, 4, 5]}], - "11,23": [h._sono_le, {4: [6, 7, 8, 9, 10, 11]}] + "0,12": [sono_le, {5: [1, 2, 3, 4, 5, 6]}], + "1,13": [e_l, {2: [5, 6, 7]}], + "2,14": [sono_le, {2: [9, 10, 11]}], + "3,15": [sono_le, {3: [1, 2, 3]}], + "4,16": [sono_le, {6: [1, 2, 3, 4, 5, 6, 7]}], + "5,17": [sono_le, {7: [1, 2, 3, 4, 5, 6]}], + "6,18": [sono_le, {6: [9, 10, 11]}], + "7,19": [sono_le, {5: [7, 8, 9, 10, 11]}], + "8,20": [sono_le, {3: [4, 5, 6, 7]}], + "9,21": [sono_le, {3: [8, 9, 10, 11]}], + "10,22": [sono_le, {4: [1, 2, 3, 4, 5]}], + "11,23": [sono_le, {4: [6, 7, 8, 9, 10, 11]}] }, "getHour": function (date) { var hour = date.getHours(); From ec9b44427cd1b565f2c4fefb80b4360aa5eaf6e3 Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 3 Jul 2014 21:16:47 +0200 Subject: [PATCH 09/30] renamed _timer to timer --- js/uhr.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/js/uhr.js b/js/uhr.js index 4ede129..aa823be 100644 --- a/js/uhr.js +++ b/js/uhr.js @@ -58,7 +58,7 @@ along with this program. If not, see . var start = function start() { if (!isOn(this)) { var uhr = this; - this._timer = window.setInterval(function uhrTimer() { + this.timer = window.setInterval(function uhrTimer() { uhr.options.time = new Date(); update(uhr); }, 1000); @@ -68,8 +68,8 @@ along with this program. If not, see . }; var stop = function stop() { if (isOn(this)) { - window.clearInterval(this._timer); - this._timer = null; + window.clearInterval(this.timer); + this.timer = null; update(this); setCookie(this, 'uhr-status', 'off'); } @@ -107,8 +107,8 @@ along with this program. If not, see . if (time === null) { this.options.time = new Date(); } else { - if (this._timer !== null) { - window.clearInterval(this._timer); + if (this.timer !== null) { + window.clearInterval(this.timer); } this.options.time = time; } @@ -118,6 +118,8 @@ along with this program. If not, see . // private interface methods var create = function create() { this._id = uhrGlobals.id++; + this.timer = null; + this._currentMinute = -1; var userTime = this.options.time; if (this.options.time === undefined) { this.options.time = new Date(); @@ -265,7 +267,7 @@ along with this program. If not, see . // business logic var isOn = function isOn(uhr) { - return uhr._timer !== null; + return uhr.timer !== null; }; var update = function update(uhr) { if (isOn(uhr)) { @@ -349,11 +351,7 @@ along with this program. If not, see . "theme": setTheme, "time": setTime, // constructor method - "_create": create, - // private variables - "_id": -1, - "_timer": null, - "_currentMinute": -1 + "_create": create }); $.fritteli.uhr.register = uhrGlobals.registerLanguage; /** From 60e68ffeaff8c0dc8ef43648e4608e6ffa09208c Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 3 Jul 2014 21:18:27 +0200 Subject: [PATCH 10/30] renamed _id to id --- js/uhr.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/js/uhr.js b/js/uhr.js index aa823be..3a26c6d 100644 --- a/js/uhr.js +++ b/js/uhr.js @@ -97,7 +97,7 @@ along with this program. If not, see . var setTheme = function setTheme(theme) { if (theme !== this.options.theme) { this.element.removeClass(this.options.theme).addClass(theme); - $('#uhr-onoffswitch' + this._id).removeClass(this.options.theme).addClass(theme); + $('#uhr-onoffswitch' + this.id).removeClass(this.options.theme).addClass(theme); this.options.theme = theme; setCookie(this, 'uhr-theme', theme); } @@ -117,7 +117,7 @@ along with this program. If not, see . // private interface methods var create = function create() { - this._id = uhrGlobals.id++; + this.id = uhrGlobals.id++; this.timer = null; this._currentMinute = -1; var userTime = this.options.time; @@ -151,9 +151,9 @@ along with this program. If not, see . if (uhr.options.controls) { // on/off switch - var toggleSwitch = $('
'); - toggleSwitch.append(''); - toggleSwitch.append('