Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions les3/MT3C/DecoratorTextfield/dev/XxxXName.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/// <reference path="textObject.ts"/>

class XxxXName extends TextObject
{
private base : TextObject = null;

constructor(base:TextObject)
{
super();

this.base = base;
}

public toString(): string
{
return "Xx" + this.base.toString() + "xX";
}
}
18 changes: 18 additions & 0 deletions les3/MT3C/DecoratorTextfield/dev/capsName.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/// <reference path="textObject.ts"/>

class CapsName extends TextObject
{
private base : TextObject = null;

constructor(base:TextObject)
{
super();

this.base = base;
}

public toString(): string
{
return this.base.toString().toUpperCase();
}
}
17 changes: 17 additions & 0 deletions les3/MT3C/DecoratorTextfield/dev/decorators/capital.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/// <reference path="../textDecorator.ts" />

class Capital extends TextDecorator{

public getText() : string{
let splits = this.decoratedTxt.getText().split('. ');

let newString = '';
for (let word of splits) {
newString += word.charAt(0).toUpperCase();
newString += word.substr(1, word.length - 1);
newString += '. ';

}
return newString;
}
}
6 changes: 6 additions & 0 deletions les3/MT3C/DecoratorTextfield/dev/decorators/lowerCase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class LowerCase extends TextDecorator{

public getText() : string{
return this.decoratedTxt.getText().toLowerCase();
}
}
12 changes: 12 additions & 0 deletions les3/MT3C/DecoratorTextfield/dev/decorators/reverse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Reverse extends TextDecorator{

public getText() : string{
let text = this.decoratedTxt.getText();

let newString = '';
for (let i = text.length - 1; i >= 0; i--) {
newString += text[i];
}
return newString;
}
}
7 changes: 7 additions & 0 deletions les3/MT3C/DecoratorTextfield/dev/decorators/summary.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Summary extends TextDecorator{

public getText() : string{
let words = this.decoratedTxt.getText().split(' ', 10);
return words.join(' ');
}
}
17 changes: 17 additions & 0 deletions les3/MT3C/DecoratorTextfield/dev/extensions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
interface String
{
shuffle():string;
}

String.prototype.shuffle = function () {
var a = this.split(""),
n = a.length;

for(var i = n - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var tmp = a[i];
a[i] = a[j];
a[j] = tmp;
}
return a.join("");
}
24 changes: 24 additions & 0 deletions les3/MT3C/DecoratorTextfield/dev/leetName.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/// <reference path="textObject.ts"/>

class LeetName extends TextObject
{
private base : TextObject = null;

constructor(base:TextObject)
{
super();

this.base = base;
}

public toString(): string
{
let baseStr = this.base.toString();

return baseStr.replace(/l/gi, "1")
.replace(/e/gi, "3")
.replace(/t/gi, "7")
.replace(/o/gi, "0")
.replace(/a/gi, "4");
}
}
40 changes: 37 additions & 3 deletions les3/MT3C/DecoratorTextfield/dev/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,64 @@ function handleSubmit(e) {

let text = form.search.value;

<<<<<<< HEAD
// Textobject
var rawString : Txt = new RawString(text);

if(form.lowercase.checked) {
console.log("Alle karakters naar lowercase");
rawString = new LowerCase(rawString);

}

if(form.summary.checked) {
console.log("Alleen de eerste 10 woorden van de string");

rawString = new Summary(rawString);
}

if(form.capital.checked) {
console.log("Na elke punt spatie een hoofdletter");

rawString = new Capital(rawString);
}

if(form.reverse.checked) {
console.log("De tekst achterstevoren.");
rawString = new Reverse(rawString);
}

// student Decorators
if(form.removevowels.checked) {
console.log("klinkers verwijderen");
rawString = new RemoveVowels(rawString);
=======
let name = new Name();
name.text = text;

if(form.Scrambled.checked) {
name = new ScrambledName(name);

}

if(form.to1337.checked) {
name = new LeetName(name);

}

if(form.FULLCAPS.checked) {
name = new CapsName(name);
}

if(form.XxxX.checked) {
name = new XxxXName(name);
>>>>>>> bpikaar/master
}


let output = document.getElementById("output");
output.style.display = "block";
//output.innerHTML =
<<<<<<< HEAD
output.innerHTML = rawString.getText();
=======
output.innerText = name.toString();
>>>>>>> bpikaar/master
}
13 changes: 13 additions & 0 deletions les3/MT3C/DecoratorTextfield/dev/name.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/// <reference path="textObject.ts"/>
class Name extends TextObject
{
constructor()
{
super();
}

public toString(): string
{
return this.text;
}
}
12 changes: 12 additions & 0 deletions les3/MT3C/DecoratorTextfield/dev/rawString.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class RawString implements Txt{

private _rawString : string;

constructor(text : string) {
this._rawString = text;
}

public getText() : string {
return this._rawString
}
}
18 changes: 18 additions & 0 deletions les3/MT3C/DecoratorTextfield/dev/scrambledName.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/// <reference path="textObject.ts"/>

class ScrambledName extends TextObject
{
private base : TextObject = null;

constructor(base:TextObject)
{
super();

this.base = base;
}

public toString(): string
{
return this.base.toString().shuffle();
}
}
18 changes: 18 additions & 0 deletions les3/MT3C/DecoratorTextfield/dev/studentDecorators/removeVowels.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

/// <reference path="../textDecorator.ts" />
class RemoveVowels extends TextDecorator {
public getText() : string{
let splits = this.decoratedTxt.getText().split('');

let newString = '';
for (let letter of splits) {

if (letter == "a" || letter == "e" || letter == "i" || letter == "o" || letter == "u"){

} else {
newString += letter;
}
}
return newString;
}
}
3 changes: 0 additions & 3 deletions les3/MT3C/DecoratorTextfield/dev/text.ts

This file was deleted.

14 changes: 14 additions & 0 deletions les3/MT3C/DecoratorTextfield/dev/textDecorator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
abstract class TextDecorator implements Txt{

private decoratedText : Txt;

public get decoratedTxt(): Txt {
return this.decoratedText;
}

constructor(decoratedTxt : Txt) {
this.decoratedText = decoratedTxt;
}

public abstract getText() : string;
}
6 changes: 6 additions & 0 deletions les3/MT3C/DecoratorTextfield/dev/textObject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
abstract class TextObject
{
public text : string = "";

public abstract toString() : string;
}
30 changes: 21 additions & 9 deletions les3/MT3C/DecoratorTextfield/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,37 @@
<div class="grid">
<form action="" method="get" class="search" id="the-form">
<div class="form-field">
<input type="search" name="search" placeholder="Insert text here." class="form-input">
<input type="search" name="search" placeholder="Insert your name here." class="form-input">
<input type="submit" value="Submit" class="button" id="submit">
</div>

<div class="form-field">
<input type="checkbox" name="lowercase" class="form-input">
<label>Lower case</label>
<input type="checkbox" name="Scrambled" class="form-input">
<label>Scrambled</label>
</div>

<div class="form-field">
<input type="checkbox" name="to1337" class="form-input">
<label>1337</label>
</div>

<div class="form-field">
<input type="checkbox" name="summary" class="form-input">
<label>Summary</label>
<input type="checkbox" name="FULLCAPS" class="form-input">
<label>FULLCAPS</label>
</div>

<div class="form-field">
<input type="checkbox" name="capital" class="form-input">
<label>Capital</label>
<input type="checkbox" name="XxxX" class="form-input">
<label>Xx xX</label>
</div>
<<<<<<< HEAD
<div class="form-field">
<input type="checkbox" name="reverse" class="form-input">
<label>Reverse</label>
<input type="checkbox" name="removevowels" class="form-input">
<label>Remove vowels</label>
</div>
=======

>>>>>>> bpikaar/master
</form>
<p><br></p>
<div id="output"></div>
Expand Down
Loading