49 lines
928 B
TypeScript
49 lines
928 B
TypeScript
import { createApp } from './lib/petite-vue.es.js'
|
|
|
|
const appdata = {
|
|
$delimiters: ['{|', '|}'],
|
|
urlParams: new URL(location.href).searchParams,
|
|
poll,
|
|
newdata: '',
|
|
data: '',
|
|
save
|
|
}
|
|
|
|
createApp(appdata).mount()
|
|
|
|
appdata.poll()
|
|
|
|
// method definitions
|
|
|
|
function save() {
|
|
this.data += '\n' + this.newdata
|
|
this.newdata = ''
|
|
}
|
|
|
|
const apiUrl = 'http://localhost:8125/api/system/poll/service/pclt-0001'
|
|
|
|
async function dopoll(obj: typeof appdata) {
|
|
while (true) {
|
|
let res = await fetch('http://localhost:8125/api/system/poll/service/pclt-0001')
|
|
//let res = await fetch(apiUrl)
|
|
let data = await res.json()
|
|
console.log(data)
|
|
obj.newdata = data['status']
|
|
}
|
|
}
|
|
|
|
function poll() {
|
|
dopoll(this)
|
|
}
|
|
|
|
function x_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()
|
|
})
|
|
return null
|
|
}
|
|
|