"use strict"; import Emel from 'emel'; import fa_emel from './forkawesome_emel.mjs'; class TableView { constructor(el) { if(this.el === null || typeof this.el === "undefined") throw new Error(`Expected HTML element as the first argument, but got null or undefined.`); this.el = el; this.el_parts = new Map(); this.emel = new Emel().emel; } clear() { this.el.replaceChildren(); this.el_parts.clear(); } init(tabledef) { this.clear(); const parts = this.emel(`h2>(${fa_emel(tabledef.icon)}+{?})^div[class=data-display]`, { placeholders: [ tabledef.name ] }); for(let def of tabledef.items) { // MARKER: We were last editing here } this.el.replaceChildren(parts); } async switch_table(table_name) { table_name = table_name.replace(/[^a-z0-9-_]/g, ""); this.clear(); for await (let tabledef of await globalThis.sysquery.table(table_name)) { this.append_table(tabledef.peer, tabledef.table); } } append_table(peer, table) { } } export default TableView;