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