Merge branch 'develop' into migrate-to-angular-cli
This commit is contained in:
commit
8c119a55e9
43 changed files with 1455 additions and 1094 deletions
16
src/app/app-routing.module.ts
Normal file
16
src/app/app-routing.module.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import {NgModule} from '@angular/core';
|
||||
import {RouterModule, Routes} from '@angular/router';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
children: []
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forRoot(routes)],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class AppRoutingModule {
|
||||
}
|
|
@ -12,5 +12,6 @@
|
|||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="errormessage" *ngIf="step.error">{{step.message}}</div>
|
||||
<div class="errormessage" *ngIf="step.error" [innerHTML]="step.message"></div>
|
||||
</div>
|
||||
<!--<router-outlet></router-outlet>-->
|
||||
|
|
|
@ -12,53 +12,45 @@
|
|||
position: relative;
|
||||
background: #fff;
|
||||
border: 1px solid #aaa;
|
||||
}
|
||||
|
||||
.arrow_box:focus {
|
||||
border-color: #888;
|
||||
}
|
||||
|
||||
.arrow_box:hover {
|
||||
border-color: #333;
|
||||
}
|
||||
|
||||
.arrow_box:after, .arrow_box:before {
|
||||
top: 100%;
|
||||
left: 50%;
|
||||
border: solid transparent;
|
||||
content: " ";
|
||||
height: 0;
|
||||
width: 0;
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.arrow_box:after {
|
||||
border-color: rgba(255, 255, 255, 0);
|
||||
border-top-color: #fff;
|
||||
border-width: 1em;
|
||||
margin-left: -1em;
|
||||
}
|
||||
|
||||
.arrow_box:before {
|
||||
border-color: rgba(170, 170, 170, 0);
|
||||
border-top-color: #aaa;
|
||||
border-width: calc(1em + 1px);
|
||||
margin-left: calc(-1em - 1px);
|
||||
}
|
||||
|
||||
.arrow_box:focus:before {
|
||||
border-color: rgba(136, 136, 136, 0);
|
||||
border-top-color: #888;
|
||||
}
|
||||
|
||||
.arrow_box:hover:before {
|
||||
border-color: rgba(51, 51, 51, 0);
|
||||
border-top-color: #333;
|
||||
}
|
||||
|
||||
.selectwrapper > .arrow_box {
|
||||
display: inline-block;
|
||||
&:focus {
|
||||
border-color: #888;
|
||||
}
|
||||
&:hover {
|
||||
border-color: #333;
|
||||
}
|
||||
&:after, &:before {
|
||||
top: 100%;
|
||||
left: 50%;
|
||||
border: solid transparent;
|
||||
content: " ";
|
||||
height: 0;
|
||||
width: 0;
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
}
|
||||
&:after {
|
||||
border-color: rgba(255, 255, 255, 0);
|
||||
border-top-color: #fff;
|
||||
border-width: 1em;
|
||||
margin-left: -1em;
|
||||
}
|
||||
&:before {
|
||||
border-color: rgba(170, 170, 170, 0);
|
||||
border-top-color: #aaa;
|
||||
border-width: calc(1em + 1px);
|
||||
margin-left: calc(-1em - 1px);
|
||||
}
|
||||
&:focus:before {
|
||||
border-color: rgba(136, 136, 136, 0);
|
||||
border-top-color: #888;
|
||||
}
|
||||
&:hover:before {
|
||||
border-color: rgba(51, 51, 51, 0);
|
||||
border-top-color: #333;
|
||||
}
|
||||
.selectwrapper > & {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
|
||||
.textinput {
|
||||
|
@ -71,20 +63,29 @@
|
|||
padding: 0.5em;
|
||||
resize: vertical;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.textinput:focus {
|
||||
border-color: #888;
|
||||
}
|
||||
|
||||
.textinput:hover {
|
||||
border-color: #333;
|
||||
&:focus {
|
||||
border-color: #888;
|
||||
}
|
||||
&:hover {
|
||||
border-color: #333;
|
||||
}
|
||||
}
|
||||
|
||||
.selectwrapper {
|
||||
margin: 0 0 1em 0;
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
&.error {
|
||||
> .arrow_box {
|
||||
border-color: red;
|
||||
&:before {
|
||||
border-top-color: red;
|
||||
}
|
||||
}
|
||||
select {
|
||||
color: red;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.select {
|
||||
|
@ -100,18 +101,6 @@
|
|||
/* font-family: "ABeeZee", sans-serif;*/
|
||||
}
|
||||
|
||||
.selectwrapper.error > .arrow_box {
|
||||
border-color: red;
|
||||
}
|
||||
|
||||
.selectwrapper.error > .arrow_box:before {
|
||||
border-top-color: red;
|
||||
}
|
||||
|
||||
.selectwrapper.error select {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.errormessage {
|
||||
color: red;
|
||||
text-align: center;
|
||||
|
|
|
@ -1,32 +1,54 @@
|
|||
import {async, TestBed} from "@angular/core/testing";
|
||||
|
||||
import {AppComponent} from "./app.component";
|
||||
import {AppComponent} from './app.component';
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
import {InputComponentManagerService} from './inputcomponentmanager.service';
|
||||
import {Step} from './step';
|
||||
|
||||
describe('AppComponent', () => {
|
||||
let sut: AppComponent;
|
||||
let fixture: ComponentFixture<AppComponent>;
|
||||
const firstStep: Step = new Step(0);
|
||||
|
||||
const inputComponentManagerServiceStub = {
|
||||
getFirst: () => {
|
||||
return firstStep;
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
/*return */
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [
|
||||
AppComponent
|
||||
],
|
||||
}).compileComponents();
|
||||
declarations: [AppComponent],
|
||||
providers: [{
|
||||
provide: InputComponentManagerService, useValue: inputComponentManagerServiceStub
|
||||
}]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
it('should create the app', async(() => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.debugElement.componentInstance;
|
||||
expect(app).toBeTruthy();
|
||||
}));
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(AppComponent);
|
||||
sut = fixture.componentInstance;
|
||||
});
|
||||
// beforeEach(async(() => {
|
||||
// TestBed.configureTestingModule({
|
||||
// imports: [
|
||||
// RouterTestingModule
|
||||
// ],
|
||||
// declarations: [
|
||||
// AppComponent
|
||||
// ],
|
||||
// }).compileComponents();
|
||||
// }));
|
||||
|
||||
// it(`should have as title 'app works!'`, async(() => {
|
||||
it('should be true that true is true', () => {
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
|
||||
// it('should create the app', async(() => {
|
||||
// const fixture = TestBed.createComponent(AppComponent);
|
||||
// const app = fixture.debugElement.componentInstance;
|
||||
// expect(app.title).toEqual('app works!');
|
||||
// expect(app).toBeTruthy();
|
||||
// }));
|
||||
|
||||
// it('should render title in a h1 tag', async(() => {
|
||||
// const fixture = TestBed.createComponent(AppComponent);
|
||||
// fixture.detectChanges();
|
||||
// const compiled = fixture.debugElement.nativeElement;
|
||||
// expect(compiled.querySelector('h1').textContent).toContain('app works!');
|
||||
// }));
|
||||
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import {Component, OnInit} from "@angular/core";
|
||||
import {NativeLibraryWrapperService} from "./nativelibrarywrapper.service";
|
||||
import {InputComponentManagerService} from "./inputcomponentmanager.service";
|
||||
import {ConverterRegistryService} from "./converterregistry.service";
|
||||
import {Step} from "./step";
|
||||
import {Converter} from "./converter/converter";
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {ConverterRegistryService} from './converterregistry.service';
|
||||
import {InputComponentManagerService} from './inputcomponentmanager.service';
|
||||
import {NativeLibraryWrapperService} from './nativelibrarywrapper.service';
|
||||
import {Step} from './step';
|
||||
import {Converter} from './converter/converter';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
|
@ -15,7 +15,8 @@ export class AppComponent implements OnInit {
|
|||
public steps: Step[] = [];
|
||||
public converters: Converter[] = [];
|
||||
|
||||
constructor(private converterRegistryService: ConverterRegistryService, private inputComponentManagerService: InputComponentManagerService) {
|
||||
constructor(private converterRegistryService: ConverterRegistryService,
|
||||
private inputComponentManagerService: InputComponentManagerService) {
|
||||
}
|
||||
|
||||
convert(step: Step, $event: any): void {
|
||||
|
@ -24,15 +25,15 @@ export class AppComponent implements OnInit {
|
|||
}
|
||||
|
||||
update(step: Step): void {
|
||||
let converter: Converter = step.selectedConverter;
|
||||
const converter: Converter = step.selectedConverter;
|
||||
|
||||
if (converter !== undefined) {
|
||||
let content: string = step.content;
|
||||
const content: string = step.content;
|
||||
let result: string;
|
||||
try {
|
||||
result = converter.convert(content);
|
||||
} catch (error) {
|
||||
if (typeof console === "object" && typeof console.log === "function") {
|
||||
if (typeof console === 'object' && typeof console.log === 'function') {
|
||||
console.log(error);
|
||||
}
|
||||
step.message = error.message;
|
||||
|
@ -40,10 +41,10 @@ export class AppComponent implements OnInit {
|
|||
result = null;
|
||||
}
|
||||
if (result !== null) {
|
||||
step.message = "";
|
||||
step.message = '';
|
||||
step.error = false;
|
||||
if (result !== "") {
|
||||
let nextComponent: Step = this.inputComponentManagerService.getNext(step);
|
||||
if (result !== '') {
|
||||
const nextComponent: Step = this.inputComponentManagerService.getNext(step);
|
||||
nextComponent.content = result;
|
||||
this.update(nextComponent);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import {BrowserModule} from "@angular/platform-browser";
|
||||
import {NgModule} from "@angular/core";
|
||||
import {FormsModule} from "@angular/forms";
|
||||
import {BrowserModule} from '@angular/platform-browser';
|
||||
import {NgModule} from '@angular/core';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {HttpModule} from '@angular/http';
|
||||
|
||||
import {AppComponent} from "./app.component";
|
||||
import {AppRoutingModule} from './app-routing.module';
|
||||
import {AppComponent} from './app.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
|
@ -10,7 +12,9 @@ import {AppComponent} from "./app.component";
|
|||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
FormsModule
|
||||
FormsModule,
|
||||
HttpModule,
|
||||
AppRoutingModule
|
||||
],
|
||||
providers: [],
|
||||
bootstrap: [AppComponent]
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
import {Converter} from "./converter";
|
||||
import {Converter} from './converter';
|
||||
|
||||
export class Base64Decoder implements Converter {
|
||||
getDisplayname(): string {
|
||||
return "Decode Base 64";
|
||||
return 'Decode Base 64';
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
return "base64decode";
|
||||
return 'base64decode';
|
||||
}
|
||||
|
||||
convert(input: string): string {
|
||||
try {
|
||||
return atob(input);
|
||||
} catch (exception) {
|
||||
throw new Error("Could not decode base64 string. Maybe corrupt input?");
|
||||
throw new Error('Could not decode base64 string. Maybe corrupt input?');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,22 @@
|
|||
import {Converter} from "./converter";
|
||||
import {Converter} from './converter';
|
||||
|
||||
export class Base64Encoder implements Converter {
|
||||
getDisplayname(): string {
|
||||
return "Encode Base 64";
|
||||
return 'Encode Base 64';
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
return "base64encode";
|
||||
return 'base64encode';
|
||||
}
|
||||
|
||||
convert(input: string): string {
|
||||
try {
|
||||
return btoa(input);
|
||||
} catch (exception) {
|
||||
throw new Error("Could not encode base64 string. This should not happen, so why don't you just try again?");
|
||||
console.error(exception);
|
||||
throw new Error('Ouch! Looks like you\'ve got a UTF-8 character there. Too bad, this is not supported yet. '
|
||||
+ 'We\'re working on it and hope to be ready soon! Why don\'t you '
|
||||
+ '<a href="https://duckduckgo.com/?q=cute+kitties&iar=images">enjoy some kittens</a> meanwhile?');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
import {Converter} from "./converter";
|
||||
import {Converter} from './converter';
|
||||
|
||||
export class BinToDecConverter implements Converter {
|
||||
getDisplayname(): string {
|
||||
return "Convert binary to decimal";
|
||||
return 'Convert binary to decimal';
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
return "bintodec";
|
||||
return 'bintodec';
|
||||
}
|
||||
|
||||
convert(input: string): string {
|
||||
let n: number = parseInt(input, 2);
|
||||
const n: number = parseInt(input, 2);
|
||||
if (isNaN(n)) {
|
||||
throw new Error("The input seems not to be a valid binary number.");
|
||||
throw new Error('The input seems not to be a valid binary number.');
|
||||
}
|
||||
return n.toString(10);
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
import {Converter} from "./converter";
|
||||
import {Converter} from './converter';
|
||||
|
||||
export class DecToBinConverter implements Converter {
|
||||
getDisplayname(): string {
|
||||
return "Convert decimal to binary";
|
||||
return 'Convert decimal to binary';
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
return "dectobin";
|
||||
return 'dectobin';
|
||||
}
|
||||
|
||||
convert(input: string): string {
|
||||
let n: number = parseInt(input, 10);
|
||||
const n: number = parseInt(input, 10);
|
||||
if (isNaN(n)) {
|
||||
throw new Error("The input seems not to be a valid integer.");
|
||||
throw new Error('The input seems not to be a valid integer.');
|
||||
}
|
||||
return n.toString(2);
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
import {Converter} from "./converter";
|
||||
import {Converter} from './converter';
|
||||
|
||||
export class DecToHexConverter implements Converter {
|
||||
getDisplayname(): string {
|
||||
return "Convert decimal to hexadecimal";
|
||||
return 'Convert decimal to hexadecimal';
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
return "dectohex";
|
||||
return 'dectohex';
|
||||
}
|
||||
|
||||
convert(input: string): string {
|
||||
let n: number = parseInt(input, 10);
|
||||
const n: number = parseInt(input, 10);
|
||||
if (isNaN(n)) {
|
||||
throw new Error("The input seems not to be a valid integer.");
|
||||
throw new Error('The input seems not to be a valid integer.');
|
||||
}
|
||||
return n.toString(16);
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
import {Converter} from "./converter";
|
||||
import {Converter} from './converter';
|
||||
|
||||
export class HexToDecConverter implements Converter {
|
||||
getDisplayname(): string {
|
||||
return "Convert hexadecimal to decimal";
|
||||
return 'Convert hexadecimal to decimal';
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
return "hextodec";
|
||||
return 'hextodec';
|
||||
}
|
||||
|
||||
convert(input: string): string {
|
||||
let n: number = parseInt(input, 16);
|
||||
const n: number = parseInt(input, 16);
|
||||
if (isNaN(n)) {
|
||||
throw new Error("The input seems not to be a valid hexadecimal number.")
|
||||
throw new Error('The input seems not to be a valid hexadecimal number.');
|
||||
}
|
||||
return n.toString(10);
|
||||
}
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
import {Converter} from "./converter";
|
||||
import {Converter} from './converter';
|
||||
|
||||
export class HTMLEntitiesDecoder implements Converter {
|
||||
getDisplayname(): string {
|
||||
return "Decode HTML entities";
|
||||
return 'Decode HTML entities';
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
return "decodehtmlentities";
|
||||
return 'decodehtmlentities';
|
||||
}
|
||||
|
||||
convert(input: string): string {
|
||||
return input
|
||||
.replace(/\"\;/g, "\"")
|
||||
.replace(/\>\;/g, ">")
|
||||
.replace(/\<\;/g, "<")
|
||||
.replace(/\&\;/g, "&");
|
||||
.replace(/\"\;/g, '"')
|
||||
.replace(/\>\;/g, '>')
|
||||
.replace(/\<\;/g, '<')
|
||||
.replace(/\&\;/g, '&');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
import {Converter} from "./converter";
|
||||
import {Converter} from './converter';
|
||||
|
||||
export class HTMLEntitiesEncoder implements Converter {
|
||||
getDisplayname(): string {
|
||||
return "Encode HTML entities";
|
||||
return 'Encode HTML entities';
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
return "encodehtmlentities";
|
||||
return 'encodehtmlentities';
|
||||
}
|
||||
|
||||
convert(input: string): string {
|
||||
return input
|
||||
.replace(/\&/g, "&")
|
||||
.replace(/\</g, "<")
|
||||
.replace(/\>/g, ">")
|
||||
.replace(/\"/g, """);
|
||||
.replace(/\&/g, '&')
|
||||
.replace(/\</g, '<')
|
||||
.replace(/\>/g, '>')
|
||||
.replace(/\"/g, '"');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {Converter} from "./converter";
|
||||
import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service";
|
||||
import {Converter} from './converter';
|
||||
import {NativeLibraryWrapperService} from '../nativelibrarywrapper.service';
|
||||
|
||||
export class PunycodeDecoder implements Converter {
|
||||
|
||||
|
@ -7,11 +7,11 @@ export class PunycodeDecoder implements Converter {
|
|||
}
|
||||
|
||||
getDisplayname(): string {
|
||||
return "Decode from punycode";
|
||||
return 'Decode from punycode';
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
return "decodepunycode";
|
||||
return 'decodepunycode';
|
||||
}
|
||||
|
||||
convert(input: string): string {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {Converter} from "./converter";
|
||||
import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service";
|
||||
import {Converter} from './converter';
|
||||
import {NativeLibraryWrapperService} from '../nativelibrarywrapper.service';
|
||||
|
||||
export class PunycodeEncoder implements Converter {
|
||||
|
||||
|
@ -7,11 +7,11 @@ export class PunycodeEncoder implements Converter {
|
|||
}
|
||||
|
||||
getDisplayname(): string {
|
||||
return "Encode as punycode";
|
||||
return 'Encode as punycode';
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
return "encodepunycode";
|
||||
return 'encodepunycode';
|
||||
}
|
||||
|
||||
convert(input: string): string {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {Converter} from "./converter";
|
||||
import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service";
|
||||
import {Converter} from './converter';
|
||||
import {NativeLibraryWrapperService} from '../nativelibrarywrapper.service';
|
||||
|
||||
export class QuotedPrintableDecoder implements Converter {
|
||||
|
||||
|
@ -7,18 +7,18 @@ export class QuotedPrintableDecoder implements Converter {
|
|||
}
|
||||
|
||||
getDisplayname(): string {
|
||||
return "Decode quoted printable";
|
||||
return 'Decode quoted printable';
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
return "decodequotedprintable";
|
||||
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?");
|
||||
throw new Error('The input can not be interpreted as quoted-printable. May be corrupt?');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {Converter} from "./converter";
|
||||
import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service";
|
||||
import {Converter} from './converter';
|
||||
import {NativeLibraryWrapperService} from '../nativelibrarywrapper.service';
|
||||
|
||||
export class QuotedPrintableEncoder implements Converter {
|
||||
|
||||
|
@ -7,11 +7,11 @@ export class QuotedPrintableEncoder implements Converter {
|
|||
}
|
||||
|
||||
getDisplayname(): string {
|
||||
return "Encode quoted printable";
|
||||
return 'Encode quoted printable';
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
return "encodequotedprintable";
|
||||
return 'encodequotedprintable';
|
||||
}
|
||||
|
||||
convert(input: string): string {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import {Converter} from "./converter";
|
||||
import {Converter} from './converter';
|
||||
|
||||
export class URIComponentDecoder implements Converter {
|
||||
getDisplayname(): string {
|
||||
return "Decode URI component";
|
||||
return 'Decode URI component';
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
return "uricomponentdecode";
|
||||
return 'uricomponentdecode';
|
||||
}
|
||||
|
||||
convert(input: string): string {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import {Converter} from "./converter";
|
||||
import {Converter} from './converter';
|
||||
|
||||
export class URIComponentEncoder implements Converter {
|
||||
getDisplayname(): string {
|
||||
return "Encode URI component";
|
||||
return 'Encode URI component';
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
return "uricomponentencode";
|
||||
return 'uricomponentencode';
|
||||
}
|
||||
|
||||
convert(input: string): string {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import {Converter} from "./converter";
|
||||
import {Converter} from './converter';
|
||||
|
||||
export class URIDecoder implements Converter {
|
||||
getDisplayname(): string {
|
||||
return "Decode URI";
|
||||
return 'Decode URI';
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
return "uridecode";
|
||||
return 'uridecode';
|
||||
}
|
||||
|
||||
convert(input: string): string {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import {Converter} from "./converter";
|
||||
import {Converter} from './converter';
|
||||
|
||||
export class URIEncoder implements Converter {
|
||||
getDisplayname(): string {
|
||||
return "Encode URI";
|
||||
return 'Encode URI';
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
return "uriencode";
|
||||
return 'uriencode';
|
||||
}
|
||||
|
||||
convert(input: string): string {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {Converter} from "./converter";
|
||||
import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service";
|
||||
import {Converter} from './converter';
|
||||
import {NativeLibraryWrapperService} from '../nativelibrarywrapper.service';
|
||||
|
||||
export class UTF8Decoder implements Converter {
|
||||
|
||||
|
@ -7,18 +7,18 @@ export class UTF8Decoder implements Converter {
|
|||
}
|
||||
|
||||
getDisplayname(): string {
|
||||
return "Decode UTF-8";
|
||||
return 'Decode UTF-8';
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
return "decodeutf8";
|
||||
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?");
|
||||
throw new Error('The input can not be interpreted a valid UTF-8 encoded string. May be corrupt?');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {Converter} from "./converter";
|
||||
import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service";
|
||||
import {Converter} from './converter';
|
||||
import {NativeLibraryWrapperService} from '../nativelibrarywrapper.service';
|
||||
|
||||
export class UTF8Encoder implements Converter {
|
||||
|
||||
|
@ -7,18 +7,18 @@ export class UTF8Encoder implements Converter {
|
|||
}
|
||||
|
||||
getDisplayname(): string {
|
||||
return "Encode UTF-8";
|
||||
return 'Encode UTF-8';
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
return "encodeutf8";
|
||||
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?");
|
||||
throw new Error('The input can not be encoded as UTF-8. May be corrupt?');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
import {Injectable} from "@angular/core";
|
||||
import {Converter} from "./converter/converter";
|
||||
import {Base64Encoder} from "./converter/base64encoder";
|
||||
import {Base64Decoder} from "./converter/base64decoder";
|
||||
import {URIEncoder} from "./converter/uriencoder";
|
||||
import {URIDecoder} from "./converter/uridecoder";
|
||||
import {URIComponentEncoder} from "./converter/uricomponentencoder";
|
||||
import {URIComponentDecoder} from "./converter/uricomponentdecoder";
|
||||
import {HTMLEntitiesEncoder} from "./converter/htmlentitiesencoder";
|
||||
import {HTMLEntitiesDecoder} from "./converter/htmlentitiesdecoder";
|
||||
import {DecToHexConverter} from "./converter/dectohexconverter";
|
||||
import {HexToDecConverter} from "./converter/hextodecconverter";
|
||||
import {DecToBinConverter} from "./converter/dectobinconverter";
|
||||
import {BinToDecConverter} from "./converter/bintodecconverter";
|
||||
import {QuotedPrintableDecoder} from "./converter/quotedprintabledecoder";
|
||||
import {QuotedPrintableEncoder} from "./converter/quotedprintableencoder";
|
||||
import {NativeLibraryWrapperService} from "./nativelibrarywrapper.service";
|
||||
import {PunycodeEncoder} from "./converter/punycodeencoder";
|
||||
import {PunycodeDecoder} from "./converter/punycodedecoder";
|
||||
import {UTF8Encoder} from "./converter/utf8encoder";
|
||||
import {UTF8Decoder} from "./converter/utf8decoder";
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Converter} from './converter/converter';
|
||||
import {Base64Encoder} from './converter/base64encoder';
|
||||
import {Base64Decoder} from './converter/base64decoder';
|
||||
import {URIEncoder} from './converter/uriencoder';
|
||||
import {URIDecoder} from './converter/uridecoder';
|
||||
import {URIComponentEncoder} from './converter/uricomponentencoder';
|
||||
import {URIComponentDecoder} from './converter/uricomponentdecoder';
|
||||
import {HTMLEntitiesEncoder} from './converter/htmlentitiesencoder';
|
||||
import {HTMLEntitiesDecoder} from './converter/htmlentitiesdecoder';
|
||||
import {DecToHexConverter} from './converter/dectohexconverter';
|
||||
import {HexToDecConverter} from './converter/hextodecconverter';
|
||||
import {DecToBinConverter} from './converter/dectobinconverter';
|
||||
import {BinToDecConverter} from './converter/bintodecconverter';
|
||||
import {QuotedPrintableDecoder} from './converter/quotedprintabledecoder';
|
||||
import {QuotedPrintableEncoder} from './converter/quotedprintableencoder';
|
||||
import {NativeLibraryWrapperService} from './nativelibrarywrapper.service';
|
||||
import {PunycodeEncoder} from './converter/punycodeencoder';
|
||||
import {PunycodeDecoder} from './converter/punycodedecoder';
|
||||
import {UTF8Encoder} from './converter/utf8encoder';
|
||||
import {UTF8Decoder} from './converter/utf8decoder';
|
||||
|
||||
@Injectable()
|
||||
export class ConverterRegistryService {
|
||||
|
@ -34,7 +34,7 @@ export class ConverterRegistryService {
|
|||
|
||||
public getConverter(id: string): Converter {
|
||||
for (let i = 0; i < this.converters.length; i++) {
|
||||
if (this.converters[i].getId() == id) {
|
||||
if (this.converters[i].getId() === id) {
|
||||
return this.converters[i];
|
||||
}
|
||||
}
|
||||
|
@ -64,8 +64,8 @@ export class ConverterRegistryService {
|
|||
|
||||
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!");
|
||||
if (c.getId() === converter.getId()) {
|
||||
throw new Error('Converter-ID ' + converter.getId() + ' is already registered!');
|
||||
}
|
||||
});
|
||||
this.converters.push(converter);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {Injectable} from "@angular/core";
|
||||
import {Step} from "./step";
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Step} from './step';
|
||||
|
||||
@Injectable()
|
||||
export class InputComponentManagerService {
|
||||
|
@ -17,15 +17,15 @@ export class InputComponentManagerService {
|
|||
}
|
||||
|
||||
public getNext(component: Step): Step {
|
||||
let index: number = component.index;
|
||||
if (index == this.components.length - 1) {
|
||||
const 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) {
|
||||
if (this.components.length === 0) {
|
||||
this.addComponent();
|
||||
}
|
||||
return this.components[0];
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import {Injectable} from "@angular/core";
|
||||
import {Punycode} from "./punycode";
|
||||
import {Utf8} from "./utf8";
|
||||
import {QuotedPrintable} from "./quotedprintable";
|
||||
import * as QuotedPrintableNative from "quoted-printable";
|
||||
import * as Utf8Native from "utf8";
|
||||
import * as PunycodeNative from "punycode";
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Punycode} from './punycode';
|
||||
import {Utf8} from './utf8';
|
||||
import {QuotedPrintable} from './quotedprintable';
|
||||
import * as NativeUtf8 from 'utf8';
|
||||
import * as NativeQuotedPrintable from 'quoted-printable';
|
||||
import * as NativePunycode from 'punycode';
|
||||
|
||||
@Injectable()
|
||||
export class NativeLibraryWrapperService {
|
||||
|
@ -13,8 +13,8 @@ export class NativeLibraryWrapperService {
|
|||
public punycode: Punycode;
|
||||
|
||||
constructor() {
|
||||
this.utf8 = Utf8Native;
|
||||
this.quotedPrintable = QuotedPrintableNative;
|
||||
this.punycode = PunycodeNative;
|
||||
this.utf8 = NativeUtf8;
|
||||
this.quotedPrintable = NativeQuotedPrintable;
|
||||
this.punycode = NativePunycode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import {Converter} from "./converter/converter";
|
||||
import {Converter} from './converter/converter';
|
||||
|
||||
export class Step {
|
||||
public content: string = "";
|
||||
public content = '';
|
||||
public selectedConverter: Converter = undefined;
|
||||
public index: number;
|
||||
public error: boolean = false;
|
||||
public message: string = "";
|
||||
public error = false;
|
||||
public message = '';
|
||||
|
||||
constructor(index: number) {
|
||||
this.index = index;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue