hugo-theme-cyberscopes/assets/js/main.ts

44 lines
757 B
TypeScript

import { createApp } from './lib/petite-vue.es.js'
createApp({
$delimiters: ['{|', '|}'],
urlParams: new URL(location.href).searchParams,
poll,
newdata: '',
data: '',
save
}).mount()
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() {
return {
data: '',
save(txt: string) {
this.data += '\n' + txt
}
}
}
// p = new URL(location.href).searchParams
// id = p.get('id')