diff --git a/assets/js/main.ts b/assets/js/main.ts index 4b1098a..db01e77 100644 --- a/assets/js/main.ts +++ b/assets/js/main.ts @@ -3,6 +3,7 @@ import { createApp } from './lib/petite-vue.es.js' createApp({ $delimiters: ['{|', '|}'], urlParams: new URL(location.href).searchParams, + poll, newdata: '', data: '', save @@ -10,6 +11,23 @@ createApp({ function save() { this.data += '\n' + this.newdata + this.newdata = '' +} + +//let pwait = new Promise(function(resolve, reject) { +// poll() +//}) + +function poll() { + fetch('http://localhost:8125/api/system/poll/service/pclt-0001') + .then((res) => res.json()) + .then((data) => { + console.log(data) + this.newdata = data['status'] + this.poll() + }) + console.log('after fetch') + return null } function Data() { @@ -24,5 +42,3 @@ function Data() { // p = new URL(location.href).searchParams // id = p.get('id') -// fetch('http://localhost:8125/api/system/poll/service/pclt-0001'). -// then((res) => res.json()).then((data) => console.log(data)) diff --git a/layouts/partials/js.html b/layouts/partials/js.html index 53fa197..8162381 100644 --- a/layouts/partials/js.html +++ b/layouts/partials/js.html @@ -1,2 +1,3 @@ {{ $js := resources.Get "js/main.ts" | js.Build (dict "minify" false) }} - + +
{| poll() |}
diff --git a/layouts/shortcodes/input.html b/layouts/shortcodes/input.html index a100152..1577670 100644 --- a/layouts/shortcodes/input.html +++ b/layouts/shortcodes/input.html @@ -16,4 +16,3 @@
id = {| urlParams.get('id') |}
-