From 56edced4abb0e01a4886737adfc9dd45d6a98610 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Sat, 18 Feb 2023 16:48:07 +0100 Subject: [PATCH] work in progress: frontend functionality with petite-vue --- assets/js/index.ts | 2 -- assets/js/main.ts | 26 ++++++++++++++++++++++++++ layouts/partials/js.html | 7 +------ 3 files changed, 27 insertions(+), 8 deletions(-) delete mode 100644 assets/js/index.ts create mode 100644 assets/js/main.ts diff --git a/assets/js/index.ts b/assets/js/index.ts deleted file mode 100644 index dee2a07..0000000 --- a/assets/js/index.ts +++ /dev/null @@ -1,2 +0,0 @@ - -PetiteVue.createApp({$delimiters: ['{|', '|}']}).mount() diff --git a/assets/js/main.ts b/assets/js/main.ts new file mode 100644 index 0000000..693eed5 --- /dev/null +++ b/assets/js/main.ts @@ -0,0 +1,26 @@ +import { createApp } from './lib/petite-vue.es.js' + +createApp({ + $delimiters: ['{|', '|}'], + urlParams: new URL(location.href).searchParams, + save +}).mount() + +function save(text: string) { + console.log(text) +} + +const s: string = 'test-string' +save(s) + +for (let i = 0; i < 10; i++) { + setTimeout(function () { + console.log(i); + }, 100 * i); +} + +// 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 4336bfa..53fa197 100644 --- a/layouts/partials/js.html +++ b/layouts/partials/js.html @@ -1,7 +1,2 @@ - - -{{ $js := resources.Get "js/index.ts" | js.Build }} +{{ $js := resources.Get "js/main.ts" | js.Build (dict "minify" false) }} -