/** */ namespace _zeitbild.frontend_web { /** */ type type_conf = { view_mode : string; calendar_ids : Array; timezone_shift : int; }; /** */ async function render( ) : Promise { const target : HTMLElement = (document.querySelector("body") as HTMLBodyElement); const view_type : string = "table"; switch (view_type) { default: { throw (new Error("invalid view mode")); break; } case "table": { const content : string = await _zeitbild.frontend_web.view.calendar_view_table_html( { "calendar_ids": null, "from": { "year": 2024, "week": 37 }, "to": { "year": 2024, "week": 43 }, "timezone_shift": /*conf.timezone_shift*/0, } ); target.innerHTML = content; /* document.querySelectorAll(".tableview-sources-entry").forEach( (element) => { element.addEventListener( "click", (event) => { const element_ : HTMLElement = (event.target as HTMLElement); const calendar_id : type_calendar_id = parseInt(element_.getAttribute("rel") as string); const active : boolean = element_.classList.toggle("tableview-sources-entry-active"); render( conf, lib_plankton.call.convey( calendar_ids, [ (x : Array) => ( active ? calendar_ids.concat([calendar_id]) : calendar_ids.filter(y => (y !== calendar_id)) ), ] ) ); } ); } ); */ break; } case "list": { const content : string = await _zeitbild.frontend_web.view.calendar_view_list_html( null, { "timezone_shift": /*conf.timezone_shift*/0, } ); target.innerHTML = content; break; } } return Promise.resolve(undefined); } /** */ export async function main( ) : Promise { // init lib_plankton.log.conf_push( [ lib_plankton.log.channel_make({"kind": "console", "data": {"threshold": "info"}}), ] ); // conf await _zeitbild.frontend_web.conf.init(("conf.json")); // setup await _zeitbild.frontend_web.backend.session_begin( "alice", "alice" ); // args /* const url : URL = new URL(window.location.toString()); const calendar_ids : Array = ( (url.searchParams.get("ids") !== null) ? lib_plankton.call.convey( url.searchParams.get("ids"), [ (x : string) => lib_plankton.string.split(x, ","), (x : Array) => x.map(y => parseInt(y)), ] ) : (await _zeitbild.frontend_web.backend.calendar_list()).map(x => x.key) ); */ // exec await render(); return Promise.resolve(undefined); } }