From fc2c8ac38a860713be006d0cb2e2bf15f35cd0a5 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Sat, 11 Jan 2014 12:18:11 +0100 Subject: [PATCH] =?UTF-8?q?es=20funzt!=20nun=20muss=20ich=20aufr=C3=A4umen?= =?UTF-8?q?=20und=20das=20ganze=20noch=20RICHTIG=20machen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 5 ++++- uhr-de.js | 2 +- uhr-de_CH.js | 2 +- uhr-en.js | 2 +- uhr.js | 33 ++++++++++++++++++++++++++------- 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index 632a595..e77801c 100644 --- a/index.html +++ b/index.html @@ -30,6 +30,9 @@ along with this program. If not, see .
+
+
+

Created by fritteli, inspired by QLOCKTWO. @@ -46,7 +49,7 @@ along with this program. If not, see . width: size + 'px' }); */ - $('#test').uhr({width:'10em'}); + $('div.u').uhr({width:'10em'}); diff --git a/uhr-de.js b/uhr-de.js index be7c72e..297484d 100644 --- a/uhr-de.js +++ b/uhr-de.js @@ -27,4 +27,4 @@ var layout = { [h('Z', 10), h('E', 10),h('H', 10),h('N', 9, 10),h('E', 9),h('U', 9),h('N', 9),l('K'),l('U'),l('H'),l('R')] ] }; -//Uhr.register('de', layout); +Uhr.registerLanguage('de', layout); diff --git a/uhr-de_CH.js b/uhr-de_CH.js index 36e333b..4b6f5cb 100644 --- a/uhr-de_CH.js +++ b/uhr-de_CH.js @@ -27,4 +27,4 @@ var layout = { [h('Z', 12), h('W', 12),h('Ö', 12),h('U', 12),h('F', 12),h('I', 12),l('N'),l('A'),l('U'),l('H'),l('R')] ] }; -//Uhr.register('de_CH', layout); +Uhr.registerLanguage('de_CH', layout); diff --git a/uhr-en.js b/uhr-en.js index 5f9d026..2727d28 100644 --- a/uhr-en.js +++ b/uhr-en.js @@ -34,4 +34,4 @@ var layout = { return hour; } }; -//Uhr.register('en', layout); +Uhr.registerLanguage('en', layout); diff --git a/uhr.js b/uhr.js index 67529c4..8337a01 100644 --- a/uhr.js +++ b/uhr.js @@ -43,7 +43,6 @@ along with this program. If not, see . return; } e.data('currentMinute', now.getMinutes()); - //FIXME var dotMinute = Uhr.getDotMinute(e, now); var hour = Uhr.getHour(e, now); var coarseMinute = this.getCoarseMinute(e, now); @@ -74,6 +73,13 @@ along with this program. If not, see . e.find('.item').removeClass('active'); }, setLanguage: function(e, language) { + var newLanguage = Uhr.layouts[language]; + if (newLanguage !== undefined && newLanguage != e.data('currentLanguage')) { + e.data('currentLanguage', newLanguage); + var renderer = new UhrRenderer(newLanguage, e.find('.letterarea')); + renderer.render(e); + jQuery.cookie('language' + e.data('id'), language, {expires: 365, path: '/'}); + } }, setTheme: function(e, theme) { var currentTheme = e.data('currentTheme'); @@ -91,9 +97,12 @@ along with this program. If not, see . e.find('.item.' + itemClass).addClass('active'); }, getHour: function(e, date) { + //FIXME + /* if (typeof e.data('currentLayout').getHour === 'function') { return e.data('currentLayout').getHour(date); } + */ var hour = date.getHours(); if (date.getMinutes() >= 25) { return hour + 1; @@ -101,16 +110,22 @@ along with this program. If not, see . return hour; }, getCoarseMinute: function(e, date) { + //FIXME + /* if (typeof e.data('currentLayout').getCoarseMinute === 'function') { return e.data('currentLayout').getCoarseMinute(date); } + */ var minutes = date.getMinutes(); return minutes - Uhr.getDotMinute(e, date); }, getDotMinute: function(e, date) { + //FIXME + /* if (typeof e.data('currentLayout').getDotMinute === 'function') { return e.data('currentLayout').getDotMinute(date); } + */ var minutes = date.getMinutes(); return minutes % 5; }, @@ -122,7 +137,11 @@ along with this program. If not, see . return 12; } return hour; - } + }, + registerLanguage: function(languageKey, layout) { + this.layouts[languageKey] = layout; + }, + layouts: new Array() } $.fn.uhr = function(options) { var settings = $.extend({ @@ -470,6 +489,9 @@ Uhr.prototype.initThemeSwitch = function(defaultValue, overrideCookie) { this.setTheme(selectedTheme); } + +//} +})(jQuery); /** * Hilfsklasse zum Rendern der Uhr. * @param layout Layout-Objekt, das gerendert werden soll. @@ -492,14 +514,11 @@ UhrRenderer.prototype.render = function(uhr) { renderer.renderarea.append('
'); } } - uhr.currentMinute = -1; - uhr.update(); + uhr.data('currentMinute', -1); + Uhr.update(uhr); renderer.renderarea.fadeIn('fast'); }); } - -//} -})(jQuery); /** * Ein Buchstabe. Hilfsklasse für den Renderer und Inhalt der Layout-Arrays. * @param value Der Buchstabe, der Dargestellt werden soll.