Enable linting
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Manuel Friedli 2019-05-05 12:18:46 +02:00
parent f344cdb3f8
commit 174e0d9af2
11 changed files with 866 additions and 242 deletions

47
.eslintrc.json Normal file
View file

@ -0,0 +1,47 @@
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"parser": "@typescript-eslint/parser",
"env": {
"browser": true
},
"rules": {
"curly": "error",
"deprecation": true,
"eofline": true,
"file-header": [
true,
{
"match": " This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program. If not, see <http://www.gnu.org/licenses/>.\n",
"enforce-trailing-newline": true
}
],
"member-ordering": [
true,
{
"order": "fields-first",
"alphabetize": true
}
],
"prefer-for-of": true,
"static-this": true,
"triple-equals": true,
"typeof-compare": true,
"prefer-const": "warn",
"prefer-readonly": true,
"array-type": [
true,
"array"
],
"arrow-return-shorthand": [
true,
"multiline"
],
"quotes": [
"warn",
"single"
]
}
}

34
dist/bundle.js vendored

File diff suppressed because one or more lines are too long

800
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -34,8 +34,10 @@
"@types/jquery": "3.3.29",
"@types/jqueryui": "1.12.7",
"@types/js-cookie": "2.2.2",
"@typescript-eslint/parser": "1.7.0",
"chai": "4.2.0",
"jshint-stylish": "2.2.1",
"eslint": "5.16.0",
"eslint-loader": "2.1.2",
"mocha": "6.1.4",
"phantomjs-prebuilt": "2.1.16",
"ts-loader": "5.4.5",

View file

@ -13,8 +13,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {Layout} from "./layout";
import {Theme} from "./theme";
import {Layout} from './layout';
import {Theme} from './theme';
export class Globals {
private static layouts: Layout[] = [];

View file

@ -13,7 +13,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {Letter} from "./letter";
import {Letter} from './letter';
export interface Layout {
readonly code: string;

View file

@ -13,21 +13,21 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {Globals} from "./domain/globals";
import {autodetectThemes} from "./theme-autodetector";
import {Uhr} from "./uhr";
import {WidgetPrototype} from "./widget/widget-prototype";
import {Layout} from "./domain/layout";
import {Layout_de_CH} from "./layout/layout-de_ch";
import {Layout_de_CH_genau} from "./layout/layout-de_ch_genau";
import {Layout_de} from "./layout/layout-de";
import {Layout_dk} from "./layout/layout-dk";
import {Layout_en} from "./layout/layout-en";
import {Layout_es} from "./layout/layout-es";
import {Layout_fr} from "./layout/layout-fr";
import {Layout_it} from "./layout/layout-it";
import {Layout_nl} from "./layout/layout-nl";
import {Layout_pt} from "./layout/layout-pt";
import {Globals} from './domain/globals';
import {autodetectThemes} from './theme-autodetector';
import {Uhr} from './uhr';
import {WidgetPrototype} from './widget/widget-prototype';
import {Layout} from './domain/layout';
import {Layout_de_CH} from './layout/layout-de_ch';
import {Layout_de_CH_genau} from './layout/layout-de_ch_genau';
import {Layout_de} from './layout/layout-de';
import {Layout_dk} from './layout/layout-dk';
import {Layout_en} from './layout/layout-en';
import {Layout_es} from './layout/layout-es';
import {Layout_fr} from './layout/layout-fr';
import {Layout_it} from './layout/layout-it';
import {Layout_nl} from './layout/layout-nl';
import {Layout_pt} from './layout/layout-pt';
// First things first: discover included themes and register them
autodetectThemes();
@ -44,8 +44,8 @@ Globals.registerLayout(Layout_it);
Globals.registerLayout(Layout_nl);
Globals.registerLayout(Layout_pt);
$.widget("fritteli.uhr", {
"options": {
$.widget('fritteli.uhr', {
options: {
width: '100%',
status: 'on',
language: 'de_CH',
@ -56,39 +56,39 @@ $.widget("fritteli.uhr", {
autoresize: true,
mode: 'normal'
},
"start": function () {
start: function () {
this.__fritteli_uhr_instance.start();
},
"stop": function () {
stop: function () {
this.__fritteli_uhr_instance.stop();
},
"toggle": function () {
toggle: function () {
this.__fritteli_uhr_instance.toggle();
},
"language": function (key: string) {
language: function (key: string) {
this.__fritteli_uhr_instance.setLanguage(key);
},
"theme": function (styleClass: string) {
theme: function (styleClass: string) {
this.__fritteli_uhr_instance.setTheme(styleClass);
},
"time": function (time: Date) {
time: function (time: Date) {
this.__fritteli_uhr_instance.setTime(time);
},
"mode": function (mode: string) {
mode: function (mode: string) {
this.__fritteli_uhr_instance.setMode(mode);
},
"width": function (width: string) {
width: function (width: string) {
this.__fritteli_uhr_instance.setWidth(width);
},
// constructor method
"_create": function () {
_create: function () {
this.__fritteli_uhr_instance = new Uhr(this);
},
// destructor method
"_destroy": function () {
_destroy: function () {
this.__fritteli_uhr_instance.destroy();
},
"__fritteli_uhr_instance": null
__fritteli_uhr_instance: null
} as WidgetPrototype);
$.fritteli.uhr.register = Globals.registerLayout;

View file

@ -13,8 +13,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {Layout, TimeDefinition, WordDefinition} from "./domain/layout";
import {Letter} from "./domain/letter";
import {Layout, TimeDefinition, WordDefinition} from './domain/layout';
import {Letter} from './domain/letter';
class UhrRendererV2Delegate {
private static readonly vorne0: WordDefinition = {
@ -162,66 +162,66 @@ class UhrRendererV2Delegate {
9: [8, 9]
};
private static readonly seconds: TimeDefinition = {
"0": [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten0],
"1": [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten1],
"2": [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten2],
"3": [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten3],
"4": [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten4],
"5": [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten5],
"6": [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten6],
"7": [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten7],
"8": [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten8],
"9": [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten9],
"10": [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten0],
"11": [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten1],
"12": [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten2],
"13": [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten3],
"14": [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten4],
"15": [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten5],
"16": [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten6],
"17": [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten7],
"18": [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten8],
"19": [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten9],
"20": [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten0],
"21": [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten1],
"22": [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten2],
"23": [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten3],
"24": [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten4],
"25": [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten5],
"26": [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten6],
"27": [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten7],
"28": [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten8],
"29": [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten9],
"30": [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten0],
"31": [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten1],
"32": [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten2],
"33": [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten3],
"34": [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten4],
"35": [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten5],
"36": [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten6],
"37": [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten7],
"38": [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten8],
"39": [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten9],
"40": [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten0],
"41": [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten1],
"42": [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten2],
"43": [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten3],
"44": [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten4],
"45": [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten5],
"46": [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten6],
"47": [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten7],
"48": [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten8],
"49": [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten9],
"50": [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten0],
"51": [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten1],
"52": [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten2],
"53": [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten3],
"54": [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten4],
"55": [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten5],
"56": [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten6],
"57": [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten7],
"58": [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten8],
"59": [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten9]
'0': [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten0],
'1': [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten1],
'2': [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten2],
'3': [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten3],
'4': [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten4],
'5': [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten5],
'6': [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten6],
'7': [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten7],
'8': [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten8],
'9': [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten9],
'10': [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten0],
'11': [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten1],
'12': [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten2],
'13': [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten3],
'14': [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten4],
'15': [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten5],
'16': [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten6],
'17': [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten7],
'18': [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten8],
'19': [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten9],
'20': [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten0],
'21': [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten1],
'22': [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten2],
'23': [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten3],
'24': [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten4],
'25': [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten5],
'26': [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten6],
'27': [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten7],
'28': [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten8],
'29': [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten9],
'30': [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten0],
'31': [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten1],
'32': [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten2],
'33': [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten3],
'34': [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten4],
'35': [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten5],
'36': [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten6],
'37': [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten7],
'38': [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten8],
'39': [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten9],
'40': [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten0],
'41': [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten1],
'42': [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten2],
'43': [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten3],
'44': [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten4],
'45': [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten5],
'46': [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten6],
'47': [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten7],
'48': [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten8],
'49': [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten9],
'50': [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten0],
'51': [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten1],
'52': [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten2],
'53': [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten3],
'54': [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten4],
'55': [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten5],
'56': [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten6],
'57': [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten7],
'58': [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten8],
'59': [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten9]
};
constructor(private layout: Layout) {
@ -294,10 +294,10 @@ export class UhrRenderer {
if (this.layout.version === 2) {
const delegate: UhrRendererV2Delegate = new UhrRendererV2Delegate(this.layout);
const parsedLayout: Letter[][] = delegate.parse();
Object.defineProperty(this.layout, "parsed", {
"value": parsedLayout,
"writable": false,
"configurable": false
Object.defineProperty(this.layout, 'parsed', {
value: parsedLayout,
writable: false,
configurable: false
});
} else {
console.warn(`Unknown layout version: '${this.layout.version}', expecting '2'`);
@ -313,7 +313,7 @@ export class UhrRenderer {
this.renderarea.append('<br/>');
}
});
if (typeof beforeshow === 'function') {
if (!!beforeshow) {
beforeshow();
}
this.renderarea.fadeIn('fast');

View file

@ -14,7 +14,7 @@
*/
import * as $ from 'jquery';
import {Globals} from "./domain/globals";
import {Globals} from './domain/globals';
export function autodetectThemes() {
$('link[rel=stylesheet]').each((index, item) => {

View file

@ -13,11 +13,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {WidgetPrototype} from "./widget/widget-prototype";
import {Globals} from "./domain/globals";
import {UhrRenderer} from "./renderer";
import {EMPTY_LAYOUT, Layout} from "./domain/layout";
import * as Cookies from "js-cookie";
import {WidgetPrototype} from './widget/widget-prototype';
import {Globals} from './domain/globals';
import {UhrRenderer} from './renderer';
import {EMPTY_LAYOUT, Layout} from './domain/layout';
import * as Cookies from 'js-cookie';
export class Uhr {
@ -249,7 +249,7 @@ export class Uhr {
selectedLayout = fallbackLanguage;
}
languageChooser.val(selectedLayout);
this.widgetInstance.options.language = "";
this.widgetInstance.options.language = '';
this.setLanguage(selectedLayout);
// theme chooser
@ -270,7 +270,7 @@ export class Uhr {
selectedTheme = fallbackTheme;
}
themeChooser.val(selectedTheme);
this.widgetInstance.options.theme = "";
this.widgetInstance.options.theme = '';
this.setTheme(selectedTheme);
if (this.widgetInstance.options.autoresize) {
// FIXME deprecated!?

View file

@ -9,13 +9,18 @@ module.exports = {
'./src/index.ts',
'./node_modules/jquery/dist/jquery.js'
],
devtool: "inline-source-map",
devtool: 'inline-source-map',
module: {
rules: [
{
enforce: 'pre',
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
exclude: /node_modules/,
use: 'eslint-loader'
}, {
test: /\.tsx?$/,
exclude: /node_modules/,
use: 'ts-loader'
}
]
},