diff --git a/assets/js/common.ts b/assets/js/common.ts index 230d068..21a37d4 100644 --- a/assets/js/common.ts +++ b/assets/js/common.ts @@ -15,30 +15,30 @@ export function config (api, polling): confdata { return { apiurl: api.path, pollurl: pu, itemid: urlparams.get('id') } } -export const pvapp = { +const appdata = { $delimiters: ['{|', '|}'], conf: {} as confdata, data: {}, output: '', - run, save, poll, - newdata: '', mounted(name: string) { console.log('app mounted: ', name) } } -// pvapp method definitions - -function run(conf: confdata) { - this.conf = conf - createApp(this).mount() - if (this.conf.pollurl) { - this.poll() +export const pvapp = { + run(conf: confdata) { + appdata.conf = conf + createApp(appdata).mount() + if (appdata.conf.pollurl) { + appdata.poll() + } } } +// appdata method definitions + function save(value: string) { this.output += '\n' + value console.log('save:', value) @@ -50,10 +50,10 @@ function poll() { // basic functions -async function dopoll(app: typeof pvapp) { +async function dopoll(app: typeof appdata) { while (true) { try { - let res = await fetch(pvapp.conf.pollurl) + let res = await fetch(app.conf.pollurl) let msg = await res.json() console.log(msg) //app.handle(msg)