Add new tslint rules and fix rule breaks

This commit is contained in:
József Farkas
2017-03-18 23:43:32 +01:00
parent 0e8165a0b4
commit ca31e5bb4d
44 changed files with 127 additions and 142 deletions

View File

@@ -67,7 +67,7 @@ export class KeymapEditComponent extends SharedKeymapEditComponent {
.do(response => console.log('Sending layer finished', response)) .do(response => console.log('Sending layer finished', response))
.switchMap(() => this.uhkDevice.applyConfig()) .switchMap(() => this.uhkDevice.applyConfig())
.subscribe( .subscribe(
(response) => console.log('Applying layer finished', response), response => console.log('Applying layer finished', response),
error => console.error('Error during uploading layer', error), error => console.error('Error during uploading layer', error),
() => console.log('Layer has been sucessfully uploaded') () => console.log('Layer has been sucessfully uploaded')
); );
@@ -85,7 +85,7 @@ export class KeymapEditComponent extends SharedKeymapEditComponent {
.do(response => console.log('Sending keymap finished', response)) .do(response => console.log('Sending keymap finished', response))
.switchMap(() => this.uhkDevice.applyConfig()) .switchMap(() => this.uhkDevice.applyConfig())
.subscribe( .subscribe(
(response) => console.log('Applying keymap finished', response), response => console.log('Applying keymap finished', response),
error => console.error('Error during uploading keymap', error), error => console.error('Error during uploading keymap', error),
() => console.log('Keymap has been sucessfully uploaded') () => console.log('Keymap has been sucessfully uploaded')
); );

View File

@@ -24,7 +24,7 @@ function createWindow() {
win.loadURL(`file://${indexPath}`); win.loadURL(`file://${indexPath}`);
win.on('page-title-updated', (event) => { win.on('page-title-updated', event => {
event.preventDefault(); event.preventDefault();
}); });

View File

@@ -54,7 +54,7 @@ export class MainAppComponent {
.do(response => console.log('Sending user configuration finished', response)) .do(response => console.log('Sending user configuration finished', response))
.switchMap(() => this.uhkDevice.applyConfig()) .switchMap(() => this.uhkDevice.applyConfig())
.subscribe( .subscribe(
(response) => console.log('Applying user configuration finished', response), response => console.log('Applying user configuration finished', response),
error => console.error('Error during uploading user configuration', error), error => console.error('Error during uploading user configuration', error),
() => console.log('User configuration has been sucessfully uploaded') () => console.log('User configuration has been sucessfully uploaded')
); );

View File

@@ -115,7 +115,7 @@ export class UhkDeviceService implements OnDestroy {
const outSending = this.messageOut$.concatMap(senderPackage => { const outSending = this.messageOut$.concatMap(senderPackage => {
return (<Observable<void>>Observable.create((subscriber: Subscriber<void>) => { return (<Observable<void>>Observable.create((subscriber: Subscriber<void>) => {
console.log('transfering', senderPackage.buffer); console.log('transfering', senderPackage.buffer);
outEndPoint.transfer(senderPackage.buffer, (error) => { outEndPoint.transfer(senderPackage.buffer, error => {
if (error) { if (error) {
console.error('transfering errored', error); console.error('transfering errored', error);
subscriber.error(error); subscriber.error(error);

View File

@@ -12,9 +12,9 @@ import { Observable } from 'rxjs/Observable';
} }
}) })
export class AddOnComponent { export class AddOnComponent {
private name$: Observable<string>; name$: Observable<string>;
constructor(private route: ActivatedRoute) { constructor(route: ActivatedRoute) {
this.name$ = route this.name$ = route
.params .params
.select<string>('name'); .select<string>('name');

View File

@@ -32,7 +32,7 @@ export class KeymapEditComponent {
constructor( constructor(
protected store: Store<AppState>, protected store: Store<AppState>,
private route: ActivatedRoute route: ActivatedRoute
) { ) {
this.keymap$ = route this.keymap$ = route
.params .params

View File

@@ -29,18 +29,16 @@ export class MacroActionEditorComponent implements OnInit {
@ViewChild('tab') selectedTab: any; @ViewChild('tab') selectedTab: any;
private editableMacroAction: EditableMacroAction; editableMacroAction: EditableMacroAction;
private activeTab: TabName; activeTab: TabName;
/* tslint:disable:variable-name: It is an enum type. So it can start with uppercase. */ /* tslint:disable:variable-name: It is an enum type. So it can start with uppercase. */
/* tslint:disable:no-unused-variable: It is used in the template. */ TabName = TabName;
private TabName = TabName;
/* tslint:enable:no-unused-variable */
/* tslint:enable:variable-name */ /* tslint:enable:variable-name */
ngOnInit() { ngOnInit() {
let macroAction: MacroAction = this.macroAction ? this.macroAction : new TextMacroAction(); const macroAction: MacroAction = this.macroAction ? this.macroAction : new TextMacroAction();
this.editableMacroAction = new EditableMacroAction(macroAction.toJsonObject()); this.editableMacroAction = new EditableMacroAction(macroAction.toJsonObject());
let tab: TabName = this.getTabName(this.editableMacroAction); const tab: TabName = this.getTabName(this.editableMacroAction);
this.activeTab = tab; this.activeTab = tab;
} }

View File

@@ -22,10 +22,8 @@ export class MacroDelayTabComponent implements OnInit {
@Input() macroAction: EditableMacroAction; @Input() macroAction: EditableMacroAction;
@ViewChild('macroDelayInput') input: ElementRef; @ViewChild('macroDelayInput') input: ElementRef;
private delay: number; delay: number;
/* tslint:disable:no-unused-variable: It is used in the template. */ presets: number[] = [0.3, 0.5, 0.8, 1, 2, 3, 4, 5];
private presets: number[] = [0.3, 0.5, 0.8, 1, 2, 3, 4, 5];
/* tslint:enable:no-unused-variable */
constructor() { } constructor() { }

View File

@@ -25,14 +25,11 @@ export class MacroKeyTabComponent implements OnInit {
@ViewChild('tab') selectedTab: Tab; @ViewChild('tab') selectedTab: Tab;
@ViewChild('keypressTab') keypressTab: KeypressTabComponent; @ViewChild('keypressTab') keypressTab: KeypressTabComponent;
private defaultKeyAction: KeyAction;
private activeTab: TabName;
/* tslint:disable:variable-name: It is an enum type. So it can start with uppercase. */ /* tslint:disable:variable-name: It is an enum type. So it can start with uppercase. */
/* tslint:disable:no-unused-variable: It is used in the template. */ TabName = TabName;
private TabName = TabName;
/* tslint:enable:no-unused-variable */
/* tslint:enable:variable-name */ /* tslint:enable:variable-name */
activeTab: TabName;
defaultKeyAction: KeyAction;
ngOnInit() { ngOnInit() {
this.defaultKeyAction = this.macroAction.toKeystrokeAction(); this.defaultKeyAction = this.macroAction.toKeystrokeAction();

View File

@@ -24,14 +24,12 @@ export class MacroMouseTabComponent implements OnInit {
@Input() macroAction: EditableMacroAction; @Input() macroAction: EditableMacroAction;
@ViewChild('tab') selectedTab: Tab; @ViewChild('tab') selectedTab: Tab;
/* tslint:disable:variable-name: It is an enum type. So it can start with uppercase. */
TabName = TabName;
/* tslint:enable:variable-name */
private activeTab: TabName; private activeTab: TabName;
private buttonLabels: string[]; private buttonLabels: string[];
private selectedButtons: boolean[]; private selectedButtons: boolean[];
/* tslint:disable:variable-name: It is an enum type. So it can start with uppercase. */
/* tslint:disable:no-unused-variable: It is used in the template. */
private TabName = TabName;
/* tslint:enable:no-unused-variable */
/* tslint:enable:variable-name */
constructor() { constructor() {
this.buttonLabels = ['Left', 'Middle', 'Right']; this.buttonLabels = ['Left', 'Middle', 'Right'];

View File

@@ -106,12 +106,12 @@ export class MacroItemComponent implements OnInit, OnChanges {
} else if (this.macroAction instanceof DelayMacroAction) { } else if (this.macroAction instanceof DelayMacroAction) {
// Delay // Delay
this.iconName = 'clock'; this.iconName = 'clock';
let action: DelayMacroAction = this.macroAction as DelayMacroAction; const action: DelayMacroAction = this.macroAction as DelayMacroAction;
const delay = action.delay > 0 ? action.delay / 1000 : 0; const delay = action.delay > 0 ? action.delay / 1000 : 0;
this.title = `Delay of ${delay}s`; this.title = `Delay of ${delay}s`;
} else if (this.macroAction instanceof TextMacroAction) { } else if (this.macroAction instanceof TextMacroAction) {
// Write text // Write text
let action: TextMacroAction = this.macroAction as TextMacroAction; const action: TextMacroAction = this.macroAction as TextMacroAction;
this.iconName = 'font'; this.iconName = 'font';
this.title = `Write text: ${action.text}`; this.title = `Write text: ${action.text}`;
} else if (this.macroAction instanceof KeyMacroAction) { } else if (this.macroAction instanceof KeyMacroAction) {

View File

@@ -60,7 +60,7 @@ export class MacroListComponent {
private dragIndex: number; private dragIndex: number;
private showNew: boolean = false; private showNew: boolean = false;
constructor(private dragulaService: DragulaService) { constructor(dragulaService: DragulaService) {
/* tslint:disable:no-unused-variable: Used by Dragula. */ /* tslint:disable:no-unused-variable: Used by Dragula. */
dragulaService.setOptions('macroActions', { dragulaService.setOptions('macroActions', {
moves: function (el: any, container: any, handle: any) { moves: function (el: any, container: any, handle: any) {

View File

@@ -90,7 +90,7 @@ export class PopoverComponent implements OnChanges {
private leftPosition: number = 0; private leftPosition: number = 0;
private animationState: string; private animationState: string;
constructor(private store: Store<AppState>) { constructor(store: Store<AppState>) {
this.animationState = 'closed'; this.animationState = 'closed';
this.keymaps$ = store.let(getKeymaps()) this.keymaps$ = store.let(getKeymaps())
.map((keymaps: Keymap[]) => .map((keymaps: Keymap[]) =>
@@ -139,7 +139,7 @@ export class PopoverComponent implements OnChanges {
onRemapKey(): void { onRemapKey(): void {
if (this.keyActionValid) { if (this.keyActionValid) {
try { try {
let keyAction = this.selectedTab.toKeyAction(); const keyAction = this.selectedTab.toKeyAction();
this.remap.emit(keyAction); this.remap.emit(keyAction);
} catch (e) { } catch (e) {
// TODO: show error dialog // TODO: show error dialog

View File

@@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core'; import { ChangeDetectionStrategy, Component, Input, OnChanges, OnInit } from '@angular/core';
import { Select2OptionData } from 'ng2-select2/ng2-select2'; import { Select2OptionData } from 'ng2-select2/ng2-select2';

View File

@@ -1,4 +1,4 @@
import { Component, Input, EventEmitter, OnChanges, Output } from '@angular/core'; import { Component, Input, OnChanges } from '@angular/core';
import { Select2OptionData, Select2TemplateFunction } from 'ng2-select2'; import { Select2OptionData, Select2TemplateFunction } from 'ng2-select2';
@@ -86,11 +86,11 @@ export class KeypressTabComponent extends Tab implements OnChanges {
if (!(keyAction instanceof KeystrokeAction)) { if (!(keyAction instanceof KeystrokeAction)) {
return false; return false;
} }
let keystrokeAction: KeystrokeAction = <KeystrokeAction>keyAction; const keystrokeAction: KeystrokeAction = <KeystrokeAction>keyAction;
// Restore scancode // Restore scancode
this.scanCode = keystrokeAction.scancode || 0; this.scanCode = keystrokeAction.scancode || 0;
let leftModifiersLength: number = this.leftModifiers.length; const leftModifiersLength: number = this.leftModifiers.length;
// Restore modifiers // Restore modifiers
for (let i = 0; i < leftModifiersLength; ++i) { for (let i = 0; i < leftModifiersLength; ++i) {
@@ -98,7 +98,7 @@ export class KeypressTabComponent extends Tab implements OnChanges {
} }
for (let i = leftModifiersLength; i < leftModifiersLength + this.rightModifierSelects.length; ++i) { for (let i = leftModifiersLength; i < leftModifiersLength + this.rightModifierSelects.length; ++i) {
let index: number = this.mapper.modifierMapper(i) - leftModifiersLength; const index: number = this.mapper.modifierMapper(i) - leftModifiersLength;
this.rightModifierSelects[index] = ((keystrokeAction.modifierMask >> i) & 1) === 1; this.rightModifierSelects[index] = ((keystrokeAction.modifierMask >> i) & 1) === 1;
} }
@@ -111,11 +111,11 @@ export class KeypressTabComponent extends Tab implements OnChanges {
} }
toKeyAction(): KeystrokeAction { toKeyAction(): KeystrokeAction {
let keystrokeAction: KeystrokeAction = new KeystrokeAction(); const keystrokeAction: KeystrokeAction = new KeystrokeAction();
keystrokeAction.scancode = this.scanCode; keystrokeAction.scancode = this.scanCode;
keystrokeAction.modifierMask = 0; keystrokeAction.modifierMask = 0;
let modifiers = this.leftModifierSelects.concat(this.rightModifierSelects).map(x => x ? 1 : 0); const modifiers = this.leftModifierSelects.concat(this.rightModifierSelects).map(x => x ? 1 : 0);
for (let i = 0; i < modifiers.length; ++i) { for (let i = 0; i < modifiers.length; ++i) {
keystrokeAction.modifierMask |= modifiers[i] << this.mapper.modifierMapper(i); keystrokeAction.modifierMask |= modifiers[i] << this.mapper.modifierMapper(i);
} }
@@ -149,7 +149,7 @@ export class KeypressTabComponent extends Tab implements OnChanges {
} }
toggleModifier(right: boolean, index: number) { toggleModifier(right: boolean, index: number) {
let modifierSelects: boolean[] = right ? this.rightModifierSelects : this.leftModifierSelects; const modifierSelects: boolean[] = right ? this.rightModifierSelects : this.leftModifierSelects;
modifierSelects[index] = !modifierSelects[index]; modifierSelects[index] = !modifierSelects[index];
this.validAction.emit(this.keyActionValid()); this.validAction.emit(this.keyActionValid());

View File

@@ -1,4 +1,4 @@
import { Component, EventEmitter, HostBinding, Input, OnChanges, Output, SimpleChanges } from '@angular/core'; import { Component, HostBinding, Input, OnChanges, SimpleChanges } from '@angular/core';
import { KeyAction, LayerName, SwitchLayerAction } from '../../../../config-serializer/config-items/key-action'; import { KeyAction, LayerName, SwitchLayerAction } from '../../../../config-serializer/config-items/key-action';
@@ -71,14 +71,14 @@ export class LayerTabComponent extends Tab implements OnChanges {
return false; return false;
} }
let switchLayerAction: SwitchLayerAction = <SwitchLayerAction>keyAction; const switchLayerAction: SwitchLayerAction = <SwitchLayerAction>keyAction;
this.toggle = switchLayerAction.isLayerToggleable; this.toggle = switchLayerAction.isLayerToggleable;
this.layer = switchLayerAction.layer; this.layer = switchLayerAction.layer;
return true; return true;
} }
toKeyAction(): SwitchLayerAction { toKeyAction(): SwitchLayerAction {
let keyAction = new SwitchLayerAction(); const keyAction = new SwitchLayerAction();
keyAction.isLayerToggleable = this.toggle; keyAction.isLayerToggleable = this.toggle;
keyAction.layer = this.layer; keyAction.layer = this.layer;
if (!this.keyActionValid()) { if (!this.keyActionValid()) {

View File

@@ -1,4 +1,4 @@
import { Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output } from '@angular/core'; import { Component, Input, OnChanges, OnDestroy, OnInit } from '@angular/core';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
@@ -27,7 +27,7 @@ export class MacroTabComponent extends Tab implements OnInit, OnChanges, OnDestr
private selectedMacroIndex: number; private selectedMacroIndex: number;
private subscription: Subscription; private subscription: Subscription;
constructor(private store: Store<AppState>) { constructor(store: Store<AppState>) {
super(); super();
this.subscription = store.let(getMacros()) this.subscription = store.let(getMacros())
.subscribe((macros: Macro[]) => this.macros = macros); .subscribe((macros: Macro[]) => this.macros = macros);

View File

@@ -1,4 +1,4 @@
import { Component, EventEmitter, Input, OnChanges, Output } from '@angular/core'; import { Component, Input, OnChanges } from '@angular/core';
import { KeyAction, MouseAction, MouseActionParam } from '../../../../config-serializer/config-items/key-action'; import { KeyAction, MouseAction, MouseActionParam } from '../../../../config-serializer/config-items/key-action';
import { Tab } from '../tab'; import { Tab } from '../tab';
@@ -11,14 +11,12 @@ import { Tab } from '../tab';
export class MouseTabComponent extends Tab implements OnChanges { export class MouseTabComponent extends Tab implements OnChanges {
@Input() defaultKeyAction: KeyAction; @Input() defaultKeyAction: KeyAction;
private mouseActionParam: MouseActionParam;
private selectedPageIndex: number;
/* tslint:disable:variable-name: It is an enum type. So it can start with uppercase. */ /* tslint:disable:variable-name: It is an enum type. So it can start with uppercase. */
/* tslint:disable:no-unused-variable: It is used in the template. */ MouseActionParam = MouseActionParam;
private MouseActionParam = MouseActionParam; /* tslint:enable:variable-name*/
/* tslint:enable:no-unused-variable tslint:enable:variable-name */ mouseActionParam: MouseActionParam;
selectedPageIndex: number;
private pages: string[]; pages: string[];
constructor() { constructor() {
super(); super();
@@ -40,7 +38,7 @@ export class MouseTabComponent extends Tab implements OnChanges {
return false; return false;
} }
let mouseAction: MouseAction = <MouseAction>keyAction; const mouseAction: MouseAction = <MouseAction>keyAction;
this.mouseActionParam = mouseAction.mouseAction; this.mouseActionParam = mouseAction.mouseAction;
if (mouseAction.mouseAction === MouseActionParam.moveUp) { if (mouseAction.mouseAction === MouseActionParam.moveUp) {
@@ -77,7 +75,7 @@ export class MouseTabComponent extends Tab implements OnChanges {
} }
toKeyAction(): MouseAction { toKeyAction(): MouseAction {
let mouseAction: MouseAction = new MouseAction(); const mouseAction: MouseAction = new MouseAction();
mouseAction.mouseAction = this.mouseActionParam; mouseAction.mouseAction = this.mouseActionParam;
return mouseAction; return mouseAction;
} }

View File

@@ -1,4 +1,4 @@
import { Component, EventEmitter, OnChanges, Output } from '@angular/core'; import { Component, OnChanges } from '@angular/core';
import { Tab } from '../tab'; import { Tab } from '../tab';

View File

@@ -56,7 +56,7 @@ export class SideMenuComponent {
} }
toggleHide(event: Event, type: string) { toggleHide(event: Event, type: string) {
let header: DOMTokenList = (<Element>event.target).classList; const header: DOMTokenList = (<Element>event.target).classList;
let show = false; let show = false;
if (header.contains('fa-chevron-down')) { if (header.contains('fa-chevron-down')) {

View File

@@ -55,7 +55,7 @@ export class SvgKeyboardComponent implements OnInit {
} }
private getKeyboardSvgAttributes(): { viewBox: string, transform: string, fill: string } { private getKeyboardSvgAttributes(): { viewBox: string, transform: string, fill: string } {
let svg: any = this.getBaseLayer(); const svg: any = this.getBaseLayer();
return { return {
viewBox: svg.$.viewBox, viewBox: svg.$.viewBox,
transform: svg.g[0].$.transform, transform: svg.g[0].$.transform,
@@ -64,7 +64,7 @@ export class SvgKeyboardComponent implements OnInit {
} }
private getSvgModules(): SvgModule[] { private getSvgModules(): SvgModule[] {
let modules = this.getBaseLayer().g[0].g.map((obj: any) => new SvgModule(obj)); const modules = this.getBaseLayer().g[0].g.map((obj: any) => new SvgModule(obj));
return [modules[1], modules[0]]; // TODO: remove if the svg will be correct return [modules[1], modules[0]]; // TODO: remove if the svg will be correct
} }

View File

@@ -141,7 +141,7 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
constructor( constructor(
private mapper: MapperService, private mapper: MapperService,
private store: Store<AppState>, store: Store<AppState>,
private element: ElementRef, private element: ElementRef,
private captureService: CaptureService, private captureService: CaptureService,
private renderer: Renderer private renderer: Renderer
@@ -215,11 +215,11 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
this.labelType = LabelTypes.OneLineText; this.labelType = LabelTypes.OneLineText;
if (this.keyAction instanceof KeystrokeAction) { if (this.keyAction instanceof KeystrokeAction) {
let keyAction: KeystrokeAction = this.keyAction as KeystrokeAction; const keyAction: KeystrokeAction = this.keyAction as KeystrokeAction;
let newLabelSource: string[]; let newLabelSource: string[];
if (!keyAction.hasActiveModifier() && keyAction.hasScancode()) { if (!keyAction.hasActiveModifier() && keyAction.hasScancode()) {
let scancode: number = keyAction.scancode; const scancode: number = keyAction.scancode;
newLabelSource = this.mapper.scanCodeToText(scancode); newLabelSource = this.mapper.scanCodeToText(scancode);
if (this.mapper.hasScancodeIcon(scancode)) { if (this.mapper.hasScancodeIcon(scancode)) {
this.labelSource = this.mapper.scanCodeToSvgImagePath(scancode); this.labelSource = this.mapper.scanCodeToSvgImagePath(scancode);
@@ -262,7 +262,7 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
this.labelSource = this.keyAction; this.labelSource = this.keyAction;
} }
} else if (this.keyAction instanceof SwitchLayerAction) { } else if (this.keyAction instanceof SwitchLayerAction) {
let keyAction: SwitchLayerAction = this.keyAction as SwitchLayerAction; const keyAction: SwitchLayerAction = this.keyAction as SwitchLayerAction;
let newLabelSource: string; let newLabelSource: string;
switch (keyAction.layer) { switch (keyAction.layer) {
case LayerName.mod: case LayerName.mod:
@@ -289,11 +289,11 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
this.labelSource = newLabelSource; this.labelSource = newLabelSource;
} }
} else if (this.keyAction instanceof SwitchKeymapAction) { } else if (this.keyAction instanceof SwitchKeymapAction) {
let keyAction: SwitchKeymapAction = this.keyAction as SwitchKeymapAction; const keyAction: SwitchKeymapAction = this.keyAction as SwitchKeymapAction;
this.labelType = LabelTypes.SwitchKeymap; this.labelType = LabelTypes.SwitchKeymap;
this.labelSource = keyAction.keymapAbbreviation; this.labelSource = keyAction.keymapAbbreviation;
} else if (this.keyAction instanceof PlayMacroAction) { } else if (this.keyAction instanceof PlayMacroAction) {
let keyAction: PlayMacroAction = this.keyAction as PlayMacroAction; const keyAction: PlayMacroAction = this.keyAction as PlayMacroAction;
const macro: Macro = this.macros.find((_macro: Macro) => _macro.id === keyAction.macroId); const macro: Macro = this.macros.find((_macro: Macro) => _macro.id === keyAction.macroId);
this.labelType = LabelTypes.IconText; this.labelType = LabelTypes.IconText;
this.labelSource = { this.labelSource = {

View File

@@ -20,10 +20,6 @@ class SvgAttributes {
} }
} }
enum Modifiers {
Shift, Control, Alt, Command
}
@Component({ @Component({
selector: 'g[svg-keystroke-key]', selector: 'g[svg-keystroke-key]',
templateUrl: './svg-keystroke-key.component.html', templateUrl: './svg-keystroke-key.component.html',
@@ -68,7 +64,7 @@ export class SvgKeystrokeKeyComponent implements OnInit, OnChanges {
this.modifierIconNames.option = this.mapper.getIcon('option'); this.modifierIconNames.option = this.mapper.getIcon('option');
this.modifierIconNames.command = this.mapper.getIcon('command'); this.modifierIconNames.command = this.mapper.getIcon('command');
let bottomSideMode: boolean = this.width < this.height * 1.8; const bottomSideMode: boolean = this.width < this.height * 1.8;
const heightWidthRatio = this.height / this.width; const heightWidthRatio = this.height / this.width;
@@ -76,8 +72,8 @@ export class SvgKeystrokeKeyComponent implements OnInit, OnChanges {
const maxIconWidth = this.width / 4; const maxIconWidth = this.width / 4;
const maxIconHeight = this.height; const maxIconHeight = this.height;
const iconScalingFactor = 0.8; const iconScalingFactor = 0.8;
let iconWidth = iconScalingFactor * heightWidthRatio * maxIconWidth; const iconWidth = iconScalingFactor * heightWidthRatio * maxIconWidth;
let iconHeight = iconScalingFactor * maxIconHeight; const iconHeight = iconScalingFactor * maxIconHeight;
this.modifierContainer.width = this.width; this.modifierContainer.width = this.width;
this.modifierContainer.height = this.height / 5; this.modifierContainer.height = this.height / 5;
this.modifierContainer.y = this.height - this.modifierContainer.height; this.modifierContainer.y = this.height - this.modifierContainer.height;
@@ -134,7 +130,7 @@ export class SvgKeystrokeKeyComponent implements OnInit, OnChanges {
ngOnChanges() { ngOnChanges() {
let newLabelSource: string[]; let newLabelSource: string[];
if (this.keystrokeAction.hasScancode()) { if (this.keystrokeAction.hasScancode()) {
let scancode: number = this.keystrokeAction.scancode; const scancode: number = this.keystrokeAction.scancode;
newLabelSource = this.mapper.scanCodeToText(scancode); newLabelSource = this.mapper.scanCodeToText(scancode);
if (newLabelSource) { if (newLabelSource) {
if (newLabelSource.length === 1) { if (newLabelSource.length === 1) {

View File

@@ -155,7 +155,7 @@ export class SvgKeyboardWrapComponent implements OnInit, OnChanges {
} }
onCapture(moduleId: number, keyId: number, captured: { code: number, left: boolean[], right: boolean[] }): void { onCapture(moduleId: number, keyId: number, captured: { code: number, left: boolean[], right: boolean[] }): void {
let keystrokeAction: KeystrokeAction = new KeystrokeAction(); const keystrokeAction: KeystrokeAction = new KeystrokeAction();
const modifiers = captured.left.concat(captured.right).map(x => x ? 1 : 0); const modifiers = captured.left.concat(captured.right).map(x => x ? 1 : 0);
keystrokeAction.scancode = captured.code; keystrokeAction.scancode = captured.code;

View File

@@ -24,7 +24,7 @@ export class UhkBuffer {
} }
readInt8(): number { readInt8(): number {
let value = this.buffer.readInt8(this.offset); const value = this.buffer.readInt8(this.offset);
this.dump(`i8(${value})`); this.dump(`i8(${value})`);
this.bytesToBacktrack = 1; this.bytesToBacktrack = 1;
this.offset += this.bytesToBacktrack; this.offset += this.bytesToBacktrack;
@@ -38,7 +38,7 @@ export class UhkBuffer {
} }
readUInt8(): number { readUInt8(): number {
let value = this.buffer.readUInt8(this.offset); const value = this.buffer.readUInt8(this.offset);
this.dump(`u8(${value})`); this.dump(`u8(${value})`);
this.bytesToBacktrack = 1; this.bytesToBacktrack = 1;
this.offset += this.bytesToBacktrack; this.offset += this.bytesToBacktrack;
@@ -52,7 +52,7 @@ export class UhkBuffer {
} }
readInt16(): number { readInt16(): number {
let value = this.buffer.readInt16LE(this.offset); const value = this.buffer.readInt16LE(this.offset);
this.dump(`i16(${value})`); this.dump(`i16(${value})`);
this.bytesToBacktrack = 2; this.bytesToBacktrack = 2;
this.offset += this.bytesToBacktrack; this.offset += this.bytesToBacktrack;
@@ -66,7 +66,7 @@ export class UhkBuffer {
} }
readUInt16(): number { readUInt16(): number {
let value = this.buffer.readUInt16LE(this.offset); const value = this.buffer.readUInt16LE(this.offset);
this.dump(`u16(${value})`); this.dump(`u16(${value})`);
this.bytesToBacktrack = 2; this.bytesToBacktrack = 2;
this.offset += this.bytesToBacktrack; this.offset += this.bytesToBacktrack;
@@ -80,7 +80,7 @@ export class UhkBuffer {
} }
readInt32(): number { readInt32(): number {
let value = this.buffer.readInt32LE(this.offset); const value = this.buffer.readInt32LE(this.offset);
this.dump(`i32(${value})`); this.dump(`i32(${value})`);
this.bytesToBacktrack = 4; this.bytesToBacktrack = 4;
this.offset += this.bytesToBacktrack; this.offset += this.bytesToBacktrack;
@@ -94,7 +94,7 @@ export class UhkBuffer {
} }
readUInt32(): number { readUInt32(): number {
let value = this.buffer.readUInt32LE(this.offset); const value = this.buffer.readUInt32LE(this.offset);
this.dump(`u32(${value})`); this.dump(`u32(${value})`);
this.bytesToBacktrack = 4; this.bytesToBacktrack = 4;
this.offset += this.bytesToBacktrack; this.offset += this.bytesToBacktrack;
@@ -125,8 +125,8 @@ export class UhkBuffer {
} }
readString(): string { readString(): string {
let stringByteLength = this.readCompactLength(); const stringByteLength = this.readCompactLength();
let str = this.buffer.toString(UhkBuffer.stringEncoding, this.offset, this.offset + stringByteLength); const str = this.buffer.toString(UhkBuffer.stringEncoding, this.offset, this.offset + stringByteLength);
this.dump(`${UhkBuffer.stringEncoding}(${str})`); this.dump(`${UhkBuffer.stringEncoding}(${str})`);
this.bytesToBacktrack = stringByteLength; this.bytesToBacktrack = stringByteLength;
this.offset += stringByteLength; this.offset += stringByteLength;
@@ -134,7 +134,7 @@ export class UhkBuffer {
} }
writeString(str: string): void { writeString(str: string): void {
let stringByteLength = Buffer.byteLength(str, UhkBuffer.stringEncoding); const stringByteLength = Buffer.byteLength(str, UhkBuffer.stringEncoding);
if (stringByteLength > UhkBuffer.maxCompactLength) { if (stringByteLength > UhkBuffer.maxCompactLength) {
throw `Cannot serialize string: ${stringByteLength} bytes is larger throw `Cannot serialize string: ${stringByteLength} bytes is larger
@@ -156,8 +156,8 @@ export class UhkBuffer {
} }
readArray<T>(elementReader: (buffer: UhkBuffer, index?: number) => T): T[] { readArray<T>(elementReader: (buffer: UhkBuffer, index?: number) => T): T[] {
let array: T[] = []; const array: T[] = [];
let length = this.readCompactLength(); const length = this.readCompactLength();
for (let i = 0; i < length; ++i) { for (let i = 0; i < length; ++i) {
array.push(elementReader(this, i)); array.push(elementReader(this, i));
} }

View File

@@ -1,5 +1,4 @@
import { UhkBuffer } from '../UhkBuffer'; import { UhkBuffer } from '../UhkBuffer';
import { Keymap } from './Keymap';
import { Macro } from './Macro'; import { Macro } from './Macro';
import { Module } from './Module'; import { Module } from './Module';

View File

@@ -38,7 +38,7 @@ export class Macro {
this.isLooped = buffer.readBoolean(); this.isLooped = buffer.readBoolean();
this.isPrivate = buffer.readBoolean(); this.isPrivate = buffer.readBoolean();
this.name = buffer.readString(); this.name = buffer.readString();
let macroActionsLength: number = buffer.readCompactLength(); const macroActionsLength: number = buffer.readCompactLength();
this.macroActions = []; this.macroActions = [];
for (let i = 0; i < macroActionsLength; ++i) { for (let i = 0; i < macroActionsLength; ++i) {
this.macroActions.push(MacroActionHelper.createMacroAction(buffer)); this.macroActions.push(MacroActionHelper.createMacroAction(buffer));

View File

@@ -1,7 +1,6 @@
import { assertEnum, assertUInt8 } from '../assert'; import { assertEnum, assertUInt8 } from '../assert';
import { UhkBuffer } from '../UhkBuffer'; import { UhkBuffer } from '../UhkBuffer';
import { Helper as KeyActionHelper, KeyAction, NoneAction } from './key-action'; import { Helper as KeyActionHelper, KeyAction, NoneAction } from './key-action';
import { Keymap } from './Keymap';
import { Macro } from './Macro'; import { Macro } from './Macro';
import { PlayMacroAction, SwitchLayerAction } from './key-action'; import { PlayMacroAction, SwitchLayerAction } from './key-action';
@@ -42,7 +41,7 @@ export class Module {
fromBinary(buffer: UhkBuffer, macros?: Macro[]): Module { fromBinary(buffer: UhkBuffer, macros?: Macro[]): Module {
this.id = buffer.readUInt8(); this.id = buffer.readUInt8();
this.pointerRole = buffer.readUInt8(); this.pointerRole = buffer.readUInt8();
let keyActionsLength: number = buffer.readCompactLength(); const keyActionsLength: number = buffer.readCompactLength();
this.keyActions = []; this.keyActions = [];
for (let i = 0; i < keyActionsLength; ++i) { for (let i = 0; i < keyActionsLength; ++i) {
this.keyActions.push(KeyActionHelper.createKeyAction(buffer, macros)); this.keyActions.push(KeyActionHelper.createKeyAction(buffer, macros));

View File

@@ -32,17 +32,17 @@ export let keyActionType = {
export abstract class KeyAction { export abstract class KeyAction {
assertKeyActionType(jsObject: any): void { assertKeyActionType(jsObject: any): void {
let keyActionClassname: string = this.constructor.name; const keyActionClassname: string = this.constructor.name;
let keyActionTypeString: string = keyActionType[keyActionClassname]; const keyActionTypeString: string = keyActionType[keyActionClassname];
if (jsObject.keyActionType !== keyActionTypeString) { if (jsObject.keyActionType !== keyActionTypeString) {
throw `Invalid ${keyActionClassname}.keyActionType: ${jsObject.keyActionType}`; throw `Invalid ${keyActionClassname}.keyActionType: ${jsObject.keyActionType}`;
} }
} }
readAndAssertKeyActionId(buffer: UhkBuffer): KeyActionId { readAndAssertKeyActionId(buffer: UhkBuffer): KeyActionId {
let classname: string = this.constructor.name; const classname: string = this.constructor.name;
let readKeyActionId: number = buffer.readUInt8(); const readKeyActionId: number = buffer.readUInt8();
let keyActionId: number = KeyActionId[classname]; const keyActionId: number = KeyActionId[classname];
if (keyActionId === KeyActionId.KeystrokeAction) { if (keyActionId === KeyActionId.KeystrokeAction) {
if (readKeyActionId < KeyActionId.KeystrokeAction || readKeyActionId > KeyActionId.LastKeystrokeAction) { if (readKeyActionId < KeyActionId.KeystrokeAction || readKeyActionId > KeyActionId.LastKeystrokeAction) {
throw `Invalid ${classname} first byte: ${readKeyActionId}`; throw `Invalid ${classname} first byte: ${readKeyActionId}`;

View File

@@ -49,8 +49,8 @@ export class KeystrokeAction extends KeyAction {
} }
fromBinary(buffer: UhkBuffer): KeystrokeAction { fromBinary(buffer: UhkBuffer): KeystrokeAction {
let keyActionId: KeyActionId = this.readAndAssertKeyActionId(buffer); const keyActionId: KeyActionId = this.readAndAssertKeyActionId(buffer);
let flags: number = keyActionId - KeyActionId.KeystrokeAction; const flags: number = keyActionId - KeyActionId.KeystrokeAction;
if (flags & KeystrokeActionFlag.scancode) { if (flags & KeystrokeActionFlag.scancode) {
this.scancode = buffer.readUInt8(); this.scancode = buffer.readUInt8();
} }
@@ -64,7 +64,7 @@ export class KeystrokeAction extends KeyAction {
} }
toJsonObject(): JsonObjectKeystrokeAction { toJsonObject(): JsonObjectKeystrokeAction {
let jsonObject: JsonObjectKeystrokeAction = { const jsonObject: JsonObjectKeystrokeAction = {
keyActionType: keyActionType.KeystrokeAction keyActionType: keyActionType.KeystrokeAction
}; };
@@ -85,7 +85,7 @@ export class KeystrokeAction extends KeyAction {
toBinary(buffer: UhkBuffer) { toBinary(buffer: UhkBuffer) {
let flags = 0; let flags = 0;
let bufferData: number[] = []; const bufferData: number[] = [];
if (this.hasScancode()) { if (this.hasScancode()) {
flags |= KeystrokeActionFlag.scancode; flags |= KeystrokeActionFlag.scancode;
@@ -109,7 +109,7 @@ export class KeystrokeAction extends KeyAction {
} }
toString(): string { toString(): string {
let properties: string[] = []; const properties: string[] = [];
if (this.hasScancode()) { if (this.hasScancode()) {
properties.push(`scancode="${this.scancode}"`); properties.push(`scancode="${this.scancode}"`);
} }
@@ -144,7 +144,7 @@ export class KeystrokeAction extends KeyAction {
} }
getModifierList(): string[] { getModifierList(): string[] {
let modifierList: string[] = []; const modifierList: string[] = [];
let modifierMask = this.modifierMask; let modifierMask = this.modifierMask;
for (let i = 0; modifierMask !== 0; ++i, modifierMask >>= 1) { for (let i = 0; modifierMask !== 0; ++i, modifierMask >>= 1) {
if (modifierMask & 1) { if (modifierMask & 1) {

View File

@@ -10,7 +10,6 @@ import {
keyActionType keyActionType
} from './index'; } from './index';
import { Keymap } from '../Keymap';
import { Macro } from '../Macro'; import { Macro } from '../Macro';
export class Helper { export class Helper {
@@ -26,7 +25,7 @@ export class Helper {
} }
private static fromUhkBuffer(buffer: UhkBuffer, macros: Macro[]): KeyAction { private static fromUhkBuffer(buffer: UhkBuffer, macros: Macro[]): KeyAction {
let keyActionFirstByte = buffer.readUInt8(); const keyActionFirstByte = buffer.readUInt8();
buffer.backtrack(); buffer.backtrack();
if (keyActionFirstByte >= KeyActionId.KeystrokeAction && keyActionFirstByte < KeyActionId.LastKeystrokeAction) { if (keyActionFirstByte >= KeyActionId.KeystrokeAction && keyActionFirstByte < KeyActionId.LastKeystrokeAction) {

View File

@@ -93,13 +93,13 @@ export class EditableMacroAction {
} }
fromKeyAction(keyAction: KeyAction): void { fromKeyAction(keyAction: KeyAction): void {
let data = keyAction.toJsonObject(); const data = keyAction.toJsonObject();
this.scancode = data.scancode; this.scancode = data.scancode;
this.modifierMask = data.modifierMask; this.modifierMask = data.modifierMask;
} }
toKeystrokeAction(): KeystrokeAction { toKeystrokeAction(): KeystrokeAction {
let data = this.toJsObject(); const data = this.toJsObject();
data.keyActionType = keyActionType.KeystrokeAction; data.keyActionType = keyActionType.KeystrokeAction;
return <KeystrokeAction>(new KeystrokeAction().fromJsonObject(data)); return <KeystrokeAction>(new KeystrokeAction().fromJsonObject(data));
} }
@@ -113,7 +113,7 @@ export class EditableMacroAction {
} }
getMouseButtons(): boolean[] { getMouseButtons(): boolean[] {
let enabledMouseButtons: boolean[] = []; const enabledMouseButtons: boolean[] = [];
for (let bitmask = this.mouseButtonsMask; bitmask; bitmask >>>= 1) { for (let bitmask = this.mouseButtonsMask; bitmask; bitmask >>>= 1) {
enabledMouseButtons.push(Boolean(bitmask & 1)); enabledMouseButtons.push(Boolean(bitmask & 1));
} }

View File

@@ -42,7 +42,7 @@ export class KeyMacroAction extends MacroAction {
} }
fromBinary(buffer: UhkBuffer): KeyMacroAction { fromBinary(buffer: UhkBuffer): KeyMacroAction {
let macroActionId: MacroActionId = this.readAndAssertMacroActionId(buffer); const macroActionId: MacroActionId = this.readAndAssertMacroActionId(buffer);
let keyMacroType: number = macroActionId - MacroActionId.KeyMacroAction; let keyMacroType: number = macroActionId - MacroActionId.KeyMacroAction;
this.action = Math.floor(keyMacroType / NUM_OF_COMBINATIONS); this.action = Math.floor(keyMacroType / NUM_OF_COMBINATIONS);
keyMacroType %= NUM_OF_COMBINATIONS; keyMacroType %= NUM_OF_COMBINATIONS;
@@ -56,7 +56,7 @@ export class KeyMacroAction extends MacroAction {
} }
toJsonObject(): any { toJsonObject(): any {
let jsObject: JsObjectKeyMacroAction = { const jsObject: JsObjectKeyMacroAction = {
macroActionType: macroActionType.KeyMacroAction, macroActionType: macroActionType.KeyMacroAction,
action: MacroSubAction[this.action] action: MacroSubAction[this.action]
}; };

View File

@@ -46,17 +46,17 @@ export let macroActionType = {
export abstract class MacroAction { export abstract class MacroAction {
assertMacroActionType(jsObject: any) { assertMacroActionType(jsObject: any) {
let macroActionClassname = this.constructor.name; const macroActionClassname = this.constructor.name;
let macroActionTypeString = macroActionType[macroActionClassname]; const macroActionTypeString = macroActionType[macroActionClassname];
if (jsObject.macroActionType !== macroActionTypeString) { if (jsObject.macroActionType !== macroActionTypeString) {
throw `Invalid ${macroActionClassname}.macroActionType: ${jsObject.macroActionType}`; throw `Invalid ${macroActionClassname}.macroActionType: ${jsObject.macroActionType}`;
} }
} }
readAndAssertMacroActionId(buffer: UhkBuffer): MacroActionId { readAndAssertMacroActionId(buffer: UhkBuffer): MacroActionId {
let classname: string = this.constructor.name; const classname: string = this.constructor.name;
let readMacroActionId: MacroActionId = buffer.readUInt8(); const readMacroActionId: MacroActionId = buffer.readUInt8();
let macroActionId: MacroActionId = MacroActionId[classname]; const macroActionId: MacroActionId = MacroActionId[classname];
if (macroActionId === MacroActionId.KeyMacroAction) { if (macroActionId === MacroActionId.KeyMacroAction) {
if (readMacroActionId < MacroActionId.KeyMacroAction || readMacroActionId > MacroActionId.LastKeyMacroAction) { if (readMacroActionId < MacroActionId.KeyMacroAction || readMacroActionId > MacroActionId.LastKeyMacroAction) {
throw `Invalid ${classname} first byte: ${readMacroActionId}`; throw `Invalid ${classname} first byte: ${readMacroActionId}`;

View File

@@ -38,7 +38,7 @@ export class MouseButtonMacroAction extends MacroAction {
} }
fromBinary(buffer: UhkBuffer): MouseButtonMacroAction { fromBinary(buffer: UhkBuffer): MouseButtonMacroAction {
let macroActionId: MacroActionId = this.readAndAssertMacroActionId(buffer); const macroActionId: MacroActionId = this.readAndAssertMacroActionId(buffer);
this.action = macroActionId - MacroActionId.MouseButtonMacroAction; this.action = macroActionId - MacroActionId.MouseButtonMacroAction;
this.mouseButtonsMask = buffer.readUInt8(); this.mouseButtonsMask = buffer.readUInt8();
return this; return this;
@@ -66,7 +66,7 @@ export class MouseButtonMacroAction extends MacroAction {
} }
getMouseButtons(): boolean[] { getMouseButtons(): boolean[] {
let enabledMouseButtons: boolean[] = []; const enabledMouseButtons: boolean[] = [];
for (let bitmask = this.mouseButtonsMask; bitmask; bitmask >>>= 1) { for (let bitmask = this.mouseButtonsMask; bitmask; bitmask >>>= 1) {
enabledMouseButtons.push(Boolean(bitmask & 1)); enabledMouseButtons.push(Boolean(bitmask & 1));
} }

View File

@@ -24,7 +24,7 @@ export class Helper {
} }
private static fromUhkBuffer(buffer: UhkBuffer): MacroAction { private static fromUhkBuffer(buffer: UhkBuffer): MacroAction {
let macroActionFirstByte = buffer.readUInt8(); const macroActionFirstByte = buffer.readUInt8();
buffer.backtrack(); buffer.backtrack();
if (macroActionFirstByte >= MacroActionId.KeyMacroAction && macroActionFirstByte <= MacroActionId.LastKeyMacroAction) { if (macroActionFirstByte >= MacroActionId.KeyMacroAction && macroActionFirstByte <= MacroActionId.LastKeyMacroAction) {

View File

@@ -27,7 +27,7 @@ export class MapperService {
} }
public scanCodeToSvgImagePath(scanCode: number): string { public scanCodeToSvgImagePath(scanCode: number): string {
let fileName: string = this.scanCodeFileName.get(scanCode); const fileName: string = this.scanCodeFileName.get(scanCode);
if (fileName) { if (fileName) {
return 'assets/compiled_sprite.svg#' + fileName; return 'assets/compiled_sprite.svg#' + fileName;
} }

View File

@@ -8,8 +8,6 @@ import 'rxjs/add/operator/do';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import 'rxjs/add/operator/withLatestFrom'; import 'rxjs/add/operator/withLatestFrom';
import { Macro } from '../../config-serializer/config-items/Macro';
import { KeymapActions, MacroActions } from '../actions'; import { KeymapActions, MacroActions } from '../actions';
import { AppState } from '../index'; import { AppState } from '../index';

View File

@@ -5,7 +5,7 @@ import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of'; import 'rxjs/add/observable/of';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import { Helper as KeyActionHelper, KeyAction, SwitchKeymapAction } from '../../config-serializer/config-items/key-action'; import { Helper as KeyActionHelper, KeyAction } from '../../config-serializer/config-items/key-action';
import { Keymap } from '../../config-serializer/config-items/Keymap'; import { Keymap } from '../../config-serializer/config-items/Keymap';
import { Macro } from '../../config-serializer/config-items/Macro'; import { Macro } from '../../config-serializer/config-items/Macro';
import { UserConfiguration } from '../../config-serializer/config-items/UserConfiguration'; import { UserConfiguration } from '../../config-serializer/config-items/UserConfiguration';
@@ -74,7 +74,7 @@ export default function (state = initialState, action: Action): UserConfiguratio
case KeymapActions.REMOVE: case KeymapActions.REMOVE:
let isDefault: boolean; let isDefault: boolean;
let filtered: Keymap[] = state.keymaps.filter((keymap: Keymap) => { const filtered: Keymap[] = state.keymaps.filter((keymap: Keymap) => {
if (keymap.abbreviation === action.payload) { if (keymap.abbreviation === action.payload) {
isDefault = keymap.isDefault; isDefault = keymap.isDefault;
return false; return false;
@@ -306,8 +306,8 @@ function generateMacroId(macros: Macro[]) {
} }
function checkExistence(layers: Layer[], property: string, value: any) { function checkExistence(layers: Layer[], property: string, value: any) {
let newLayers = layers.map((layer) => { const newLayers = layers.map(layer => {
let newLayer = new Layer(layer); const newLayer = new Layer(layer);
newLayer.modules = layer.modules.map((module: Module) => { newLayer.modules = layer.modules.map((module: Module) => {
module.keyActions.forEach((action: KeyAction, index: number) => { module.keyActions.forEach((action: KeyAction, index: number) => {

View File

@@ -3,10 +3,8 @@ import { Injectable } from '@angular/core';
import { Action } from '@ngrx/store'; import { Action } from '@ngrx/store';
import { Keymap } from '../../config-serializer/config-items/Keymap'; import { Keymap } from '../../config-serializer/config-items/Keymap';
import { Macro } from '../../config-serializer/config-items/Macro';
import { UserConfiguration } from '../../config-serializer/config-items/UserConfiguration'; import { UserConfiguration } from '../../config-serializer/config-items/UserConfiguration';
import { KeymapActions, MacroActions } from '../actions';
import { AppState } from '../index'; import { AppState } from '../index';
import { Electron } from './electron'; import { Electron } from './electron';
import { Local } from './local'; import { Local } from './local';

View File

@@ -5,7 +5,7 @@ export class Local {
constructor(private dataModelVersion: number) { } constructor(private dataModelVersion: number) { }
getConfig(): UserConfiguration { getConfig(): UserConfiguration {
let configJsonString = localStorage.getItem('config'); const configJsonString = localStorage.getItem('config');
let config: UserConfiguration; let config: UserConfiguration;
if (configJsonString) { if (configJsonString) {

View File

@@ -1,27 +1,27 @@
import { UserConfiguration } from '../shared/src/config-serializer/config-items/UserConfiguration'; import { UserConfiguration } from '../shared/src/config-serializer/config-items/UserConfiguration';
import { UhkBuffer } from '../shared/src/config-serializer/UhkBuffer'; import { UhkBuffer } from '../shared/src/config-serializer/UhkBuffer';
let assert = require('assert'); const assert = require('assert');
let fs = require('fs'); const fs = require('fs');
let userConfig = JSON.parse(fs.readFileSync('../shared/src/config-serializer/user-config.json')); const userConfig = JSON.parse(fs.readFileSync('../shared/src/config-serializer/user-config.json'));
let config1Js = userConfig; const config1Js = userConfig;
let config1Ts: UserConfiguration = new UserConfiguration().fromJsonObject(config1Js); const config1Ts: UserConfiguration = new UserConfiguration().fromJsonObject(config1Js);
let config1Buffer = new UhkBuffer(); const config1Buffer = new UhkBuffer();
config1Ts.toBinary(config1Buffer); config1Ts.toBinary(config1Buffer);
let config1BufferContent = config1Buffer.getBufferContent(); const config1BufferContent = config1Buffer.getBufferContent();
fs.writeFileSync('user-config.bin', config1BufferContent); fs.writeFileSync('user-config.bin', config1BufferContent);
config1Buffer.offset = 0; config1Buffer.offset = 0;
console.log(); console.log();
let config2Ts = new UserConfiguration().fromBinary(config1Buffer); const config2Ts = new UserConfiguration().fromBinary(config1Buffer);
console.log('\n'); console.log('\n');
let config2Js = config2Ts.toJsonObject(); const config2Js = config2Ts.toJsonObject();
let config2Buffer = new UhkBuffer(); const config2Buffer = new UhkBuffer();
config2Ts.toBinary(config2Buffer); config2Ts.toBinary(config2Buffer);
fs.writeFileSync('user-config-serialized.json', JSON.stringify(config2Js, undefined, 4)); fs.writeFileSync('user-config-serialized.json', JSON.stringify(config2Js, undefined, 4));
let config2BufferContent = config1Buffer.getBufferContent(); const config2BufferContent = config1Buffer.getBufferContent();
fs.writeFileSync('user-config-serialized.bin', config2BufferContent); fs.writeFileSync('user-config-serialized.bin', config2BufferContent);
console.log('\n'); console.log('\n');

View File

@@ -17,6 +17,13 @@
"no-unused-expression": true, "no-unused-expression": true,
"no-use-before-declare": true, "no-use-before-declare": true,
"no-var-keyword": true, "no-var-keyword": true,
"space-before-function-paren": false,
"import-spacing": true,
"prefer-const": true,
"arrow-parens": [
true,
"ban-single-arg-parens"
],
"radix": true, "radix": true,
"switch-default": true, "switch-default": true,
"triple-equals": true, "triple-equals": true,

View File

@@ -1,5 +1,5 @@
import { ModuleWithProviders } from '@angular/core'; import { ModuleWithProviders } from '@angular/core';
import { RouterModule, Routes } from '@angular/router'; import { RouterModule, Routes } from '@angular/router';
import { addOnRoutes } from '../shared/components/add-on'; import { addOnRoutes } from '../shared/components/add-on';
import { keymapRoutes } from '../components/keymap'; import { keymapRoutes } from '../components/keymap';
@@ -13,6 +13,6 @@ const appRoutes: Routes = [
...settingsRoutes ...settingsRoutes
]; ];
export const appRoutingProviders: any[] = [ ]; export const appRoutingProviders: any[] = [];
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes, { useHash: true }); export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes, { useHash: true });