From afe923c1367b4054aba20b66e475b4eaf7cf8c61 Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 3 Jul 2014 16:53:07 +0200 Subject: [PATCH] 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

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