Merge branch 'develop' into migrate-to-angular-cli

This commit is contained in:
Manuel Friedli 2017-07-25 20:35:20 +02:00
commit 8c119a55e9
43 changed files with 1455 additions and 1094 deletions

1
.gitignore vendored
View file

@ -41,3 +41,4 @@ testem.log
# System Files # System Files
.DS_Store .DS_Store
Thumbs.db Thumbs.db
*~

View file

@ -9,7 +9,9 @@ build_job:
script: script:
- yarn install - yarn install
- yarn run build - yarn run build
- yarn run lint
- yarn run test - yarn run test
- yarn run e2e
tags: tags:
- javascript - javascript
except: except:
@ -25,7 +27,9 @@ build_job_production:
script: script:
- yarn install - yarn install
- yarn run build-prod - yarn run build-prod
- yarn run lint
- yarn run test - yarn run test
- yarn run e2e
tags: tags:
- javascript - javascript
only: only:

View file

@ -1,4 +1,14 @@
# Convertorizr # convertorizr - Convert whatever you want!
This is a short introduction to the awesome Convertorizr hosted at [https://conv.friedli.info/].
Deployment is automated with Gitlab CI. Usage is self-explanatory. What else do you need to know?
Contact the author at manuel-convertorizr|at|fritteli.ch.
Cheers!
# Technical stuff
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.0.0. This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.0.0.

View file

@ -1,4 +1,4 @@
import { ConvertorizrPage } from './app.po'; import {ConvertorizrPage} from './app.po';
describe('convertorizr App', () => { describe('convertorizr App', () => {
let page: ConvertorizrPage; let page: ConvertorizrPage;
@ -9,6 +9,6 @@ describe('convertorizr App', () => {
it('should display message saying app works', () => { it('should display message saying app works', () => {
page.navigateTo(); page.navigateTo();
expect(page.getParagraphText()).toEqual('app works!'); expect(page.getInputfieldContent(0)).toEqual('');
}); });
}); });

View file

@ -1,11 +1,25 @@
import { browser, element, by } from 'protractor'; import {browser, by, element} from 'protractor';
export class ConvertorizrPage { export class ConvertorizrPage {
navigateTo() { navigateTo() {
return browser.get('/'); return browser.get('/');
} }
getParagraphText() { public foo() {
return element(by.css('app-root h1')).getText(); return 'bar';
}
public getInputfieldContent(index: number): Promise<any> {
const css1 = by.css('app-root div.inputwrapper');
console.log(css1);
const el1 = element.all(css1)[index];
console.log(el1);
const css2 = by.css('.textwrapper textarea');
console.log(css2);
const el2 = el1.findElement(css2);
console.log(el2);
const t = el2.getText();
console.log(t);
return t;
} }
} }

View file

@ -7,38 +7,42 @@ module.exports = function (config) {
frameworks: ['jasmine', '@angular/cli'], frameworks: ['jasmine', '@angular/cli'],
plugins: [ plugins: [
require('karma-jasmine'), require('karma-jasmine'),
require('karma-chrome-launcher'), require('karma-phantomjs-launcher'),
require('karma-jasmine-html-reporter'), require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'), require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma') require('@angular/cli/plugins/karma')
], ],
client:{ client: {
captureConsole: true,
clearContext: false // leave Jasmine Spec Runner output visible in browser clearContext: false // leave Jasmine Spec Runner output visible in browser
}, },
files: [ files: [
{ pattern: './src/test.ts', watched: false } {
pattern: './src/test.ts',
watched: false
}
], ],
preprocessors: { preprocessors: {
'./src/test.ts': ['@angular/cli'] './src/test.ts': ['@angular/cli']
}, },
mime: { mime: {
'text/x-typescript': ['ts','tsx'] 'text/x-typescript': ['ts', 'tsx']
}, },
coverageIstanbulReporter: { coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ], reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true fixWebpackSourcePaths: true
}, },
angularCli: { angularCli: {
environment: 'dev' environment: 'dev'
}, },
reporters: config.angularCli && config.angularCli.codeCoverage reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'coverage-istanbul'] ? ['progress', 'coverage-istanbul']
: ['progress', 'kjhtml'], : ['progress', 'kjhtml'],
port: 9876, port: 9876,
colors: true, colors: true,
logLevel: config.LOG_INFO, logLevel: config.LOG_INFO,
autoWatch: true, autoWatch: true,
browsers: ['Chrome'], browsers: ['PhantomJS'],
singleRun: false singleRun: false
}); });
}; };

View file

@ -1,6 +1,6 @@
{ {
"name": "convertorizr", "name": "convertorizr",
"version": "1.0.1-dev", "version": "1.1.1-dev",
"description": "Decode or encode base64, punycode, HTML entities, URI components, ...", "description": "Decode or encode base64, punycode, HTML entities, URI components, ...",
"keywords": [ "keywords": [
"encode", "encode",
@ -15,7 +15,7 @@
}, },
"license": "MIT", "license": "MIT",
"homepage": "https://manuel.pages.gittr.ch/dencode.org", "homepage": "https://manuel.pages.gittr.ch/dencode.org",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://gittr.ch/manuel/dencode.org.git" "url": "https://gittr.ch/manuel/dencode.org.git"
}, },
@ -24,7 +24,8 @@
"start": "ng serve", "start": "ng serve",
"build": "ng build", "build": "ng build",
"build-prod": "ng build --env=prod", "build-prod": "ng build --env=prod",
"test": "ng test", "test": "ng test --single-run",
"test-continuous": "ng test",
"lint": "ng lint", "lint": "ng lint",
"e2e": "ng e2e" "e2e": "ng e2e"
}, },
@ -37,12 +38,13 @@
"@angular/http": "^4.0.0", "@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0", "@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0", "@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"core-js": "^2.4.1", "core-js": "^2.4.1",
"rxjs": "^5.1.0", "punycode": "^2.1.0",
"zone.js": "^0.8.4",
"quoted-printable": "^1.0.0", "quoted-printable": "^1.0.0",
"rxjs": "^5.1.0",
"utf8": "^2.1.0", "utf8": "^2.1.0",
"punycode": "^1.4.0" "zone.js": "^0.8.4"
}, },
"devDependencies": { "devDependencies": {
"@angular/cli": "^1.0.0", "@angular/cli": "^1.0.0",
@ -51,14 +53,16 @@
"@types/node": "^7.0.0", "@types/node": "^7.0.0",
"codelyzer": "^2.0.0", "codelyzer": "^2.0.0",
"jasmine-core": "^2.5.2", "jasmine-core": "^2.5.2",
"jasmine-spec-reporter": "^3.2.0", "jasmine-spec-reporter": "^4.0.0",
"karma": "^1.4.1", "karma": "^1.4.1",
"karma-chrome-launcher": "^2.0.0", "karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1", "karma-cli": "^1.0.1",
"karma-coverage-istanbul-reporter": "^1.0.0", "karma-coverage-istanbul-reporter": "^1.2.0",
"karma-jasmine": "^1.1.0", "karma-jasmine": "^1.1.0",
"karma-jasmine-html-reporter": "^0.2.2", "karma-jasmine-html-reporter": "^0.2.2",
"karma-phantomjs-launcher": "^1.0.4",
"protractor": "^5.1.0", "protractor": "^5.1.0",
"protractor-console": "^2.0.1",
"ts-node": "^3.0.0", "ts-node": "^3.0.0",
"tslint": "^5.0.0", "tslint": "^5.0.0",
"typescript": "^2.2.0" "typescript": "^2.2.0"

View file

@ -1,7 +1,7 @@
// Protractor configuration file, see link for more information // Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts // https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter'); const {SpecReporter} = require('jasmine-spec-reporter');
exports.config = { exports.config = {
allScriptsTimeout: 11000, allScriptsTimeout: 11000,
@ -25,6 +25,10 @@ exports.config = {
}); });
}, },
onPrepare() { onPrepare() {
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); jasmine.getEnv().addReporter(new SpecReporter({spec: {displayStacktrace: true}}));
} },
plugins: [{
package: 'protractor-console',
logLevels: ['debug', 'info', 'warning', 'severe']
}]
}; };

View 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 {
}

View file

@ -12,5 +12,6 @@
</select> </select>
</div> </div>
</div> </div>
<div class="errormessage" *ngIf="step.error">{{step.message}}</div> <div class="errormessage" *ngIf="step.error" [innerHTML]="step.message"></div>
</div> </div>
<!--<router-outlet></router-outlet>-->

View file

@ -12,53 +12,45 @@
position: relative; position: relative;
background: #fff; background: #fff;
border: 1px solid #aaa; border: 1px solid #aaa;
} &:focus {
border-color: #888;
.arrow_box:focus { }
border-color: #888; &:hover {
} border-color: #333;
}
.arrow_box:hover { &:after, &:before {
border-color: #333; top: 100%;
} left: 50%;
border: solid transparent;
.arrow_box:after, .arrow_box:before { content: " ";
top: 100%; height: 0;
left: 50%; width: 0;
border: solid transparent; position: absolute;
content: " "; pointer-events: none;
height: 0; }
width: 0; &:after {
position: absolute; border-color: rgba(255, 255, 255, 0);
pointer-events: none; border-top-color: #fff;
} border-width: 1em;
margin-left: -1em;
.arrow_box:after { }
border-color: rgba(255, 255, 255, 0); &:before {
border-top-color: #fff; border-color: rgba(170, 170, 170, 0);
border-width: 1em; border-top-color: #aaa;
margin-left: -1em; border-width: calc(1em + 1px);
} margin-left: calc(-1em - 1px);
}
.arrow_box:before { &:focus:before {
border-color: rgba(170, 170, 170, 0); border-color: rgba(136, 136, 136, 0);
border-top-color: #aaa; border-top-color: #888;
border-width: calc(1em + 1px); }
margin-left: calc(-1em - 1px); &:hover:before {
} border-color: rgba(51, 51, 51, 0);
border-top-color: #333;
.arrow_box:focus:before { }
border-color: rgba(136, 136, 136, 0); .selectwrapper > & {
border-top-color: #888; display: inline-block;
} }
.arrow_box:hover:before {
border-color: rgba(51, 51, 51, 0);
border-top-color: #333;
}
.selectwrapper > .arrow_box {
display: inline-block;
} }
.textinput { .textinput {
@ -71,20 +63,29 @@
padding: 0.5em; padding: 0.5em;
resize: vertical; resize: vertical;
width: 100%; width: 100%;
} &:focus {
border-color: #888;
.textinput:focus { }
border-color: #888; &:hover {
} border-color: #333;
}
.textinput:hover {
border-color: #333;
} }
.selectwrapper { .selectwrapper {
margin: 0 0 1em 0; margin: 0 0 1em 0;
padding: 0; padding: 0;
text-align: center; text-align: center;
&.error {
> .arrow_box {
border-color: red;
&:before {
border-top-color: red;
}
}
select {
color: red;
}
}
} }
.select { .select {
@ -100,18 +101,6 @@
/* font-family: "ABeeZee", sans-serif;*/ /* 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 { .errormessage {
color: red; color: red;
text-align: center; text-align: center;

View file

@ -1,32 +1,54 @@
import {async, TestBed} from "@angular/core/testing"; import {AppComponent} from './app.component';
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import {AppComponent} from "./app.component"; import {InputComponentManagerService} from './inputcomponentmanager.service';
import {Step} from './step';
describe('AppComponent', () => { describe('AppComponent', () => {
let sut: AppComponent;
let fixture: ComponentFixture<AppComponent>;
const firstStep: Step = new Step(0);
const inputComponentManagerServiceStub = {
getFirst: () => {
return firstStep;
}
};
beforeEach(async(() => { beforeEach(async(() => {
/*return */
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ declarations: [AppComponent],
AppComponent providers: [{
], provide: InputComponentManagerService, useValue: inputComponentManagerServiceStub
}).compileComponents(); }]
})
.compileComponents();
})); }));
it('should create the app', async(() => { beforeEach(() => {
const fixture = TestBed.createComponent(AppComponent); fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance; sut = fixture.componentInstance;
expect(app).toBeTruthy(); });
})); // 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 fixture = TestBed.createComponent(AppComponent);
// const app = fixture.debugElement.componentInstance; // 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!');
// }));
}); });

View file

@ -1,9 +1,9 @@
import {Component, OnInit} from "@angular/core"; import {Component, OnInit} from '@angular/core';
import {NativeLibraryWrapperService} from "./nativelibrarywrapper.service"; import {ConverterRegistryService} from './converterregistry.service';
import {InputComponentManagerService} from "./inputcomponentmanager.service"; import {InputComponentManagerService} from './inputcomponentmanager.service';
import {ConverterRegistryService} from "./converterregistry.service"; import {NativeLibraryWrapperService} from './nativelibrarywrapper.service';
import {Step} from "./step"; import {Step} from './step';
import {Converter} from "./converter/converter"; import {Converter} from './converter/converter';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
@ -15,7 +15,8 @@ export class AppComponent implements OnInit {
public steps: Step[] = []; public steps: Step[] = [];
public converters: Converter[] = []; public converters: Converter[] = [];
constructor(private converterRegistryService: ConverterRegistryService, private inputComponentManagerService: InputComponentManagerService) { constructor(private converterRegistryService: ConverterRegistryService,
private inputComponentManagerService: InputComponentManagerService) {
} }
convert(step: Step, $event: any): void { convert(step: Step, $event: any): void {
@ -24,15 +25,15 @@ export class AppComponent implements OnInit {
} }
update(step: Step): void { update(step: Step): void {
let converter: Converter = step.selectedConverter; const converter: Converter = step.selectedConverter;
if (converter !== undefined) { if (converter !== undefined) {
let content: string = step.content; const content: string = step.content;
let result: string; let result: string;
try { try {
result = converter.convert(content); result = converter.convert(content);
} catch (error) { } catch (error) {
if (typeof console === "object" && typeof console.log === "function") { if (typeof console === 'object' && typeof console.log === 'function') {
console.log(error); console.log(error);
} }
step.message = error.message; step.message = error.message;
@ -40,10 +41,10 @@ export class AppComponent implements OnInit {
result = null; result = null;
} }
if (result !== null) { if (result !== null) {
step.message = ""; step.message = '';
step.error = false; step.error = false;
if (result !== "") { if (result !== '') {
let nextComponent: Step = this.inputComponentManagerService.getNext(step); const nextComponent: Step = this.inputComponentManagerService.getNext(step);
nextComponent.content = result; nextComponent.content = result;
this.update(nextComponent); this.update(nextComponent);
} }

View file

@ -1,8 +1,10 @@
import {BrowserModule} from "@angular/platform-browser"; import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from "@angular/core"; import {NgModule} from '@angular/core';
import {FormsModule} from "@angular/forms"; 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({ @NgModule({
declarations: [ declarations: [
@ -10,7 +12,9 @@ import {AppComponent} from "./app.component";
], ],
imports: [ imports: [
BrowserModule, BrowserModule,
FormsModule FormsModule,
HttpModule,
AppRoutingModule
], ],
providers: [], providers: [],
bootstrap: [AppComponent] bootstrap: [AppComponent]

View file

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

View file

@ -1,19 +1,22 @@
import {Converter} from "./converter"; import {Converter} from './converter';
export class Base64Encoder implements Converter { export class Base64Encoder implements Converter {
getDisplayname(): string { getDisplayname(): string {
return "Encode Base 64"; return 'Encode Base 64';
} }
getId(): string { getId(): string {
return "base64encode"; return 'base64encode';
} }
convert(input: string): string { convert(input: string): string {
try { try {
return btoa(input); return btoa(input);
} catch (exception) { } 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?');
} }
} }
} }

View file

@ -1,18 +1,18 @@
import {Converter} from "./converter"; import {Converter} from './converter';
export class BinToDecConverter implements Converter { export class BinToDecConverter implements Converter {
getDisplayname(): string { getDisplayname(): string {
return "Convert binary to decimal"; return 'Convert binary to decimal';
} }
getId(): string { getId(): string {
return "bintodec"; return 'bintodec';
} }
convert(input: string): string { convert(input: string): string {
let n: number = parseInt(input, 2); const n: number = parseInt(input, 2);
if (isNaN(n)) { 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); return n.toString(10);
} }

View file

@ -1,18 +1,18 @@
import {Converter} from "./converter"; import {Converter} from './converter';
export class DecToBinConverter implements Converter { export class DecToBinConverter implements Converter {
getDisplayname(): string { getDisplayname(): string {
return "Convert decimal to binary"; return 'Convert decimal to binary';
} }
getId(): string { getId(): string {
return "dectobin"; return 'dectobin';
} }
convert(input: string): string { convert(input: string): string {
let n: number = parseInt(input, 10); const n: number = parseInt(input, 10);
if (isNaN(n)) { 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); return n.toString(2);
} }

View file

@ -1,18 +1,18 @@
import {Converter} from "./converter"; import {Converter} from './converter';
export class DecToHexConverter implements Converter { export class DecToHexConverter implements Converter {
getDisplayname(): string { getDisplayname(): string {
return "Convert decimal to hexadecimal"; return 'Convert decimal to hexadecimal';
} }
getId(): string { getId(): string {
return "dectohex"; return 'dectohex';
} }
convert(input: string): string { convert(input: string): string {
let n: number = parseInt(input, 10); const n: number = parseInt(input, 10);
if (isNaN(n)) { 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); return n.toString(16);
} }

View file

@ -1,18 +1,18 @@
import {Converter} from "./converter"; import {Converter} from './converter';
export class HexToDecConverter implements Converter { export class HexToDecConverter implements Converter {
getDisplayname(): string { getDisplayname(): string {
return "Convert hexadecimal to decimal"; return 'Convert hexadecimal to decimal';
} }
getId(): string { getId(): string {
return "hextodec"; return 'hextodec';
} }
convert(input: string): string { convert(input: string): string {
let n: number = parseInt(input, 16); const n: number = parseInt(input, 16);
if (isNaN(n)) { 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); return n.toString(10);
} }

View file

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

View file

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

View file

@ -1,5 +1,5 @@
import {Converter} from "./converter"; import {Converter} from './converter';
import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service"; import {NativeLibraryWrapperService} from '../nativelibrarywrapper.service';
export class PunycodeDecoder implements Converter { export class PunycodeDecoder implements Converter {
@ -7,11 +7,11 @@ export class PunycodeDecoder implements Converter {
} }
getDisplayname(): string { getDisplayname(): string {
return "Decode from punycode"; return 'Decode from punycode';
} }
getId(): string { getId(): string {
return "decodepunycode"; return 'decodepunycode';
} }
convert(input: string): string { convert(input: string): string {

View file

@ -1,5 +1,5 @@
import {Converter} from "./converter"; import {Converter} from './converter';
import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service"; import {NativeLibraryWrapperService} from '../nativelibrarywrapper.service';
export class PunycodeEncoder implements Converter { export class PunycodeEncoder implements Converter {
@ -7,11 +7,11 @@ export class PunycodeEncoder implements Converter {
} }
getDisplayname(): string { getDisplayname(): string {
return "Encode as punycode"; return 'Encode as punycode';
} }
getId(): string { getId(): string {
return "encodepunycode"; return 'encodepunycode';
} }
convert(input: string): string { convert(input: string): string {

View file

@ -1,5 +1,5 @@
import {Converter} from "./converter"; import {Converter} from './converter';
import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service"; import {NativeLibraryWrapperService} from '../nativelibrarywrapper.service';
export class QuotedPrintableDecoder implements Converter { export class QuotedPrintableDecoder implements Converter {
@ -7,18 +7,18 @@ export class QuotedPrintableDecoder implements Converter {
} }
getDisplayname(): string { getDisplayname(): string {
return "Decode quoted printable"; return 'Decode quoted printable';
} }
getId(): string { getId(): string {
return "decodequotedprintable"; return 'decodequotedprintable';
} }
convert(input: string): string { convert(input: string): string {
try { try {
return this.nativeLibraryWrapperService.quotedPrintable.decode(input); return this.nativeLibraryWrapperService.quotedPrintable.decode(input);
} catch (error) { } 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?');
} }
} }
} }

View file

@ -1,5 +1,5 @@
import {Converter} from "./converter"; import {Converter} from './converter';
import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service"; import {NativeLibraryWrapperService} from '../nativelibrarywrapper.service';
export class QuotedPrintableEncoder implements Converter { export class QuotedPrintableEncoder implements Converter {
@ -7,11 +7,11 @@ export class QuotedPrintableEncoder implements Converter {
} }
getDisplayname(): string { getDisplayname(): string {
return "Encode quoted printable"; return 'Encode quoted printable';
} }
getId(): string { getId(): string {
return "encodequotedprintable"; return 'encodequotedprintable';
} }
convert(input: string): string { convert(input: string): string {

View file

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

View file

@ -1,12 +1,12 @@
import {Converter} from "./converter"; import {Converter} from './converter';
export class URIComponentEncoder implements Converter { export class URIComponentEncoder implements Converter {
getDisplayname(): string { getDisplayname(): string {
return "Encode URI component"; return 'Encode URI component';
} }
getId(): string { getId(): string {
return "uricomponentencode"; return 'uricomponentencode';
} }
convert(input: string): string { convert(input: string): string {

View file

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

View file

@ -1,12 +1,12 @@
import {Converter} from "./converter"; import {Converter} from './converter';
export class URIEncoder implements Converter { export class URIEncoder implements Converter {
getDisplayname(): string { getDisplayname(): string {
return "Encode URI"; return 'Encode URI';
} }
getId(): string { getId(): string {
return "uriencode"; return 'uriencode';
} }
convert(input: string): string { convert(input: string): string {

View file

@ -1,5 +1,5 @@
import {Converter} from "./converter"; import {Converter} from './converter';
import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service"; import {NativeLibraryWrapperService} from '../nativelibrarywrapper.service';
export class UTF8Decoder implements Converter { export class UTF8Decoder implements Converter {
@ -7,18 +7,18 @@ export class UTF8Decoder implements Converter {
} }
getDisplayname(): string { getDisplayname(): string {
return "Decode UTF-8"; return 'Decode UTF-8';
} }
getId(): string { getId(): string {
return "decodeutf8"; return 'decodeutf8';
} }
convert(input: string): string { convert(input: string): string {
try { try {
return this.nativeLibraryWrapperService.utf8.decode(input); return this.nativeLibraryWrapperService.utf8.decode(input);
} catch (error) { } 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?');
} }
} }
} }

View file

@ -1,5 +1,5 @@
import {Converter} from "./converter"; import {Converter} from './converter';
import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service"; import {NativeLibraryWrapperService} from '../nativelibrarywrapper.service';
export class UTF8Encoder implements Converter { export class UTF8Encoder implements Converter {
@ -7,18 +7,18 @@ export class UTF8Encoder implements Converter {
} }
getDisplayname(): string { getDisplayname(): string {
return "Encode UTF-8"; return 'Encode UTF-8';
} }
getId(): string { getId(): string {
return "encodeutf8"; return 'encodeutf8';
} }
convert(input: string): string { convert(input: string): string {
try { try {
return this.nativeLibraryWrapperService.utf8.encode(input); return this.nativeLibraryWrapperService.utf8.encode(input);
} catch (error) { } 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?');
} }
} }
} }

View file

@ -1,24 +1,24 @@
import {Injectable} from "@angular/core"; import {Injectable} from '@angular/core';
import {Converter} from "./converter/converter"; import {Converter} from './converter/converter';
import {Base64Encoder} from "./converter/base64encoder"; import {Base64Encoder} from './converter/base64encoder';
import {Base64Decoder} from "./converter/base64decoder"; import {Base64Decoder} from './converter/base64decoder';
import {URIEncoder} from "./converter/uriencoder"; import {URIEncoder} from './converter/uriencoder';
import {URIDecoder} from "./converter/uridecoder"; import {URIDecoder} from './converter/uridecoder';
import {URIComponentEncoder} from "./converter/uricomponentencoder"; import {URIComponentEncoder} from './converter/uricomponentencoder';
import {URIComponentDecoder} from "./converter/uricomponentdecoder"; import {URIComponentDecoder} from './converter/uricomponentdecoder';
import {HTMLEntitiesEncoder} from "./converter/htmlentitiesencoder"; import {HTMLEntitiesEncoder} from './converter/htmlentitiesencoder';
import {HTMLEntitiesDecoder} from "./converter/htmlentitiesdecoder"; import {HTMLEntitiesDecoder} from './converter/htmlentitiesdecoder';
import {DecToHexConverter} from "./converter/dectohexconverter"; import {DecToHexConverter} from './converter/dectohexconverter';
import {HexToDecConverter} from "./converter/hextodecconverter"; import {HexToDecConverter} from './converter/hextodecconverter';
import {DecToBinConverter} from "./converter/dectobinconverter"; import {DecToBinConverter} from './converter/dectobinconverter';
import {BinToDecConverter} from "./converter/bintodecconverter"; import {BinToDecConverter} from './converter/bintodecconverter';
import {QuotedPrintableDecoder} from "./converter/quotedprintabledecoder"; import {QuotedPrintableDecoder} from './converter/quotedprintabledecoder';
import {QuotedPrintableEncoder} from "./converter/quotedprintableencoder"; import {QuotedPrintableEncoder} from './converter/quotedprintableencoder';
import {NativeLibraryWrapperService} from "./nativelibrarywrapper.service"; import {NativeLibraryWrapperService} from './nativelibrarywrapper.service';
import {PunycodeEncoder} from "./converter/punycodeencoder"; import {PunycodeEncoder} from './converter/punycodeencoder';
import {PunycodeDecoder} from "./converter/punycodedecoder"; import {PunycodeDecoder} from './converter/punycodedecoder';
import {UTF8Encoder} from "./converter/utf8encoder"; import {UTF8Encoder} from './converter/utf8encoder';
import {UTF8Decoder} from "./converter/utf8decoder"; import {UTF8Decoder} from './converter/utf8decoder';
@Injectable() @Injectable()
export class ConverterRegistryService { export class ConverterRegistryService {
@ -34,7 +34,7 @@ export class ConverterRegistryService {
public getConverter(id: string): Converter { public getConverter(id: string): Converter {
for (let i = 0; i < this.converters.length; i++) { 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]; return this.converters[i];
} }
} }
@ -64,8 +64,8 @@ export class ConverterRegistryService {
private registerConverter(converter: Converter): void { private registerConverter(converter: Converter): void {
this.converters.forEach((c: Converter) => { this.converters.forEach((c: Converter) => {
if (c.getId() == converter.getId()) { if (c.getId() === converter.getId()) {
throw new Error("Converter-ID " + converter.getId() + " is already registered!"); throw new Error('Converter-ID ' + converter.getId() + ' is already registered!');
} }
}); });
this.converters.push(converter); this.converters.push(converter);

View file

@ -1,5 +1,5 @@
import {Injectable} from "@angular/core"; import {Injectable} from '@angular/core';
import {Step} from "./step"; import {Step} from './step';
@Injectable() @Injectable()
export class InputComponentManagerService { export class InputComponentManagerService {
@ -17,15 +17,15 @@ export class InputComponentManagerService {
} }
public getNext(component: Step): Step { public getNext(component: Step): Step {
let index: number = component.index; const index: number = component.index;
if (index == this.components.length - 1) { if (index === this.components.length - 1) {
this.addComponent(); this.addComponent();
} }
return this.components[index + 1]; return this.components[index + 1];
} }
public getFirst(): Step { public getFirst(): Step {
if (this.components.length == 0) { if (this.components.length === 0) {
this.addComponent(); this.addComponent();
} }
return this.components[0]; return this.components[0];

View file

@ -1,10 +1,10 @@
import {Injectable} from "@angular/core"; import {Injectable} from '@angular/core';
import {Punycode} from "./punycode"; import {Punycode} from './punycode';
import {Utf8} from "./utf8"; import {Utf8} from './utf8';
import {QuotedPrintable} from "./quotedprintable"; import {QuotedPrintable} from './quotedprintable';
import * as QuotedPrintableNative from "quoted-printable"; import * as NativeUtf8 from 'utf8';
import * as Utf8Native from "utf8"; import * as NativeQuotedPrintable from 'quoted-printable';
import * as PunycodeNative from "punycode"; import * as NativePunycode from 'punycode';
@Injectable() @Injectable()
export class NativeLibraryWrapperService { export class NativeLibraryWrapperService {
@ -13,8 +13,8 @@ export class NativeLibraryWrapperService {
public punycode: Punycode; public punycode: Punycode;
constructor() { constructor() {
this.utf8 = Utf8Native; this.utf8 = NativeUtf8;
this.quotedPrintable = QuotedPrintableNative; this.quotedPrintable = NativeQuotedPrintable;
this.punycode = PunycodeNative; this.punycode = NativePunycode;
} }
} }

View file

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

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View file

@ -2,9 +2,10 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Convertorizr</title>
<base href="/"> <base href="/">
<!-- sha256sum: b67da665e68244f0009b1217a9c126c1377de6ec20b934d1d90b001e16571e6b -->
<script>document.getElementsByTagName('base')[0].setAttribute('href', window.location.pathname);</script>
<title>Convertorizr - Convert whatever you want!</title>
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico"> <link rel="icon" type="image/x-icon" href="favicon.ico">
</head> </head>

View file

@ -1,8 +1,8 @@
import { enableProdMode } from '@angular/core'; import {enableProdMode} from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module'; import {AppModule} from './app/app.module';
import { environment } from './environments/environment'; import {environment} from './environments/environment';
if (environment.production) { if (environment.production) {
enableProdMode(); enableProdMode();

View file

@ -13,48 +13,36 @@
* *
* Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
*/ */
/*************************************************************************************************** /***************************************************************************************************
* BROWSER POLYFILLS * BROWSER POLYFILLS
*/ */
/** IE9, IE10 and IE11 requires all of the following polyfills. **/ /** IE9, IE10 and IE11 requires all of the following polyfills. **/
// import 'core-js/es6/symbol'; import 'core-js/es6/symbol';
// import 'core-js/es6/object'; import 'core-js/es6/object';
// import 'core-js/es6/function'; import 'core-js/es6/function';
// import 'core-js/es6/parse-int'; import 'core-js/es6/parse-int';
// import 'core-js/es6/parse-float'; import 'core-js/es6/parse-float';
// import 'core-js/es6/number'; import 'core-js/es6/number';
// import 'core-js/es6/math'; import 'core-js/es6/math';
// import 'core-js/es6/string'; import 'core-js/es6/string';
// import 'core-js/es6/date'; import 'core-js/es6/date';
// import 'core-js/es6/array'; import 'core-js/es6/array';
// import 'core-js/es6/regexp'; import 'core-js/es6/regexp';
// import 'core-js/es6/map'; import 'core-js/es6/map';
// import 'core-js/es6/set'; import 'core-js/es6/set';
/** IE10 and IE11 requires the following for NgClass support on SVG elements */ /** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js'; // Run `npm install --save classlist.js`. // import 'classlist.js'; // Run `npm install --save classlist.js`.
/** IE10 and IE11 requires the following to support `@angular/animation`. */ /** IE10 and IE11 requires the following to support `@angular/animation`. */
// import 'web-animations-js'; // Run `npm install --save web-animations-js`. // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/** Evergreen browsers require these. **/ /** Evergreen browsers require these. **/
import 'core-js/es6/reflect'; import 'core-js/es6/reflect';
import 'core-js/es7/reflect'; import 'core-js/es7/reflect';
/** ALL Firefox browsers require the following to support `@angular/animation`. **/ /** ALL Firefox browsers require the following to support `@angular/animation`. **/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`. // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/*************************************************************************************************** /***************************************************************************************************
* Zone JS is required by Angular itself. * Zone JS is required by Angular itself.
*/ */
import 'zone.js/dist/zone'; // Included with Angular CLI. import 'zone.js/dist/zone'; // Included with Angular CLI.
/*************************************************************************************************** /***************************************************************************************************

View file

@ -6,18 +6,16 @@ import 'zone.js/dist/sync-test';
import 'zone.js/dist/jasmine-patch'; import 'zone.js/dist/jasmine-patch';
import 'zone.js/dist/async-test'; import 'zone.js/dist/async-test';
import 'zone.js/dist/fake-async-test'; import 'zone.js/dist/fake-async-test';
import { getTestBed } from '@angular/core/testing'; import {getTestBed} from '@angular/core/testing';
import { import {BrowserDynamicTestingModule, platformBrowserDynamicTesting} from '@angular/platform-browser-dynamic/testing';
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
declare var __karma__: any; declare const __karma__: any;
declare var require: any; declare const require: any;
// Prevent Karma from running prematurely. // Prevent Karma from running prematurely.
__karma__.loaded = function () {}; __karma__.loaded = function () {
};
// First, initialize the Angular testing environment. // First, initialize the Angular testing environment.
getTestBed().initTestEnvironment( getTestBed().initTestEnvironment(

654
yarn.lock

File diff suppressed because it is too large Load diff