git.schokokeks.org
Repositories
Help
Report an Issue
fs-words.git
Code
Commits
Branches
Tags
Suche
Strukturansicht:
409a0a2
Branches
Tags
develop-client_server
master
typescript
fs-words.git
client
source
widgets
languagechooser
logic.ts
[mod] client
Christian Fraß
commited
409a0a2
at 2021-03-12 22:01:10
logic.ts
Blame
History
Raw
namespace folksprak.words.widgets { export class class_widget_languagechooser extends class_widget { /** */ private classes : Array<string>; /** */ private dom_select : HTMLSelectElement; /** */ public constructor(classes : Array<string> = []) { super(); this.classes = classes; this.dom_select = undefined; } /** */ public render() : HTMLElement { const languages : Array<{value : string; label : string;}> = [ {'value': '_', 'label': '*'}, {'value': 'afr', 'label': 'afr'}, {'value': 'dan', 'label': 'dan'}, {'value': 'deu', 'label': 'deu'}, {'value': 'eng', 'label': 'eng'}, {'value': 'flk', 'label': 'flk'}, {'value': 'gem', 'label': 'gem'}, {'value': 'isl', 'label': 'isl'}, {'value': 'nld', 'label': 'nld'}, {'value': 'nob', 'label': 'nob'}, {'value': 'swe', 'label': 'swe'}, {'value': 'yid', 'label': 'yid'}, ]; const dom_select : HTMLSelectElement = <HTMLSelectElement>(document.createElement('select')); dom_select.setAttribute ( 'class', ['widget', 'widget-languagechooser'].concat(this.classes).join(' ') ); for (const language of languages) { let dom_option : HTMLOptionElement = document.createElement('option'); dom_option.setAttribute('value', language.value); dom_option.textContent = language.label; dom_select.appendChild(dom_option); } this.dom_select = dom_select; return dom_select; } /** */ public read() : string { return this.dom_select.value; } /** */ public write(language : string) : void { this.dom_select.value = language; } } }