Fixed TSLint. Now I'll have to fix the actual linting errors.

This commit is contained in:
Manuel Friedli 2017-04-15 18:51:22 +02:00
parent 1a689efc3c
commit 9ffbee6e0d
32 changed files with 1201 additions and 981 deletions

View file

@ -1,5 +1,5 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import {NgModule} from "@angular/core";
import {RouterModule, Routes} from "@angular/router";
const routes: Routes = [
{
@ -12,4 +12,5 @@ const routes: Routes = [
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
export class AppRoutingModule {
}

View file

@ -1,10 +1,10 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import {BrowserModule} from "@angular/platform-browser";
import {NgModule} from "@angular/core";
import {FormsModule} from "@angular/forms";
import {HttpModule} from "@angular/http";
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import {AppRoutingModule} from "./app-routing.module";
import {AppComponent} from "./app.component";
@NgModule({
declarations: [
@ -19,4 +19,5 @@ import { AppComponent } from './app.component';
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
export class AppModule {
}

View file

@ -1,19 +1,19 @@
import {Converter} from "./converter";
export class Base64Decoder implements Converter {
getDisplayname():string {
return "Decode Base 64";
}
getDisplayname(): string {
return "Decode Base 64";
}
getId():string {
return "base64decode";
}
getId(): string {
return "base64decode";
}
convert(input:string):string {
try {
return atob(input);
} catch (exception) {
throw new Error("Could not decode base64 string. Maybe corrupt input?");
}
convert(input: string): string {
try {
return atob(input);
} catch (exception) {
throw new Error("Could not decode base64 string. Maybe corrupt input?");
}
}
}

View file

@ -1,19 +1,19 @@
import {Converter} from "./converter";
export class BinToDecConverter implements Converter {
getDisplayname():string {
return "Convert binary to decimal";
}
getDisplayname(): string {
return "Convert binary to decimal";
}
getId():string {
return "bintodec";
}
getId(): string {
return "bintodec";
}
convert(input:string):string {
let n:number = parseInt(input, 2);
if (isNaN(n)) {
throw new Error("The input seems not to be a valid binary number.");
}
return n.toString(10);
convert(input: string): string {
let n: number = parseInt(input, 2);
if (isNaN(n)) {
throw new Error("The input seems not to be a valid binary number.");
}
return n.toString(10);
}
}

View file

@ -1,5 +1,5 @@
export interface Converter {
getDisplayname():string;
getId():string;
convert(input:string):string;
getDisplayname(): string;
getId(): string;
convert(input: string): string;
}

View file

@ -1,19 +1,19 @@
import {Converter} from "./converter";
export class DecToBinConverter implements Converter {
getDisplayname():string {
return "Convert decimal to binary";
}
getDisplayname(): string {
return "Convert decimal to binary";
}
getId():string {
return "dectobin";
}
getId(): string {
return "dectobin";
}
convert(input:string):string {
let n:number = parseInt(input, 10);
if (isNaN(n)) {
throw new Error("The input seems not to be a valid integer.");
}
return n.toString(2);
convert(input: string): string {
let n: number = parseInt(input, 10);
if (isNaN(n)) {
throw new Error("The input seems not to be a valid integer.");
}
return n.toString(2);
}
}

View file

@ -1,19 +1,19 @@
import {Converter} from "./converter";
export class DecToHexConverter implements Converter {
getDisplayname():string {
return "Convert decimal to hexadecimal";
}
getDisplayname(): string {
return "Convert decimal to hexadecimal";
}
getId():string {
return "dectohex";
}
getId(): string {
return "dectohex";
}
convert(input:string):string {
let n:number = parseInt(input, 10);
if (isNaN(n)) {
throw new Error("The input seems not to be a valid integer.");
}
return n.toString(16);
convert(input: string): string {
let n: number = parseInt(input, 10);
if (isNaN(n)) {
throw new Error("The input seems not to be a valid integer.");
}
return n.toString(16);
}
}

View file

@ -1,19 +1,19 @@
import {Converter} from "./converter";
export class HexToDecConverter implements Converter {
getDisplayname():string {
return "Convert hexadecimal to decimal";
}
getDisplayname(): string {
return "Convert hexadecimal to decimal";
}
getId():string {
return "hextodec";
}
getId(): string {
return "hextodec";
}
convert(input:string):string {
let n:number = parseInt(input, 16);
if (isNaN(n)) {
throw new Error("The input seems not to be a valid hexadecimal number.")
}
return n.toString(10);
convert(input: string): string {
let n: number = parseInt(input, 16);
if (isNaN(n)) {
throw new Error("The input seems not to be a valid hexadecimal number.")
}
return n.toString(10);
}
}

View file

@ -1,19 +1,19 @@
import {Converter} from "./converter";
export class HTMLEntitiesDecoder implements Converter {
getDisplayname():string {
return "Decode HTML entities";
}
getDisplayname(): string {
return "Decode HTML entities";
}
getId():string {
return "decodehtmlentities";
}
getId(): string {
return "decodehtmlentities";
}
convert(input:string):string {
return input
.replace(/\&quot\;/g, "\"")
.replace(/\&gt\;/g, ">")
.replace(/\&lt\;/g, "<")
.replace(/\&amp\;/g, "&");
}
convert(input: string): string {
return input
.replace(/\&quot\;/g, "\"")
.replace(/\&gt\;/g, ">")
.replace(/\&lt\;/g, "<")
.replace(/\&amp\;/g, "&");
}
}

View file

@ -1,19 +1,19 @@
import {Converter} from "./converter";
export class HTMLEntitiesEncoder implements Converter {
getDisplayname():string {
return "Encode HTML entities";
}
getDisplayname(): string {
return "Encode HTML entities";
}
getId():string {
return "encodehtmlentities";
}
getId(): string {
return "encodehtmlentities";
}
convert(input:string):string {
return input
.replace(/\&/g, "&amp;")
.replace(/\</g, "&lt;")
.replace(/\>/g, "&gt;")
.replace(/\"/g, "&quot;");
}
convert(input: string): string {
return input
.replace(/\&/g, "&amp;")
.replace(/\</g, "&lt;")
.replace(/\>/g, "&gt;")
.replace(/\"/g, "&quot;");
}
}

View file

@ -3,18 +3,18 @@ import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service";
export class PunycodeDecoder implements Converter {
constructor(private nativeLibraryWrapperService: NativeLibraryWrapperService) {
}
constructor(private nativeLibraryWrapperService: NativeLibraryWrapperService) {
}
getDisplayname(): string {
return "Decode from punycode";
}
getDisplayname(): string {
return "Decode from punycode";
}
getId(): string {
return "decodepunycode";
}
getId(): string {
return "decodepunycode";
}
convert(input: string): string {
return this.nativeLibraryWrapperService.punycode.decode(input);
}
convert(input: string): string {
return this.nativeLibraryWrapperService.punycode.decode(input);
}
}

View file

@ -3,18 +3,18 @@ import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service";
export class PunycodeEncoder implements Converter {
constructor(private nativeLibraryWrapperService: NativeLibraryWrapperService) {
}
constructor(private nativeLibraryWrapperService: NativeLibraryWrapperService) {
}
getDisplayname(): string {
return "Encode as punycode";
}
getDisplayname(): string {
return "Encode as punycode";
}
getId(): string {
return "encodepunycode";
}
getId(): string {
return "encodepunycode";
}
convert(input: string): string {
return this.nativeLibraryWrapperService.punycode.encode(input);
}
convert(input: string): string {
return this.nativeLibraryWrapperService.punycode.encode(input);
}
}

View file

@ -3,22 +3,22 @@ import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service";
export class QuotedPrintableDecoder implements Converter {
constructor(private nativeLibraryWrapperService:NativeLibraryWrapperService) {
}
constructor(private nativeLibraryWrapperService: NativeLibraryWrapperService) {
}
getDisplayname():string {
return "Decode quoted printable";
}
getDisplayname(): string {
return "Decode quoted printable";
}
getId():string {
return "decodequotedprintable";
}
getId(): string {
return "decodequotedprintable";
}
convert(input:string):string {
try {
return this.nativeLibraryWrapperService.quotedPrintable.decode(input);
} catch (error) {
throw new Error("The input can not be interpreted as quoted-printable. May be corrupt?");
}
convert(input: string): string {
try {
return this.nativeLibraryWrapperService.quotedPrintable.decode(input);
} catch (error) {
throw new Error("The input can not be interpreted as quoted-printable. May be corrupt?");
}
}
}

View file

@ -3,18 +3,18 @@ import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service";
export class QuotedPrintableEncoder implements Converter {
constructor(private nativeLibraryWrapperService:NativeLibraryWrapperService) {
}
constructor(private nativeLibraryWrapperService: NativeLibraryWrapperService) {
}
getDisplayname():string {
return "Encode quoted printable";
}
getDisplayname(): string {
return "Encode quoted printable";
}
getId():string {
return "encodequotedprintable";
}
getId(): string {
return "encodequotedprintable";
}
convert(input:string):string {
return this.nativeLibraryWrapperService.quotedPrintable.encode(input);
}
convert(input: string): string {
return this.nativeLibraryWrapperService.quotedPrintable.encode(input);
}
}

View file

@ -1,15 +1,15 @@
import {Converter} from "./converter";
export class URIComponentDecoder implements Converter {
getDisplayname():string {
return "Decode URI component";
}
getDisplayname(): string {
return "Decode URI component";
}
getId():string {
return "uricomponentdecode";
}
getId(): string {
return "uricomponentdecode";
}
convert(input:string):string {
return decodeURIComponent(input);
}
convert(input: string): string {
return decodeURIComponent(input);
}
}

View file

@ -1,17 +1,17 @@
import {Converter} from "./converter";
export class URIComponentEncoder implements Converter {
getDisplayname():string {
return "Encode URI component";
}
getDisplayname(): string {
return "Encode URI component";
}
getId():string {
return "uricomponentencode";
}
getId(): string {
return "uricomponentencode";
}
convert(input:string):string {
return encodeURIComponent(input).replace(/[!'()*]/g, function (c) {
return '%' + c.charCodeAt(0).toString(16);
});
}
convert(input: string): string {
return encodeURIComponent(input).replace(/[!'()*]/g, function (c) {
return '%' + c.charCodeAt(0).toString(16);
});
}
}

View file

@ -1,15 +1,15 @@
import {Converter} from "./converter";
export class URIDecoder implements Converter {
getDisplayname():string {
return "Decode URI";
}
getDisplayname(): string {
return "Decode URI";
}
getId():string {
return "uridecode";
}
getId(): string {
return "uridecode";
}
convert(input:string):string {
return decodeURI(input);
}
convert(input: string): string {
return decodeURI(input);
}
}

View file

@ -1,15 +1,15 @@
import {Converter} from "./converter";
export class URIEncoder implements Converter {
getDisplayname():string {
return "Encode URI";
}
getDisplayname(): string {
return "Encode URI";
}
getId():string {
return "uriencode";
}
getId(): string {
return "uriencode";
}
convert(input:string):string {
return encodeURI(input).replace(/%5B/g, '[').replace(/%5D/g, ']');
}
convert(input: string): string {
return encodeURI(input).replace(/%5B/g, '[').replace(/%5D/g, ']');
}
}

View file

@ -3,22 +3,22 @@ import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service";
export class UTF8Decoder implements Converter {
constructor(private nativeLibraryWrapperService:NativeLibraryWrapperService) {
}
constructor(private nativeLibraryWrapperService: NativeLibraryWrapperService) {
}
getDisplayname():string {
return "Decode UTF-8";
}
getDisplayname(): string {
return "Decode UTF-8";
}
getId():string {
return "decodeutf8";
}
getId(): string {
return "decodeutf8";
}
convert(input:string):string {
try {
return this.nativeLibraryWrapperService.utf8.decode(input);
} catch (error) {
throw new Error("The input can not be interpreted a valid UTF-8 encoded string. May be corrupt?");
}
convert(input: string): string {
try {
return this.nativeLibraryWrapperService.utf8.decode(input);
} catch (error) {
throw new Error("The input can not be interpreted a valid UTF-8 encoded string. May be corrupt?");
}
}
}

View file

@ -3,22 +3,22 @@ import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service";
export class UTF8Encoder implements Converter {
constructor(private nativeLibraryWrapperService:NativeLibraryWrapperService) {
}
constructor(private nativeLibraryWrapperService: NativeLibraryWrapperService) {
}
getDisplayname():string {
return "Encode UTF-8";
}
getDisplayname(): string {
return "Encode UTF-8";
}
getId():string {
return "encodeutf8";
}
getId(): string {
return "encodeutf8";
}
convert(input:string):string {
try {
return this.nativeLibraryWrapperService.utf8.encode(input);
} catch (error) {
throw new Error("The input can not be encoded as UTF-8. May be corrupt?");
}
convert(input: string): string {
try {
return this.nativeLibraryWrapperService.utf8.encode(input);
} catch (error) {
throw new Error("The input can not be encoded as UTF-8. May be corrupt?");
}
}
}

View file

@ -22,52 +22,52 @@ import {UTF8Decoder} from "./converter/utf8decoder";
@Injectable()
export class ConverterRegistryService {
private converters:Converter[] = [];
private converters: Converter[] = [];
constructor(private wrapper:NativeLibraryWrapperService) {
this.init();
}
constructor(private wrapper: NativeLibraryWrapperService) {
this.init();
}
public getAllConverters():Converter[] {
return this.converters;
}
public getAllConverters(): Converter[] {
return this.converters;
}
public getConverter(id:string):Converter {
for (let i = 0; i < this.converters.length; i++) {
if (this.converters[i].getId() == id) {
return this.converters[i];
}
}
return undefined;
public getConverter(id: string): Converter {
for (let i = 0; i < this.converters.length; i++) {
if (this.converters[i].getId() == id) {
return this.converters[i];
}
}
return undefined;
}
private init():void {
this.registerConverter(new Base64Encoder());
this.registerConverter(new Base64Decoder());
this.registerConverter(new URIEncoder());
this.registerConverter(new URIDecoder());
this.registerConverter(new URIComponentEncoder());
this.registerConverter(new URIComponentDecoder());
this.registerConverter(new HTMLEntitiesEncoder());
this.registerConverter(new HTMLEntitiesDecoder());
this.registerConverter(new QuotedPrintableEncoder(this.wrapper));
this.registerConverter(new QuotedPrintableDecoder(this.wrapper));
this.registerConverter(new DecToHexConverter());
this.registerConverter(new HexToDecConverter());
this.registerConverter(new DecToBinConverter());
this.registerConverter(new BinToDecConverter());
this.registerConverter(new PunycodeEncoder(this.wrapper));
this.registerConverter(new PunycodeDecoder(this.wrapper));
this.registerConverter(new UTF8Encoder(this.wrapper));
this.registerConverter(new UTF8Decoder(this.wrapper));
}
private init(): void {
this.registerConverter(new Base64Encoder());
this.registerConverter(new Base64Decoder());
this.registerConverter(new URIEncoder());
this.registerConverter(new URIDecoder());
this.registerConverter(new URIComponentEncoder());
this.registerConverter(new URIComponentDecoder());
this.registerConverter(new HTMLEntitiesEncoder());
this.registerConverter(new HTMLEntitiesDecoder());
this.registerConverter(new QuotedPrintableEncoder(this.wrapper));
this.registerConverter(new QuotedPrintableDecoder(this.wrapper));
this.registerConverter(new DecToHexConverter());
this.registerConverter(new HexToDecConverter());
this.registerConverter(new DecToBinConverter());
this.registerConverter(new BinToDecConverter());
this.registerConverter(new PunycodeEncoder(this.wrapper));
this.registerConverter(new PunycodeDecoder(this.wrapper));
this.registerConverter(new UTF8Encoder(this.wrapper));
this.registerConverter(new UTF8Decoder(this.wrapper));
}
private registerConverter(converter:Converter):void {
this.converters.forEach((c:Converter) => {
if (c.getId() == converter.getId()) {
throw new Error("Converter-ID " + converter.getId() + " is already registered!");
}
});
this.converters.push(converter);
}
private registerConverter(converter: Converter): void {
this.converters.forEach((c: Converter) => {
if (c.getId() == converter.getId()) {
throw new Error("Converter-ID " + converter.getId() + " is already registered!");
}
});
this.converters.push(converter);
}
}

View file

@ -3,35 +3,35 @@ import {Step} from "./step";
@Injectable()
export class InputComponentManagerService {
private components:Step[] = [];
private components: Step[] = [];
public constructor() {
}
public constructor() {
}
public register(component:Step):void {
this.components.push(component);
}
public register(component: Step): void {
this.components.push(component);
}
public getAllComponents():Step[] {
return this.components;
}
public getAllComponents(): Step[] {
return this.components;
}
public getNext(component:Step):Step {
let index:number = component.index;
if (index == this.components.length - 1) {
this.addComponent();
}
return this.components[index + 1];
public getNext(component: Step): Step {
let index: number = component.index;
if (index == this.components.length - 1) {
this.addComponent();
}
return this.components[index + 1];
}
public getFirst():Step {
if (this.components.length == 0) {
this.addComponent();
}
return this.components[0];
public getFirst(): Step {
if (this.components.length == 0) {
this.addComponent();
}
return this.components[0];
}
private addComponent():void {
this.register(new Step(this.components.length));
}
}
private addComponent(): void {
this.register(new Step(this.components.length));
}
}

View file

@ -1,4 +1,4 @@
export interface Punycode {
encode(input:string):string;
decode(input:string):string;
encode(input: string): string;
decode(input: string): string;
}

View file

@ -1,4 +1,4 @@
export interface QuotedPrintable {
encode(input:string):string;
decode(input:string):string;
encode(input: string): string;
decode(input: string): string;
}

View file

@ -1,13 +1,13 @@
import {Converter} from "./converter/converter";
export class Step {
public content:string = "";
public selectedConverter:Converter = undefined;
public index:number;
public error:boolean = false;
public message:string = "";
public content: string = "";
public selectedConverter: Converter = undefined;
public index: number;
public error: boolean = false;
public message: string = "";
constructor(index:number) {
this.index = index;
}
}
constructor(index: number) {
this.index = index;
}
}

View file

@ -1,4 +1,4 @@
export interface Utf8 {
encode(input:any):string;
decode(input:string):any;
encode(input: any): string;
decode(input: string): any;
}