get rid of linting errors, hopefully

This commit is contained in:
Manuel Friedli 2016-06-26 23:22:05 +02:00
parent 63cbc1da3c
commit 0b26225c87

View file

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