Migrated the tool chain to angular-cli and updated all dependencies to their latest versions.

This commit is contained in:
Manuel Friedli 2017-04-15 09:38:23 +02:00
parent 6dd65fd488
commit 038b42c967
68 changed files with 6266 additions and 909 deletions

View file

@ -1,118 +0,0 @@
.inputwrapper {
font-family: "ABeeZee", sans-serif;
margin: 0 1em 1em 1em;
}
.textwrapper {
margin: 0 0 1em 0;
padding: 0 1em 0 0;
}
.arrow_box {
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;
}
.textinput {
background-color: #fff;
border: none;
color: #000;
font-family: "Free Monospaced", monospace;
height: 10em;
margin: 0;
padding: 0.5em;
resize: vertical;
width: 100%;
}
.textinput:focus {
border-color: #888;
}
.textinput:hover {
border-color: #333;
}
.selectwrapper {
margin: 0 0 1em 0;
padding: 0;
text-align: center;
}
.select {
background-color: #fff;
border: none;
color: #000;
font-family: "ABeeZee", sans-serif;
margin: 0;
padding: 0.5em;
}
.option {
/* 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;
}

View file

@ -1,16 +1,16 @@
<div *ngFor="let step of steps" class="inputwrapper">
<div class="textwrapper arrow_box">
<textarea class="textinput" (keyup)="update(step)" placeholder="Please enter your input ..."
[(ngModel)]="step.content">{{step.content}}</textarea>
<div class="textwrapper arrow_box">
<textarea class="textinput" (keyup)="update(step)" placeholder="Please enter your input ..."
[(ngModel)]="step.content">{{step.content}}</textarea>
</div>
<div [ngClass]="{selectwrapper: true, error: step.error}">
<div class="arrow_box">
<select class="select" (change)="convert(step, $event)">
<option id="undefined">Select conversion ...</option>
<option class="option" *ngFor="let c of converters" id="{{c.getId()}}">{{c.getDisplayname()}}
</option>
</select>
</div>
<div [ngClass]="{selectwrapper: true, error: step.error}">
<div class="arrow_box">
<select class="select" (change)="convert(step, $event)">
<option id="undefined">Select conversion ...</option>
<option class="option" *ngFor="let c of converters" id="{{c.getId()}}">{{c.getDisplayname()}}
</option>
</select>
</div>
</div>
<div class="errormessage" *ngIf="step.error">{{step.message}}</div>
</div>
<div class="errormessage" *ngIf="step.error">{{step.message}}</div>
</div>

118
src/app/app.component.scss Normal file
View file

@ -0,0 +1,118 @@
.inputwrapper {
font-family: "ABeeZee", sans-serif;
margin: 0 1em 1em 1em;
}
.textwrapper {
margin: 0 0 1em 0;
padding: 0 1em 0 0;
}
.arrow_box {
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;
}
.textinput {
background-color: #fff;
border: none;
color: #000;
font-family: "Free Monospaced", monospace;
height: 10em;
margin: 0;
padding: 0.5em;
resize: vertical;
width: 100%;
}
.textinput:focus {
border-color: #888;
}
.textinput:hover {
border-color: #333;
}
.selectwrapper {
margin: 0 0 1em 0;
padding: 0;
text-align: center;
}
.select {
background-color: #fff;
border: none;
color: #000;
font-family: "ABeeZee", sans-serif;
margin: 0;
padding: 0.5em;
}
.option {
/* 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;
}

View file

@ -1,16 +1,32 @@
import {TestBed} from "@angular/core/testing";
import {AppComponent} from "./app.component";
import {FormsModule} from "@angular/forms";
import {async, TestBed} from "@angular/core/testing";
describe('App', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [AppComponent],
imports: [FormsModule]
});
});
it('should work', () => {
let fixture = TestBed.createComponent(AppComponent);
expect(fixture.componentInstance instanceof AppComponent).toBe(true, 'should create AppComponent');
});
});
import {AppComponent} from "./app.component";
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
}).compileComponents();
}));
it('should create the app', async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
// it(`should have as title 'app works!'`, async(() => {
// const fixture = TestBed.createComponent(AppComponent);
// const app = fixture.debugElement.componentInstance;
// expect(app.title).toEqual('app works!');
// }));
// 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!');
// }));
});

View file

@ -1,61 +1,59 @@
import {Component, OnInit} from "@angular/core";
import {ConverterRegistryService} from "./converterregistry.service";
import {InputComponentManagerService} from "./inputcomponentmanager.service";
import {Converter} from "./converter/converter";
import {NativeLibraryWrapperService} from "./nativelibrarywrapper.service";
import {InputComponentManagerService} from "./inputcomponentmanager.service";
import {ConverterRegistryService} from "./converterregistry.service";
import {Step} from "./step";
import "../assets/css/style.css";
import {Converter} from "./converter/converter";
@Component({
selector: "den-app",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"],
providers: [ConverterRegistryService, InputComponentManagerService, NativeLibraryWrapperService]
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
providers: [ConverterRegistryService, InputComponentManagerService, NativeLibraryWrapperService]
})
export class AppComponent extends OnInit {
public steps:Step[] = [];
public converters:Converter[] = [];
export class AppComponent implements OnInit {
public steps: Step[] = [];
public converters: Converter[] = [];
constructor(private converterRegistryService:ConverterRegistryService, private inputComponentManagerService:InputComponentManagerService) {
super();
}
constructor(private converterRegistryService: ConverterRegistryService, private inputComponentManagerService: InputComponentManagerService) {
}
convert(step:Step, $event:any):void {
step.selectedConverter = this.converterRegistryService.getConverter($event.target.selectedOptions[0].id);
this.update(step);
}
convert(step: Step, $event: any): void {
step.selectedConverter = this.converterRegistryService.getConverter($event.target.selectedOptions[0].id);
this.update(step);
}
update(step:Step):void {
let converter:Converter = step.selectedConverter;
update(step: Step): void {
let converter: Converter = step.selectedConverter;
if (converter !== undefined) {
let content:string = step.content;
let result:string;
try {
result = converter.convert(content);
} catch (error) {
if (typeof console === "object" && typeof console.log === "function") {
console.log(error);
}
step.message = error.message;
step.error = true;
result = null;
}
if (result !== null) {
step.message = "";
step.error = false;
if (result !== "") {
let nextComponent:Step = this.inputComponentManagerService.getNext(step);
nextComponent.content = result;
this.update(nextComponent);
}
}
if (converter !== undefined) {
let content: string = step.content;
let result: string;
try {
result = converter.convert(content);
} catch (error) {
if (typeof console === "object" && typeof console.log === "function") {
console.log(error);
}
step.message = error.message;
step.error = true;
result = null;
}
if (result !== null) {
step.message = "";
step.error = false;
if (result !== "") {
let nextComponent: Step = this.inputComponentManagerService.getNext(step);
nextComponent.content = result;
this.update(nextComponent);
}
}
}
}
ngOnInit():void {
this.converters = this.converterRegistryService.getAllConverters();
this.steps = this.inputComponentManagerService.getAllComponents();
this.inputComponentManagerService.getFirst();
}
ngOnInit(): void {
this.converters = this.converterRegistryService.getAllConverters();
this.steps = this.inputComponentManagerService.getAllComponents();
this.inputComponentManagerService.getFirst();
}
}

View file

@ -1,17 +1,19 @@
import {NgModule} from "@angular/core";
import {BrowserModule} from "@angular/platform-browser";
import {NgModule} from "@angular/core";
import {FormsModule} from "@angular/forms";
import {AppComponent} from "./app.component";
@NgModule({
imports: [
BrowserModule,
FormsModule
],
declarations: [
AppComponent
],
bootstrap: [AppComponent]
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule
],
providers: [],
bootstrap: [AppComponent]
})
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 Base64Encoder implements Converter {
getDisplayname():string {
return "Encode Base 64";
}
getDisplayname(): string {
return "Encode Base 64";
}
getId():string {
return "base64encode";
}
getId(): string {
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?");
}
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?");
}
}
}

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

@ -2,16 +2,19 @@ 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";
@Injectable()
export class NativeLibraryWrapperService {
public utf8:Utf8;
public quotedPrintable:QuotedPrintable;
public punycode:Punycode;
public utf8: Utf8;
public quotedPrintable: QuotedPrintable;
public punycode: Punycode;
constructor() {
this.utf8 = require("utf8");
this.quotedPrintable = require("quoted-printable");
this.punycode = require("punycode");
}
constructor() {
this.utf8 = Utf8Native;
this.quotedPrintable = QuotedPrintableNative;
this.punycode = PunycodeNative;
}
}

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;
}

0
src/assets/.gitkeep Normal file
View file

View file

@ -1,37 +0,0 @@
@font-face {
font-family: "ABeeZee";
font-stretch: normal;
font-style: normal;
font-variant: normal;
font-weight: normal;
src: local("ABeeZee Regular"),
local("ABeeZee-Regular"),
local("ABeeZee"),
url("../fonts/abeezee-regular.woff") format("woff");
}
@font-face {
font-family: "Free Monospaced";
src: url("../fonts/freemono.eot?") format("eot"),
url("../fonts/freemono.woff") format("woff"),
url("../fonts/freemono.ttf") format("truetype"),
url("../fonts/freemono.svg#FreeMono") format("svg");
font-weight: normal;
font-style: normal;
}
body {
background-color: white;
color: black;
font-family: "ABeeZee", sans-serif;
margin: 0;
padding: 1em 0 0 0;
}
h1 {
text-align: center;
}
.apploader {
text-align: center;
}

View file

@ -0,0 +1,3 @@
export const environment = {
production: true
};

View file

@ -0,0 +1,8 @@
// The file contents for the current environment will overwrite these during build.
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
// The list of which env maps to which file can be found in `.angular-cli.json`.
export const environment = {
production: false
};

BIN
src/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View file

@ -1,18 +1,21 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/>
<title>conv.friedli.info - Convert whatever you want!</title>
<meta charset="utf-8">
<title>Convertorizr</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<h1>Convert it all</h1>
<noscript>This webpage lets you convert data and text to and from various formats. But
it requires you to <strong>enable Javascript</strong> to do so. So please turn it on in your
Browser. You won't regret it!
it requires you to <strong>enable Javascript</strong> to do so. So please turn it on in your
Browser. You won't regret it!
</noscript>
<den-app>
<div class="apploader">Please hold on, we're starting the turbines ...</div>
</den-app>
<app-root>
<div class="apploader">Please hold on, we're starting the turbines ...</div>
</app-root>
</body>
</html>

View file

@ -1,9 +1,11 @@
import {platformBrowserDynamic} from "@angular/platform-browser-dynamic";
import {AppModule} from "./app/app.module";
import {enableProdMode} from "@angular/core";
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
if (process.env.NODE_ENV === "production") {
enableProdMode();
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule);

View file

@ -1,11 +1,68 @@
import "core-js/es6";
import "core-js/es7/reflect";
require("zone.js/dist/zone");
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
*
* Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
*/
if (process.env.ENV === 'production') {
// Production
} else {
// Development and test
Error['stackTraceLimit'] = Infinity;
require('zone.js/dist/long-stack-trace-zone');
}
/***************************************************************************************************
* BROWSER POLYFILLS
*/
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
// import 'core-js/es6/symbol';
// import 'core-js/es6/object';
// import 'core-js/es6/function';
// import 'core-js/es6/parse-int';
// import 'core-js/es6/parse-float';
// import 'core-js/es6/number';
// import 'core-js/es6/math';
// import 'core-js/es6/string';
// import 'core-js/es6/date';
// import 'core-js/es6/array';
// import 'core-js/es6/regexp';
// import 'core-js/es6/map';
// import 'core-js/es6/set';
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js'; // Run `npm install --save classlist.js`.
/** IE10 and IE11 requires the following to support `@angular/animation`. */
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/** Evergreen browsers require these. **/
import 'core-js/es6/reflect';
import 'core-js/es7/reflect';
/** ALL Firefox browsers require the following to support `@angular/animation`. **/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/***************************************************************************************************
* Zone JS is required by Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/
/**
* Date, currency, decimal and percent pipes.
* Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
*/
// import 'intl'; // Run `npm install --save intl`.

38
src/styles.scss Normal file
View file

@ -0,0 +1,38 @@
/* You can add global styles to this file, and also import other style files */
@font-face {
font-family: "ABeeZee";
font-stretch: normal;
font-style: normal;
font-variant: normal;
font-weight: normal;
src: local("ABeeZee Regular"),
local("ABeeZee-Regular"),
local("ABeeZee"),
url("assets/fonts/abeezee-regular.woff") format("woff");
}
@font-face {
font-family: "Free Monospaced";
src: url("assets/fonts/freemono.eot?") format("eot"),
url("assets/fonts/freemono.woff") format("woff"),
url("assets/fonts/freemono.ttf") format("truetype"),
url("assets/fonts/freemono.svg#FreeMono") format("svg");
font-weight: normal;
font-style: normal;
}
body {
background-color: white;
color: black;
font-family: "ABeeZee", sans-serif;
margin: 0;
padding: 1em 0 0 0;
}
h1 {
text-align: center;
}
.apploader {
text-align: center;
}

32
src/test.ts Normal file
View file

@ -0,0 +1,32 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/dist/long-stack-trace-zone';
import 'zone.js/dist/proxy.js';
import 'zone.js/dist/sync-test';
import 'zone.js/dist/jasmine-patch';
import 'zone.js/dist/async-test';
import 'zone.js/dist/fake-async-test';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
declare var __karma__: any;
declare var require: any;
// Prevent Karma from running prematurely.
__karma__.loaded = function () {};
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);
// Finally, start Karma to run the tests.
__karma__.start();

13
src/tsconfig.app.json Normal file
View file

@ -0,0 +1,13 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"baseUrl": "",
"types": []
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}

View file

@ -1,20 +0,0 @@
{
"compilerOptions": {
"alwaysStrict": true,
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es2015",
"dom"
],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"typeRoots": [
"../node_modules/@types/"
]
}
}

20
src/tsconfig.spec.json Normal file
View file

@ -0,0 +1,20 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"module": "commonjs",
"target": "es5",
"baseUrl": "",
"types": [
"jasmine",
"node"
]
},
"files": [
"test.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}

5
src/typings.d.ts vendored Normal file
View file

@ -0,0 +1,5 @@
/* SystemJS module definition */
declare var module: NodeModule;
interface NodeModule {
id: string;
}

View file

@ -1,5 +0,0 @@
import "@angular/core";
import "@angular/platform-browser";
import "@angular/platform-browser-dynamic";
import "@angular/forms";
import "rxjs";