Rename renderer.ts to layout-renderer.ts and also rename the class

accordingly. This is more precise.
This commit is contained in:
Manuel Friedli 2019-05-09 20:14:57 +02:00
parent e83a37fd85
commit 7a16ac2c0a
2 changed files with 67 additions and 67 deletions

View file

@ -16,7 +16,7 @@
import {Layout, TimeDefinition, WordDefinition} from './domain/layout'; import {Layout, TimeDefinition, WordDefinition} from './domain/layout';
import {Letter} from './domain/letter'; import {Letter} from './domain/letter';
class UhrRendererV2Delegate { class LayoutRendererV2Delegate {
private static readonly vorne0: WordDefinition = { private static readonly vorne0: WordDefinition = {
3: [2, 3, 4], 3: [2, 3, 4],
4: [1, 5], 4: [1, 5],
@ -162,66 +162,66 @@ class UhrRendererV2Delegate {
9: [8, 9] 9: [8, 9]
}; };
private static readonly seconds: TimeDefinition = { private static readonly seconds: TimeDefinition = {
'0': [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten0], '0': [LayoutRendererV2Delegate.vorne0, LayoutRendererV2Delegate.hinten0],
'1': [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten1], '1': [LayoutRendererV2Delegate.vorne0, LayoutRendererV2Delegate.hinten1],
'2': [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten2], '2': [LayoutRendererV2Delegate.vorne0, LayoutRendererV2Delegate.hinten2],
'3': [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten3], '3': [LayoutRendererV2Delegate.vorne0, LayoutRendererV2Delegate.hinten3],
'4': [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten4], '4': [LayoutRendererV2Delegate.vorne0, LayoutRendererV2Delegate.hinten4],
'5': [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten5], '5': [LayoutRendererV2Delegate.vorne0, LayoutRendererV2Delegate.hinten5],
'6': [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten6], '6': [LayoutRendererV2Delegate.vorne0, LayoutRendererV2Delegate.hinten6],
'7': [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten7], '7': [LayoutRendererV2Delegate.vorne0, LayoutRendererV2Delegate.hinten7],
'8': [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten8], '8': [LayoutRendererV2Delegate.vorne0, LayoutRendererV2Delegate.hinten8],
'9': [UhrRendererV2Delegate.vorne0, UhrRendererV2Delegate.hinten9], '9': [LayoutRendererV2Delegate.vorne0, LayoutRendererV2Delegate.hinten9],
'10': [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten0], '10': [LayoutRendererV2Delegate.vorne1, LayoutRendererV2Delegate.hinten0],
'11': [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten1], '11': [LayoutRendererV2Delegate.vorne1, LayoutRendererV2Delegate.hinten1],
'12': [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten2], '12': [LayoutRendererV2Delegate.vorne1, LayoutRendererV2Delegate.hinten2],
'13': [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten3], '13': [LayoutRendererV2Delegate.vorne1, LayoutRendererV2Delegate.hinten3],
'14': [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten4], '14': [LayoutRendererV2Delegate.vorne1, LayoutRendererV2Delegate.hinten4],
'15': [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten5], '15': [LayoutRendererV2Delegate.vorne1, LayoutRendererV2Delegate.hinten5],
'16': [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten6], '16': [LayoutRendererV2Delegate.vorne1, LayoutRendererV2Delegate.hinten6],
'17': [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten7], '17': [LayoutRendererV2Delegate.vorne1, LayoutRendererV2Delegate.hinten7],
'18': [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten8], '18': [LayoutRendererV2Delegate.vorne1, LayoutRendererV2Delegate.hinten8],
'19': [UhrRendererV2Delegate.vorne1, UhrRendererV2Delegate.hinten9], '19': [LayoutRendererV2Delegate.vorne1, LayoutRendererV2Delegate.hinten9],
'20': [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten0], '20': [LayoutRendererV2Delegate.vorne2, LayoutRendererV2Delegate.hinten0],
'21': [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten1], '21': [LayoutRendererV2Delegate.vorne2, LayoutRendererV2Delegate.hinten1],
'22': [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten2], '22': [LayoutRendererV2Delegate.vorne2, LayoutRendererV2Delegate.hinten2],
'23': [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten3], '23': [LayoutRendererV2Delegate.vorne2, LayoutRendererV2Delegate.hinten3],
'24': [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten4], '24': [LayoutRendererV2Delegate.vorne2, LayoutRendererV2Delegate.hinten4],
'25': [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten5], '25': [LayoutRendererV2Delegate.vorne2, LayoutRendererV2Delegate.hinten5],
'26': [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten6], '26': [LayoutRendererV2Delegate.vorne2, LayoutRendererV2Delegate.hinten6],
'27': [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten7], '27': [LayoutRendererV2Delegate.vorne2, LayoutRendererV2Delegate.hinten7],
'28': [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten8], '28': [LayoutRendererV2Delegate.vorne2, LayoutRendererV2Delegate.hinten8],
'29': [UhrRendererV2Delegate.vorne2, UhrRendererV2Delegate.hinten9], '29': [LayoutRendererV2Delegate.vorne2, LayoutRendererV2Delegate.hinten9],
'30': [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten0], '30': [LayoutRendererV2Delegate.vorne3, LayoutRendererV2Delegate.hinten0],
'31': [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten1], '31': [LayoutRendererV2Delegate.vorne3, LayoutRendererV2Delegate.hinten1],
'32': [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten2], '32': [LayoutRendererV2Delegate.vorne3, LayoutRendererV2Delegate.hinten2],
'33': [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten3], '33': [LayoutRendererV2Delegate.vorne3, LayoutRendererV2Delegate.hinten3],
'34': [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten4], '34': [LayoutRendererV2Delegate.vorne3, LayoutRendererV2Delegate.hinten4],
'35': [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten5], '35': [LayoutRendererV2Delegate.vorne3, LayoutRendererV2Delegate.hinten5],
'36': [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten6], '36': [LayoutRendererV2Delegate.vorne3, LayoutRendererV2Delegate.hinten6],
'37': [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten7], '37': [LayoutRendererV2Delegate.vorne3, LayoutRendererV2Delegate.hinten7],
'38': [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten8], '38': [LayoutRendererV2Delegate.vorne3, LayoutRendererV2Delegate.hinten8],
'39': [UhrRendererV2Delegate.vorne3, UhrRendererV2Delegate.hinten9], '39': [LayoutRendererV2Delegate.vorne3, LayoutRendererV2Delegate.hinten9],
'40': [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten0], '40': [LayoutRendererV2Delegate.vorne4, LayoutRendererV2Delegate.hinten0],
'41': [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten1], '41': [LayoutRendererV2Delegate.vorne4, LayoutRendererV2Delegate.hinten1],
'42': [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten2], '42': [LayoutRendererV2Delegate.vorne4, LayoutRendererV2Delegate.hinten2],
'43': [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten3], '43': [LayoutRendererV2Delegate.vorne4, LayoutRendererV2Delegate.hinten3],
'44': [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten4], '44': [LayoutRendererV2Delegate.vorne4, LayoutRendererV2Delegate.hinten4],
'45': [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten5], '45': [LayoutRendererV2Delegate.vorne4, LayoutRendererV2Delegate.hinten5],
'46': [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten6], '46': [LayoutRendererV2Delegate.vorne4, LayoutRendererV2Delegate.hinten6],
'47': [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten7], '47': [LayoutRendererV2Delegate.vorne4, LayoutRendererV2Delegate.hinten7],
'48': [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten8], '48': [LayoutRendererV2Delegate.vorne4, LayoutRendererV2Delegate.hinten8],
'49': [UhrRendererV2Delegate.vorne4, UhrRendererV2Delegate.hinten9], '49': [LayoutRendererV2Delegate.vorne4, LayoutRendererV2Delegate.hinten9],
'50': [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten0], '50': [LayoutRendererV2Delegate.vorne5, LayoutRendererV2Delegate.hinten0],
'51': [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten1], '51': [LayoutRendererV2Delegate.vorne5, LayoutRendererV2Delegate.hinten1],
'52': [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten2], '52': [LayoutRendererV2Delegate.vorne5, LayoutRendererV2Delegate.hinten2],
'53': [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten3], '53': [LayoutRendererV2Delegate.vorne5, LayoutRendererV2Delegate.hinten3],
'54': [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten4], '54': [LayoutRendererV2Delegate.vorne5, LayoutRendererV2Delegate.hinten4],
'55': [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten5], '55': [LayoutRendererV2Delegate.vorne5, LayoutRendererV2Delegate.hinten5],
'56': [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten6], '56': [LayoutRendererV2Delegate.vorne5, LayoutRendererV2Delegate.hinten6],
'57': [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten7], '57': [LayoutRendererV2Delegate.vorne5, LayoutRendererV2Delegate.hinten7],
'58': [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten8], '58': [LayoutRendererV2Delegate.vorne5, LayoutRendererV2Delegate.hinten8],
'59': [UhrRendererV2Delegate.vorne5, UhrRendererV2Delegate.hinten9] '59': [LayoutRendererV2Delegate.vorne5, LayoutRendererV2Delegate.hinten9]
}; };
constructor(private layout: Layout) { constructor(private layout: Layout) {
@ -240,7 +240,7 @@ class UhrRendererV2Delegate {
if (typeof this.layout.seconds !== 'undefined' && this.layout.seconds !== null) { if (typeof this.layout.seconds !== 'undefined' && this.layout.seconds !== null) {
this.parseTimeDefinition(letters, 'second', this.layout.seconds); this.parseTimeDefinition(letters, 'second', this.layout.seconds);
} else { } else {
this.parseTimeDefinition(letters, 'second', UhrRendererV2Delegate.seconds); this.parseTimeDefinition(letters, 'second', LayoutRendererV2Delegate.seconds);
} }
this.parseTimeDefinition(letters, 'minute', this.layout.minutes); this.parseTimeDefinition(letters, 'minute', this.layout.minutes);
this.parseTimeDefinition(letters, 'hour', this.layout.hours); this.parseTimeDefinition(letters, 'hour', this.layout.hours);
@ -281,18 +281,18 @@ class UhrRendererV2Delegate {
} }
/** /**
* Hilfsklasse zum Rendern der Uhr. * Hilfsklasse zum Rendern der Buchstaben der Uhr.
* @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.
*/ */
export class UhrRenderer { export class LayoutRenderer {
constructor(private layout: Layout, private renderarea: JQuery<HTMLElement>) { constructor(private layout: Layout, private renderarea: JQuery<HTMLElement>) {
} }
render(beforeshow?: () => void): void { render(beforeshow?: () => void): void {
if (this.layout.parsed === undefined) { if (this.layout.parsed === undefined) {
if (this.layout.version === 2) { if (this.layout.version === 2) {
const delegate: UhrRendererV2Delegate = new UhrRendererV2Delegate(this.layout); const delegate: LayoutRendererV2Delegate = new LayoutRendererV2Delegate(this.layout);
const parsedLayout: Letter[][] = delegate.parse(); const parsedLayout: Letter[][] = delegate.parse();
Object.defineProperty(this.layout, 'parsed', { Object.defineProperty(this.layout, 'parsed', {
value: parsedLayout, value: parsedLayout,

View file

@ -16,7 +16,7 @@
import * as Cookies from 'js-cookie'; import * as Cookies from 'js-cookie';
import {EMPTY_LAYOUT, Layout} from './domain/layout'; import {EMPTY_LAYOUT, Layout} from './domain/layout';
import {Globals} from './domain/globals'; import {Globals} from './domain/globals';
import {UhrRenderer} from './renderer'; import {LayoutRenderer} from './layout-renderer';
import {WidgetPrototype} from './widget/widget-prototype'; import {WidgetPrototype} from './widget/widget-prototype';
export class Uhr { export class Uhr {
@ -81,7 +81,7 @@ export class Uhr {
setLanguage(key: string): void { setLanguage(key: string): void {
if (key !== this.widgetInstance.options.language) { if (key !== this.widgetInstance.options.language) {
this.widgetInstance.options.language = key; this.widgetInstance.options.language = key;
const renderer = new UhrRenderer(this.getCurrentLayout(), this.widgetInstance.element.find('.letterarea')); const renderer = new LayoutRenderer(this.getCurrentLayout(), this.widgetInstance.element.find('.letterarea'));
renderer.render(() => { renderer.render(() => {
this.currentMinute = -1; this.currentMinute = -1;
this.update(); this.update();