diff --git a/assets/js/common.ts b/assets/js/common.ts index 9e7520e..07f460b 100644 --- a/assets/js/common.ts +++ b/assets/js/common.ts @@ -7,12 +7,18 @@ type confdata = { apiurl: string pollurl: string itemid: string + sid: string } export function config (api, polling): confdata { const pu = polling ? `${api.path}/${polling.msgbase.join('/')}` : '' const urlparams = new URL(location.href).searchParams - return { apiurl: api.path, pollurl: pu, itemid: urlparams.get('id') } + return { + apiurl: api.path, + pollurl: pu, + itemid: urlparams.get('id'), + sid: getSid() + } } export const pvapp = { @@ -28,6 +34,7 @@ export const pvapp = { const appdata = { $delimiters: ['{|', '|}'], conf: {} as confdata, + components: {}, output: '', poll, mounted(name: string) { @@ -39,11 +46,13 @@ const appdata = { // components -function Data() { - return { +function Data(name: string): object { + const comp = { data: {}, save } + appdata.components[name] = comp + return comp } // appdata and component method definitions @@ -81,9 +90,9 @@ function getSid(): string { return sid } -console.log("sid: ", getSid()) -//localStorage.setItem('api.sessionid', '') +//console.log("sid: ", getSid()) // TODO: clear sid - when? +//localStorage.setItem('api.sessionid', '') async function dopoll(app: typeof appdata) { while (true) { diff --git a/layouts/shortcodes/pv/debug.html b/layouts/shortcodes/pv/debug.html index 15cf08c..0ba126b 100644 --- a/layouts/shortcodes/pv/debug.html +++ b/layouts/shortcodes/pv/debug.html @@ -1,7 +1,8 @@