Merge branch 'release-1.0.1' into 'master'

Release 1.1.0

See merge request !18
This commit is contained in:
Manuel Friedli 2017-04-15 21:11:04 +02:00
commit 817086e96e
70 changed files with 7319 additions and 1574 deletions

57
.angular-cli.json Normal file
View file

@ -0,0 +1,57 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "convertorizr"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.scss"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json"
},
{
"project": "src/tsconfig.spec.json"
},
{
"project": "e2e/tsconfig.e2e.json"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "scss",
"component": {}
}
}

13
.editorconfig Normal file
View file

@ -0,0 +1,13 @@
# Editor configuration, see http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false

52
.gitignore vendored
View file

@ -1,10 +1,44 @@
*~ # See http://help.github.com/ignore-files/ for more about ignoring files.
.idea/
*.iml # compiled output
atlassian-ide-plugin.xml /dist
node_modules/ /tmp
typings/ /out-tsc
src/**/*.js /src/**/*.js
src/**/*.js.map
# dependencies
/node_modules
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log npm-debug.log
dist/ testem.log
/typings
# e2e
/e2e/*.js
/e2e/*.map
# System Files
.DS_Store
Thumbs.db
*~

View file

@ -7,13 +7,33 @@ stages:
build_job: build_job:
stage: build stage: build
script: script:
- npm install - yarn install
- npm run build - yarn run build
- npm run test - yarn run lint
# - yarn run test
# - yarn run e2e
tags: tags:
- javascript - javascript
except: except:
- tags - tags
- master
artifacts:
paths:
- dist
expire_in: 30 min
build_job_production:
stage: build
script:
- yarn install
- yarn run build-prod
- yarn run lint
# - yarn run test
# - yarn run e2e
tags:
- javascript
only:
- master
artifacts: artifacts:
paths: paths:
- dist - dist
@ -55,3 +75,4 @@ cleanup_job:
script: script:
- rm -rf node_modules - rm -rf node_modules
when: always when: always
allow_failure: true

View file

@ -1,9 +1,38 @@
# conv.friedli.info - Convert whatever you want! # convertorizr - Convert whatever you want!
This is a short introduction to the awesome converter hosted at [https://conv.friedli.info/]. 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? Deployment is automated with Gitlab CI. Usage is self-explanatory. What else do you need to know?
Contact the author at manuel-conv.friedli.info|at|fritteli.ch. Contact the author at manuel-convertorizr|at|fritteli.ch.
Cheers! Cheers!
# Technical stuff
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.0.0.
## Development server
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
## Code scaffolding
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive/pipe/service/class/module`.
## Build
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.
## Running unit tests
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Running end-to-end tests
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
Before running the tests make sure you are serving the app via `ng serve`.
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).

View file

@ -1,7 +0,0 @@
var path = require('path');
var _root = path.resolve(__dirname, '..');
function root(args) {
args = Array.prototype.slice.call(arguments, 0);
return path.join.apply(path, [_root].concat(args));
}
exports.root = root;

View file

@ -1,21 +0,0 @@
Error.stackTraceLimit = Infinity;
require('core-js/es6');
require('core-js/es7/reflect');
require('zone.js/dist/zone');
require('zone.js/dist/long-stack-trace-zone');
require('zone.js/dist/proxy');
require('zone.js/dist/sync-test');
require('zone.js/dist/jasmine-patch');
require('zone.js/dist/async-test');
require('zone.js/dist/fake-async-test');
var appContext = require.context('../src', true, /\.spec\.ts/);
appContext.keys().forEach(appContext);
var testing = require('@angular/core/testing');
var browser = require('@angular/platform-browser-dynamic/testing');
testing.TestBed.initTestEnvironment(browser.BrowserDynamicTestingModule, browser.platformBrowserDynamicTesting());

View file

@ -1,44 +0,0 @@
var webpackConfig = require('./webpack.test');
module.exports = function (config) {
var _config = {
basePath: '',
frameworks: ['jasmine'],
files: [
{
pattern: './config/karma-test-shim.js',
watched: false
}
],
preprocessors: {
'./config/karma-test-shim.js': ['webpack', 'sourcemap']
},
webpack: webpackConfig,
webpackMiddleware: {
stats: 'errors-only'
},
webpackServer: {
noInfo: true
},
reporters: ['kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ['PhantomJS'],
singleRun: true,
phantomjsLauncher: {
// Have phantomjs exit if a ResourceError is encountered (useful if karma exits without killing phantom)
exitOnResourceError: true
}
};
config.set(_config);
};

View file

@ -1,76 +0,0 @@
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var helpers = require('./helpers');
module.exports = {
entry: {
'polyfills': './src/polyfills.ts',
'vendor': './src/vendor.ts',
'app': './src/main.ts'
},
resolve: {
extensions: ['.ts', '.js']
},
module: {
rules: [
{
test: /\.ts$/,
loaders: [
{
loader: 'awesome-typescript-loader',
options: {
configFileName: helpers.root('src', 'tsconfig.json')
}
},
'angular2-template-loader'
]
},
{
test: /\.html$/,
use: 'html-loader'
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
use: 'file-loader?name=assets/[name].[hash].[ext]'
},
{
test: /\.css$/,
exclude: helpers.root('src', 'app'),
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader?sourceMap'
})
},
{
test: /\.css$/,
include: helpers.root('src', 'app'),
use: 'raw-loader'
}
]
},
plugins: [
// Workaround for angular/angular#11580
new webpack.ContextReplacementPlugin(
// The (\\|\/) piece accounts for path separators in *nix and Windows
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
helpers.root('./src'), // location of your src
{} // a map of your routes
),
new webpack.optimize.CommonsChunkPlugin({
name: ['app', 'vendor', 'polyfills']
}),
new HtmlWebpackPlugin({
template: 'src/index.html'
}),
new webpack.optimize.UglifyJsPlugin({
comments: false
})
]
};

View file

@ -1,24 +0,0 @@
var webpackMerge = require('webpack-merge');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var commonConfig = require('./webpack.common.js');
var helpers = require('./helpers');
module.exports = webpackMerge(commonConfig, {
devtool: 'cheap-module-eval-source-map',
output: {
path: helpers.root('dist'),
publicPath: 'http://localhost:8080/',
filename: '[name].js',
chunkFilename: '[id].chunk.js'
},
plugins: [
new ExtractTextPlugin('[name].css')
],
devServer: {
historyApiFallback: true,
stats: 'minimal'
}
});

View file

@ -1,38 +0,0 @@
var webpack = require('webpack');
var webpackMerge = require('webpack-merge');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var commonConfig = require('./webpack.common.js');
var helpers = require('./helpers');
const ENV = process.env.NODE_ENV = process.env.ENV = 'production';
module.exports = webpackMerge(commonConfig, {
devtool: 'source-map',
output: {
path: helpers.root('dist'),
publicPath: '',
filename: '[name].[hash].js',
chunkFilename: '[id].[hash].chunk.js'
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.optimize.UglifyJsPlugin({ // https://github.com/angular/angular/issues/10618
mangle: {
keep_fnames: true
}
}),
new ExtractTextPlugin('[name].[hash].css'),
new webpack.DefinePlugin({
'process.env': {
'ENV': JSON.stringify(ENV)
}
}),
new webpack.LoaderOptionsPlugin({
htmlLoader: {
minimize: false // workaround for ng2
}
})
]
});

View file

@ -1,52 +0,0 @@
var webpack = require('webpack');
var helpers = require('./helpers');
module.exports = {
devtool: 'inline-source-map',
resolve: {
extensions: ['.ts', '.js']
},
module: {
rules: [
{
test: /\.ts$/,
loaders: [
{
loader: 'awesome-typescript-loader',
options: {configFileName: helpers.root('src', 'tsconfig.json')}
}, 'angular2-template-loader'
]
},
{
test: /\.html$/,
loader: 'html-loader'
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
loader: 'null-loader'
},
{
test: /\.css$/,
exclude: helpers.root('src', 'app'),
loader: 'null-loader'
},
{
test: /\.css$/,
include: helpers.root('src', 'app'),
loader: 'raw-loader'
}
]
},
plugins: [
new webpack.ContextReplacementPlugin(
// The (\\|\/) piece accounts for path separators in *nix and Windows
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
helpers.root('./src'), // location of your src
{} // a map of your routes
)
]
};

14
e2e/app.e2e-spec.ts Normal file
View file

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

25
e2e/app.po.ts Normal file
View file

@ -0,0 +1,25 @@
import {browser, by, element} from 'protractor';
export class ConvertorizrPage {
navigateTo() {
return browser.get('/');
}
public foo() {
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;
}
}

12
e2e/tsconfig.e2e.json Normal file
View file

@ -0,0 +1,12 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/e2e",
"module": "commonjs",
"target": "es5",
"types":[
"jasmine",
"node"
]
}
}

View file

@ -1 +1,48 @@
module.exports = require('./config/karma.conf.js'); // Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-phantomjs-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma')
],
client: {
captureConsole: true,
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
files: [
{
pattern: './src/test.ts',
watched: false
}
],
preprocessors: {
'./src/test.ts': ['@angular/cli']
},
mime: {
'text/x-typescript': ['ts', 'tsx']
},
coverageIstanbulReporter: {
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'coverage-istanbul']
: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['PhantomJS'],
singleRun: false
});
};

View file

@ -1,7 +1,7 @@
{ {
"name": "conv.friedli.info", "name": "convertorizr",
"version": "1.0.0", "version": "1.1.0",
"description": "Decode or encode base64, punycode, HTML entities, URI components ...", "description": "Decode or encode base64, punycode, HTML entities, URI components, ...",
"keywords": [ "keywords": [
"encode", "encode",
"decode", "decode",
@ -19,53 +19,52 @@
"type": "git", "type": "git",
"url": "https://gittr.ch/manuel/dencode.org.git" "url": "https://gittr.ch/manuel/dencode.org.git"
}, },
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build-prod": "ng build --env=prod",
"test": "ng test --single-run",
"test-continuous": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": { "dependencies": {
"@angular/common": "^2.4.0", "@angular/common": "^4.0.0",
"@angular/compiler": "^2.4.0", "@angular/compiler": "^4.0.0",
"@angular/core": "^2.4.0", "@angular/core": "^4.0.0",
"@angular/forms": "^2.4.0", "@angular/forms": "^4.0.0",
"@angular/platform-browser": "^2.4.0", "@angular/http": "^4.0.0",
"@angular/platform-browser-dynamic": "^2.4.0", "@angular/platform-browser": "^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.0.1", "punycode": "^2.1.0",
"zone.js": "^0.7.4",
"bootstrap": "^3.3.0",
"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": {
"@types/jasmine": "2.5.36", "@angular/cli": "^1.0.0",
"@types/node": "^6.0.45", "@angular/compiler-cli": "^4.0.0",
"angular2-template-loader": "^0.6.0", "@types/jasmine": "^2.5.38",
"awesome-typescript-loader": "^3.0.4", "@types/node": "^7.0.0",
"css-loader": "^0.26.1", "codelyzer": "^2.0.0",
"extract-text-webpack-plugin": "^2.0.0", "jasmine-core": "^2.5.2",
"file-loader": "^0.9.0", "jasmine-spec-reporter": "^4.0.0",
"html-loader": "^0.4.3", "karma": "^1.4.1",
"html-webpack-plugin": "^2.16.1",
"jasmine-core": "^2.4.1",
"karma": "^1.2.0",
"karma-chrome-launcher": "^2.0.0", "karma-chrome-launcher": "^2.0.0",
"karma-firefox-launcher": "^1.0.1", "karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2", "karma-coverage-istanbul-reporter": "^1.2.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", "karma-phantomjs-launcher": "^1.0.4",
"karma-sourcemap-loader": "^0.3.7", "protractor": "^5.1.0",
"karma-webpack": "^2.0.1", "protractor-console": "^2.0.1",
"null-loader": "^0.1.1", "ts-node": "^3.0.0",
"phantomjs-prebuilt": "^2.1.14", "tslint": "^4.0.0",
"raw-loader": "^0.5.1", "typescript": "~2.2.0"
"rimraf": "^2.5.2",
"style-loader": "^0.13.1",
"typescript": "^2.0.10",
"webpack": "^2.2.1",
"webpack-dev-server": "^2.4.1",
"webpack-merge": "^3.0.0"
},
"scripts": {
"start": "webpack-dev-server --inline --progress --port 8080",
"test": "karma start",
"build": "rimraf dist && webpack --config config/webpack.prod.js --progress --profile --bail"
} }
} }

35
protractor.conf.js Normal file
View file

@ -0,0 +1,35 @@
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const {SpecReporter} = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function () {
}
},
beforeLaunch: function () {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
},
onPrepare() {
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

@ -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,17 @@
<div *ngFor="let step of steps" class="inputwrapper"> <div *ngFor="let step of steps" class="inputwrapper">
<div class="textwrapper arrow_box"> <div class="textwrapper arrow_box">
<textarea class="textinput" (keyup)="update(step)" placeholder="Please enter your input ..." <textarea class="textinput" (keyup)="update(step)" placeholder="Please enter your input ..."
[(ngModel)]="step.content">{{step.content}}</textarea> [(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>
<div [ngClass]="{selectwrapper: true, error: step.error}"> </div>
<div class="arrow_box"> <div class="errormessage" *ngIf="step.error" [innerHTML]="step.message"></div>
<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>
<!--<router-outlet></router-outlet>-->

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

@ -0,0 +1,107 @@
.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;
&: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 {
background-color: #fff;
border: none;
color: #000;
font-family: "Free Monospaced", monospace;
height: 10em;
margin: 0;
padding: 0.5em;
resize: vertical;
width: 100%;
&: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 {
background-color: #fff;
border: none;
color: #000;
font-family: "ABeeZee", sans-serif;
margin: 0;
padding: 0.5em;
}
.option {
/* font-family: "ABeeZee", sans-serif;*/
}
.errormessage {
color: red;
text-align: center;
}

View file

@ -1,16 +1,54 @@
import {TestBed} from "@angular/core/testing"; import {AppComponent} from './app.component';
import {AppComponent} from "./app.component"; import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import {FormsModule} from "@angular/forms"; 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],
providers: [{
provide: InputComponentManagerService, useValue: inputComponentManagerServiceStub
}]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AppComponent);
sut = fixture.componentInstance;
});
// beforeEach(async(() => {
// TestBed.configureTestingModule({
// imports: [
// RouterTestingModule
// ],
// declarations: [
// AppComponent
// ],
// }).compileComponents();
// }));
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).toBeTruthy();
// }));
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');
});
}); });

View file

@ -1,61 +1,60 @@
import {Component, OnInit} from "@angular/core"; import {Component, OnInit} from '@angular/core';
import {ConverterRegistryService} from "./converterregistry.service"; import {ConverterRegistryService} from './converterregistry.service';
import {InputComponentManagerService} from "./inputcomponentmanager.service"; import {InputComponentManagerService} from './inputcomponentmanager.service';
import {Converter} from "./converter/converter"; import {NativeLibraryWrapperService} from './nativelibrarywrapper.service';
import {NativeLibraryWrapperService} from "./nativelibrarywrapper.service"; import {Step} from './step';
import {Step} from "./step"; import {Converter} from './converter/converter';
import "../assets/css/style.css";
@Component({ @Component({
selector: "den-app", selector: 'app-root',
templateUrl: "./app.component.html", templateUrl: './app.component.html',
styleUrls: ["./app.component.css"], styleUrls: ['./app.component.scss'],
providers: [ConverterRegistryService, InputComponentManagerService, NativeLibraryWrapperService] providers: [ConverterRegistryService, InputComponentManagerService, NativeLibraryWrapperService]
}) })
export class AppComponent extends OnInit { 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,
super(); private inputComponentManagerService: InputComponentManagerService) {
} }
convert(step:Step, $event:any):void { convert(step: Step, $event: any): void {
step.selectedConverter = this.converterRegistryService.getConverter($event.target.selectedOptions[0].id); step.selectedConverter = this.converterRegistryService.getConverter($event.target.selectedOptions[0].id);
this.update(step); this.update(step);
} }
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.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);
}
}
} }
step.message = error.message;
step.error = true;
result = null;
}
if (result !== null) {
step.message = '';
step.error = false;
if (result !== '') {
const nextComponent: Step = this.inputComponentManagerService.getNext(step);
nextComponent.content = result;
this.update(nextComponent);
}
}
} }
}
ngOnInit():void { ngOnInit(): void {
this.converters = this.converterRegistryService.getAllConverters(); this.converters = this.converterRegistryService.getAllConverters();
this.steps = this.inputComponentManagerService.getAllComponents(); this.steps = this.inputComponentManagerService.getAllComponents();
this.inputComponentManagerService.getFirst(); this.inputComponentManagerService.getFirst();
} }
} }

View file

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

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,19 +1,19 @@
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,5 +1,5 @@
export interface Converter { export interface Converter {
getDisplayname():string; getDisplayname(): string;
getId():string; getId(): string;
convert(input:string):string; convert(input: string): string;
} }

View file

@ -1,19 +1,19 @@
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,19 +1,19 @@
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,19 +1,19 @@
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,20 +1,20 @@
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 {
constructor(private nativeLibraryWrapperService: NativeLibraryWrapperService) { constructor(private nativeLibraryWrapperService: NativeLibraryWrapperService) {
} }
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 {
return this.nativeLibraryWrapperService.punycode.decode(input); return this.nativeLibraryWrapperService.punycode.decode(input);
} }
} }

View file

@ -1,20 +1,20 @@
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 {
constructor(private nativeLibraryWrapperService: NativeLibraryWrapperService) { constructor(private nativeLibraryWrapperService: NativeLibraryWrapperService) {
} }
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 {
return this.nativeLibraryWrapperService.punycode.encode(input); return this.nativeLibraryWrapperService.punycode.encode(input);
} }
} }

View file

@ -1,24 +1,24 @@
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 {
constructor(private nativeLibraryWrapperService:NativeLibraryWrapperService) { constructor(private nativeLibraryWrapperService: NativeLibraryWrapperService) {
} }
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,20 +1,20 @@
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 {
constructor(private nativeLibraryWrapperService:NativeLibraryWrapperService) { constructor(private nativeLibraryWrapperService: NativeLibraryWrapperService) {
} }
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 {
return this.nativeLibraryWrapperService.quotedPrintable.encode(input); return this.nativeLibraryWrapperService.quotedPrintable.encode(input);
} }
} }

View file

@ -1,15 +1,15 @@
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 {
return decodeURIComponent(input); return decodeURIComponent(input);
} }
} }

View file

@ -1,17 +1,17 @@
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 {
return encodeURIComponent(input).replace(/[!'()*]/g, function (c) { return encodeURIComponent(input).replace(/[!'()*]/g, function (c) {
return '%' + c.charCodeAt(0).toString(16); return '%' + c.charCodeAt(0).toString(16);
}); });
} }
} }

View file

@ -1,15 +1,15 @@
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 {
return decodeURI(input); return decodeURI(input);
} }
} }

View file

@ -1,15 +1,15 @@
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 {
return encodeURI(input).replace(/%5B/g, '[').replace(/%5D/g, ']'); return encodeURI(input).replace(/%5B/g, '[').replace(/%5D/g, ']');
} }
} }

View file

@ -1,24 +1,24 @@
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 {
constructor(private nativeLibraryWrapperService:NativeLibraryWrapperService) { constructor(private nativeLibraryWrapperService: NativeLibraryWrapperService) {
} }
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,24 +1,24 @@
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 {
constructor(private nativeLibraryWrapperService:NativeLibraryWrapperService) { constructor(private nativeLibraryWrapperService: NativeLibraryWrapperService) {
} }
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,73 +1,73 @@
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 {
private converters:Converter[] = []; private converters: Converter[] = [];
constructor(private wrapper:NativeLibraryWrapperService) { constructor(private wrapper: NativeLibraryWrapperService) {
this.init(); this.init();
} }
public getAllConverters():Converter[] { public getAllConverters(): Converter[] {
return this.converters; return this.converters;
} }
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];
} }
}
return undefined;
} }
return undefined;
}
private init():void { private init(): void {
this.registerConverter(new Base64Encoder()); this.registerConverter(new Base64Encoder());
this.registerConverter(new Base64Decoder()); this.registerConverter(new Base64Decoder());
this.registerConverter(new URIEncoder()); this.registerConverter(new URIEncoder());
this.registerConverter(new URIDecoder()); this.registerConverter(new URIDecoder());
this.registerConverter(new URIComponentEncoder()); this.registerConverter(new URIComponentEncoder());
this.registerConverter(new URIComponentDecoder()); this.registerConverter(new URIComponentDecoder());
this.registerConverter(new HTMLEntitiesEncoder()); this.registerConverter(new HTMLEntitiesEncoder());
this.registerConverter(new HTMLEntitiesDecoder()); this.registerConverter(new HTMLEntitiesDecoder());
this.registerConverter(new QuotedPrintableEncoder(this.wrapper)); this.registerConverter(new QuotedPrintableEncoder(this.wrapper));
this.registerConverter(new QuotedPrintableDecoder(this.wrapper)); this.registerConverter(new QuotedPrintableDecoder(this.wrapper));
this.registerConverter(new DecToHexConverter()); this.registerConverter(new DecToHexConverter());
this.registerConverter(new HexToDecConverter()); this.registerConverter(new HexToDecConverter());
this.registerConverter(new DecToBinConverter()); this.registerConverter(new DecToBinConverter());
this.registerConverter(new BinToDecConverter()); this.registerConverter(new BinToDecConverter());
this.registerConverter(new PunycodeEncoder(this.wrapper)); this.registerConverter(new PunycodeEncoder(this.wrapper));
this.registerConverter(new PunycodeDecoder(this.wrapper)); this.registerConverter(new PunycodeDecoder(this.wrapper));
this.registerConverter(new UTF8Encoder(this.wrapper)); this.registerConverter(new UTF8Encoder(this.wrapper));
this.registerConverter(new UTF8Decoder(this.wrapper)); this.registerConverter(new UTF8Decoder(this.wrapper));
} }
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,37 +1,37 @@
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 {
private components:Step[] = []; private components: Step[] = [];
public constructor() { public constructor() {
} }
public register(component:Step):void { public register(component: Step): void {
this.components.push(component); this.components.push(component);
} }
public getAllComponents():Step[] { public getAllComponents(): Step[] {
return this.components; return this.components;
} }
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];
}
private addComponent():void { private addComponent(): void {
this.register(new Step(this.components.length)); this.register(new Step(this.components.length));
} }
} }

View file

@ -1,17 +1,20 @@
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 NativeUtf8 from 'utf8';
import * as NativeQuotedPrintable from 'quoted-printable';
import * as NativePunycode from 'punycode';
@Injectable() @Injectable()
export class NativeLibraryWrapperService { export class NativeLibraryWrapperService {
public utf8:Utf8; public utf8: Utf8;
public quotedPrintable:QuotedPrintable; public quotedPrintable: QuotedPrintable;
public punycode:Punycode; public punycode: Punycode;
constructor() { constructor() {
this.utf8 = require("utf8"); this.utf8 = NativeUtf8;
this.quotedPrintable = require("quoted-printable"); this.quotedPrintable = NativeQuotedPrintable;
this.punycode = require("punycode"); this.punycode = NativePunycode;
} }
} }

View file

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

View file

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

View file

@ -1,13 +1,13 @@
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;
} }
} }

View file

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

0
src/assets/.gitkeep Normal file
View file

View file

@ -1,35 +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 {
font-family: "ABeeZee", sans-serif;
margin: 0;
padding: 1em 0 0 0;
}
h1 {
text-align: center;
}
.apploader {
text-align: center;
}

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 78 KiB

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: 1.1 KiB

View file

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

View file

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

View file

@ -1,11 +1,56 @@
import "core-js/es6"; /**
import "core-js/es7/reflect"; * This file includes polyfills needed by Angular and is loaded before the app.
require("zone.js/dist/zone"); * 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
*/
/***************************************************************************************************
* 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.
if (process.env.ENV === 'production') {
// Production /***************************************************************************************************
} else { * APPLICATION IMPORTS
// Development and test */
Error['stackTraceLimit'] = Infinity;
require('zone.js/dist/long-stack-trace-zone'); /**
} * 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;
}

30
src/test.ts Normal file
View file

@ -0,0 +1,30 @@
// 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 const __karma__: any;
declare const 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"
]
}

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

View file

@ -1,20 +1,20 @@
{ {
"compileOnSave": false,
"compilerOptions": { "compilerOptions": {
"alwaysStrict": true, "outDir": "./dist/out-tsc",
"target": "es5", "baseUrl": "src",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true, "sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"lib": [ "target": "es5",
"es2015",
"dom"
],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"typeRoots": [ "typeRoots": [
"../node_modules/@types/" "node_modules/@types"
],
"lib": [
"es2016",
"dom"
] ]
} }
} }

116
tslint.json Normal file
View file

@ -0,0 +1,116 @@
{
"rulesDirectory": [
"node_modules/codelyzer"
],
"rules": {
"callable-types": true,
"class-name": true,
"comment-format": [
true,
"check-space"
],
"curly": true,
"eofline": true,
"forin": true,
"import-blacklist": [true, "rxjs"],
"import-spacing": true,
"indent": [
true,
"spaces"
],
"interface-over-type-literal": true,
"label-position": true,
"max-line-length": [
true,
140
],
"member-access": false,
"member-ordering": [
true,
"static-before-instance",
"variables-before-functions"
],
"no-arg": true,
"no-bitwise": true,
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-construct": true,
"no-debugger": true,
"no-duplicate-variable": true,
"no-empty": false,
"no-empty-interface": true,
"no-eval": true,
"no-inferrable-types": [true, "ignore-params"],
"no-shadowed-variable": true,
"no-string-literal": false,
"no-string-throw": true,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": true,
"no-unused-expression": true,
"no-use-before-declare": true,
"no-var-keyword": true,
"object-literal-sort-keys": false,
"one-line": [
true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"prefer-const": true,
"quotemark": [
true,
"single"
],
"radix": true,
"semicolon": [
"always"
],
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"typeof-compare": true,
"unified-signatures": true,
"variable-name": false,
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
],
"directive-selector": [true, "attribute", "app", "camelCase"],
"component-selector": [true, "element", "app", "kebab-case"],
"use-input-property-decorator": true,
"use-output-property-decorator": true,
"use-host-property-decorator": true,
"no-input-rename": true,
"no-output-rename": true,
"use-life-cycle-interface": true,
"use-pipe-transform-interface": true,
"component-class-suffix": true,
"directive-class-suffix": true,
"no-access-missing-member": true,
"templates-use-public": true,
"invoke-injectable": true
}
}

View file

@ -1 +0,0 @@
module.exports = require('./config/webpack.dev.js');

5417
yarn.lock Normal file

File diff suppressed because it is too large Load diff