From a59ab194c33fdabbf481696cd7931eba0243cb88 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Mon, 15 Aug 2016 17:12:11 +0200 Subject: [PATCH] intermediate commit --- app/app.component.ts | 19 ++++++++++--- app/conversioninput.ts | 6 ++++ app/conversiontype.ts | 28 +++++++++++++++++++ app/inputarea.component.ts | 54 ++++++++++++++++++++++++++++++++++++ app/option.component._t_s_ | 12 ++++++++ app/selector.component._t_s_ | 19 +++++++++++++ index.html | 4 ++- 7 files changed, 137 insertions(+), 5 deletions(-) create mode 100644 app/conversioninput.ts create mode 100644 app/conversiontype.ts create mode 100644 app/inputarea.component.ts create mode 100644 app/option.component._t_s_ create mode 100644 app/selector.component._t_s_ diff --git a/app/app.component.ts b/app/app.component.ts index 0ea17ab..7799baf 100644 --- a/app/app.component.ts +++ b/app/app.component.ts @@ -1,11 +1,22 @@ import { Component } from "@angular/core"; +import { InputareaComponent } from "./inputarea.component"; +import {ConversionType} from "./conversiontype"; +//import { SelectorComponent } from "./selector.component"; + @Component({ - "selector":"dencode-app", - "template": ` -

dencode.org

- ` + selector: "den-app", + template: ` +
+ +
+ `, + directives: [InputareaComponent] }) export class AppComponent { + private inputAreas:InputareaComponent[] = []; + constructor() { + this.inputAreas.push(new InputareaComponent()); + } } diff --git a/app/conversioninput.ts b/app/conversioninput.ts new file mode 100644 index 0000000..0380c28 --- /dev/null +++ b/app/conversioninput.ts @@ -0,0 +1,6 @@ +import { ConversionType} from "./conversiontype"; + +export class ConversionInput { + public content:string; + public type:ConversionType; +} \ No newline at end of file diff --git a/app/conversiontype.ts b/app/conversiontype.ts new file mode 100644 index 0000000..4f34586 --- /dev/null +++ b/app/conversiontype.ts @@ -0,0 +1,28 @@ +export enum ConversionType { + ENCODE_BASE64, + DECODE_BASE64 +} + +export namespace ConversionType { + export function getName(type:ConversionType):string { + switch (type) { + case ConversionType.DECODE_BASE64: + return "Decode BASE64"; + case ConversionType.ENCODE_BASE64: + return "Encode BASE64"; + default: + return "Unknown"; + } + } + + export function of(id:number):ConversionType { + switch (id) { + case 0: + return ConversionType.ENCODE_BASE64; + case 1: + return ConversionType.DECODE_BASE64; + default: + return undefined; + } + } +} diff --git a/app/inputarea.component.ts b/app/inputarea.component.ts new file mode 100644 index 0000000..290175d --- /dev/null +++ b/app/inputarea.component.ts @@ -0,0 +1,54 @@ +import { Component } from "@angular/core"; +import { ConversionInput } from "./conversioninput"; +import { ConversionType } from "./conversiontype"; + + +@Component({ + selector: "den-inputarea", + template: ` +
+ + +
+ ` +}) +export class InputareaComponent { + public index:number = 0; + public conversions:ConversionType[] = [ConversionType.ENCODE_BASE64, ConversionType.DECODE_BASE64]; + private conversion:ConversionInput; + private ConversionType:ConversionType = ConversionType; + + constructor() { + console.log("Aloha, " + this.index); + this.conversion = new ConversionInput(); + this.conversion.content = ""; + this.conversion.type = ConversionType.DECODE_BASE64; + } + + public update():void { + console.log(this.conversion.content); + } + + public convert(e):void { + this.conversion.type = ConversionType.of(+e.target.selectedOptions[0].id); + console.log(this.conversion.type); + switch (this.conversion.type) { + case ConversionType.DECODE_BASE64: + this.conversion.content = "Base64 decode"; + break; + case ConversionType.ENCODE_BASE64: + this.conversion.content = "Base 64 encode"; + break; + default: + this.conversion.content = "Unknown: " + this.conversion.type; + break; + } + } + + public setIndex(index:number):void { + this.index = index; + } +} diff --git a/app/option.component._t_s_ b/app/option.component._t_s_ new file mode 100644 index 0000000..1398f21 --- /dev/null +++ b/app/option.component._t_s_ @@ -0,0 +1,12 @@ +//import {Component} from "@angular/core"; +// +//@Component({ +// selector: "den-option", +// template: ` +// +// ` +//}) +//export class OptionComponent { +// public id:string; +// public displayName:string; +//} \ No newline at end of file diff --git a/app/selector.component._t_s_ b/app/selector.component._t_s_ new file mode 100644 index 0000000..0c17a7e --- /dev/null +++ b/app/selector.component._t_s_ @@ -0,0 +1,19 @@ +//import {Component} from "@angular/core"; +// +//import {OptionComponent} from "./option.component"; +// +//@Component({ +// selector: "den-selector", +// template: ` +// +// `, +// directives: [OptionComponent] +//}) +//export class SelectorComponent { +// private options:OptionComponent[]; +// +//} \ No newline at end of file diff --git a/index.html b/index.html index d469d4c..f27b6d9 100644 --- a/index.html +++ b/index.html @@ -27,6 +27,8 @@ it requires you to enable Javascript to do so. So please turn it on in your Browser. You won't regret it! -Please hold on, we're starting the turbines ... + +
Please hold on, we're starting the turbines ...
+