Revert "get rid of linting errors, hopefully"
This reverts commit 0b26225c87
.
This commit is contained in:
parent
bc835598a4
commit
9e4a00e4bc
1 changed files with 28 additions and 37 deletions
65
src/uhr.js
65
src/uhr.js
|
@ -14,16 +14,7 @@
|
|||
*/
|
||||
(function($) {
|
||||
'use strict';
|
||||
// define all variables
|
||||
var uhrGlobals;
|
||||
// define all variables for public functions
|
||||
var start, stop, toggle, setLanguage, setTheme, setTime, setMode, setWidth;
|
||||
// define all variables for private functions
|
||||
var create, toggleConfigScreen, setupHTML, wireFunctionality, destroy, setCookie,
|
||||
isOn, update, show, highlight, clear, getSecond, getDotMinute, getCoarseMinute, getHour,
|
||||
language, UhrRenderer, UhrRendererV2Delegate,
|
||||
parseObject, Letter;
|
||||
uhrGlobals = {
|
||||
var uhrGlobals = {
|
||||
"id": 0,
|
||||
"languages": [],
|
||||
"themes": [],
|
||||
|
@ -61,7 +52,7 @@
|
|||
}
|
||||
|
||||
// public interface methods (exported later)
|
||||
start = function start() {
|
||||
var start = function start() {
|
||||
if (!isOn.bind(this)()) {
|
||||
this.timer = window.setInterval(function() {
|
||||
this.options.time = new Date();
|
||||
|
@ -71,7 +62,7 @@
|
|||
setCookie.bind(this)('uhr-status', 'on');
|
||||
}
|
||||
};
|
||||
stop = function stop() {
|
||||
var stop = function stop() {
|
||||
if (isOn.bind(this)()) {
|
||||
window.clearInterval(this.timer);
|
||||
this.timer = null;
|
||||
|
@ -79,14 +70,14 @@
|
|||
setCookie.bind(this)('uhr-status', 'off');
|
||||
}
|
||||
};
|
||||
toggle = function toggle() {
|
||||
var toggle = function toggle() {
|
||||
if (isOn.bind(this)()) {
|
||||
this.stop();
|
||||
} else {
|
||||
this.start();
|
||||
}
|
||||
};
|
||||
setLanguage = function setLanguage(languageKey) {
|
||||
var setLanguage = function setLanguage(languageKey) {
|
||||
if (languageKey !== this.options.language) {
|
||||
this.options.language = languageKey;
|
||||
var renderer = new UhrRenderer(language.bind(this)(), this.element.find('.letterarea'));
|
||||
|
@ -98,7 +89,7 @@
|
|||
update.bind(this)();
|
||||
}
|
||||
};
|
||||
setTheme = function setTheme(theme) {
|
||||
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);
|
||||
|
@ -106,7 +97,7 @@
|
|||
setCookie.bind(this)('uhr-theme', theme);
|
||||
}
|
||||
};
|
||||
setTime = function setTime(time) {
|
||||
var setTime = function setTime(time) {
|
||||
this.currentMinute = -1;
|
||||
if (time === null) {
|
||||
this.options.time = new Date();
|
||||
|
@ -118,13 +109,13 @@
|
|||
}
|
||||
update.bind(this)();
|
||||
};
|
||||
setMode = function(mode) {
|
||||
var setMode = function(mode) {
|
||||
this.options.mode = mode;
|
||||
this.currentMinute = -1;
|
||||
update.bind(this)();
|
||||
setCookie.bind(this)('uhr-mode', mode);
|
||||
};
|
||||
setWidth = function setWidth(width) {
|
||||
var setWidth = function setWidth(width) {
|
||||
var e = this.element;
|
||||
e.css('width', width);
|
||||
var realWidth = e.width();
|
||||
|
@ -134,7 +125,7 @@
|
|||
};
|
||||
|
||||
// private interface methods
|
||||
create = function create() {
|
||||
var create = function create() {
|
||||
this.id = uhrGlobals.id++;
|
||||
this.timer = null;
|
||||
this.currentMinute = -1;
|
||||
|
@ -185,11 +176,11 @@
|
|||
}
|
||||
};
|
||||
// private helper methods (not exported)
|
||||
toggleConfigScreen = function toggleConfigScreen() {
|
||||
var toggleConfigScreen = function toggleConfigScreen() {
|
||||
$('#uhr-controlpanel' + this.id).toggle('fast');
|
||||
};
|
||||
// set up
|
||||
setupHTML = function setupHTML() {
|
||||
var setupHTML = function setupHTML() {
|
||||
var e = this.element;
|
||||
// Base clock area
|
||||
e.addClass('uhr');
|
||||
|
@ -253,7 +244,7 @@
|
|||
e.after(configlink);
|
||||
}
|
||||
};
|
||||
wireFunctionality = function wireFunctionality() {
|
||||
var wireFunctionality = function wireFunctionality() {
|
||||
// on/off switch
|
||||
var toggleSwitch = $('#uhr-onoffswitch-checkbox' + this.id);
|
||||
toggleSwitch.on('click', function() {
|
||||
|
@ -353,7 +344,7 @@
|
|||
}.bind(this));
|
||||
}
|
||||
};
|
||||
destroy = function destroy() {
|
||||
var destroy = function destroy() {
|
||||
this.timer = null;
|
||||
$(this.element)
|
||||
.removeAttr('style')
|
||||
|
@ -363,7 +354,7 @@
|
|||
$('#uhr-controlpanel' + this.id).remove();
|
||||
|
||||
};
|
||||
setCookie = function setCookie(cookieName, cookieValue) {
|
||||
var setCookie = function setCookie(cookieName, cookieValue) {
|
||||
var options = {};
|
||||
if (this.options.cookiePath !== undefined) {
|
||||
options = {expires: 365, path: this.options.cookiePath};
|
||||
|
@ -374,10 +365,10 @@
|
|||
};
|
||||
|
||||
// business logic
|
||||
isOn = function isOn() {
|
||||
var isOn = function isOn() {
|
||||
return this.timer !== null;
|
||||
};
|
||||
update = function update() {
|
||||
var update = function update() {
|
||||
if (isOn.bind(this)()) {
|
||||
var time = this.options.time;
|
||||
if (!language.bind(this)().hasOwnProperty('seconds') && this.options.mode !== 'seconds') {
|
||||
|
@ -392,7 +383,7 @@
|
|||
this.currentMinute = -1;
|
||||
}
|
||||
};
|
||||
show = function show(time) {
|
||||
var show = function show(time) {
|
||||
var second = getSecond.bind(this)(time);
|
||||
var dotMinute = getDotMinute.bind(this)(time);
|
||||
var hour = getHour.bind(this)(time);
|
||||
|
@ -409,32 +400,32 @@
|
|||
highlight.bind(this)('hour' + hour);
|
||||
}
|
||||
};
|
||||
highlight = function highlight(itemClass) {
|
||||
var highlight = function highlight(itemClass) {
|
||||
this.element.find('.item.' + itemClass).addClass('active');
|
||||
};
|
||||
clear = function clear() {
|
||||
var clear = function clear() {
|
||||
this.element.find('.item').removeClass('active');
|
||||
};
|
||||
getSecond = function getSecond(date) {
|
||||
var getSecond = function getSecond(date) {
|
||||
if (typeof language.bind(this)().getSeconds === 'function') {
|
||||
return language.bind(this)().getSeconds(date);
|
||||
}
|
||||
return date.getSeconds();
|
||||
};
|
||||
getDotMinute = function getDotMinute(date) {
|
||||
var getDotMinute = function getDotMinute(date) {
|
||||
if (typeof language.bind(this)().getDotMinute === 'function') {
|
||||
return language.bind(this)().getDotMinute(date);
|
||||
}
|
||||
var minutes = date.getMinutes();
|
||||
return minutes % 5;
|
||||
};
|
||||
getCoarseMinute = function getCoarseMinute(date) {
|
||||
var getCoarseMinute = function getCoarseMinute(date) {
|
||||
if (typeof language.bind(this)().getCoarseMinute === 'function') {
|
||||
return language.bind(this)().getCoarseMinute(date);
|
||||
}
|
||||
return date.getMinutes();
|
||||
};
|
||||
getHour = function getHour(date) {
|
||||
var getHour = function getHour(date) {
|
||||
if (typeof language.bind(this)().getHour === 'function') {
|
||||
return language.bind(this)().getHour(date);
|
||||
}
|
||||
|
@ -444,7 +435,7 @@
|
|||
}
|
||||
return hour;
|
||||
};
|
||||
language = function language() {
|
||||
var language = function language() {
|
||||
var matchingLanguages = uhrGlobals.languages.filter(function(element) {
|
||||
return (element.code === this.options.language);
|
||||
}, this);
|
||||
|
@ -486,7 +477,7 @@
|
|||
* @param layout Layout-Objekt, das gerendert werden soll.
|
||||
* @param renderarea Das jQuery-gewrappte HTML-Element, auf dem gerendert werden soll.
|
||||
*/
|
||||
UhrRenderer = function UhrRenderer(layout, renderarea) {
|
||||
function UhrRenderer(layout, renderarea) {
|
||||
this.render = function render(beforeshow) {
|
||||
if (layout.parsed === undefined) {
|
||||
switch (layout.version) {
|
||||
|
@ -519,7 +510,7 @@
|
|||
};
|
||||
};
|
||||
|
||||
UhrRendererV2Delegate = function UhrRendererV2Delegate(layout) {
|
||||
function UhrRendererV2Delegate(layout) {
|
||||
var vorne0 = {
|
||||
3: [2, 3, 4],
|
||||
4: [1, 5],
|
||||
|
@ -791,7 +782,7 @@
|
|||
* @param value Der Buchstabe, der Dargestellt werden soll.
|
||||
* @param style Die CSS-Styleklassen des Buchstabens.
|
||||
*/
|
||||
Letter = function Letter(value, style) {
|
||||
function Letter(value, style) {
|
||||
var myValue = value;
|
||||
var myStyle = style || '';
|
||||
this.addStyle = function(style) {
|
||||
|
|
Loading…
Reference in a new issue