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
pages
page.ts
[mod] client
Christian Fraß
commited
409a0a2
at 2021-03-12 22:01:10
page.ts
Blame
History
Raw
namespace folksprak.words.pages { /** */ export abstract class class_page { /** */ public abstract render ( ) : HTMLElement ; } /** */ var _pool : {[name : string] : ()=>class_page} = {}; /** */ export function register ( name : string, factory : ()=>class_page ) : void { if (_pool.hasOwnProperty(name)) { throw (new Error('page "' + name + '" already registered')); } else { _pool[name] = factory; } } /** */ export function load ( name : string, parameters : any ) : void { if (! _pool.hasOwnProperty(name)) { throw (new Error('page "' + name + '" not found')); } else { const page : class_page = _pool[name](); let dom_target : HTMLElement = document.querySelector('#main'); dom_target.textContent = ''; dom_target.appendChild(page.render()); } } /** */ export function setup ( ) : Promise<void> { register('portal', () => new class_page_portal()); return Promise.resolve<void>(undefined); } }