55 lines
1.1 KiB
JavaScript
55 lines
1.1 KiB
JavaScript
|
|
// DOM STUFF ///////////////////////////////////////////////////////////////////
|
|
|
|
var app = new Vue({
|
|
el: '#wrapper',
|
|
data: {
|
|
message: 'Hello Vue!',
|
|
hits: {
|
|
|
|
}
|
|
},
|
|
// watch: {
|
|
// hits: {
|
|
// deep: true
|
|
// }
|
|
// }
|
|
})
|
|
|
|
|
|
// SOCKET STUFF ////////////////////////////////////////////////////////////////
|
|
|
|
|
|
let ws = new ReconnectingWebSocket('ws://localhost:8888/status/ws')
|
|
|
|
|
|
ws.addEventListener('open', () => {
|
|
// ws.send('hi server')
|
|
})
|
|
|
|
ws.addEventListener('message', (event) => {
|
|
console.log('message: ' + event.data)
|
|
|
|
let hits = JSON.parse(event.data)
|
|
let a = {};
|
|
for(let hitid in app.hits) {
|
|
a[hitid] = app.hits[hitid];
|
|
}
|
|
for(let hit of hits){
|
|
a[hit.id] = hit;
|
|
}
|
|
app.hits = a;
|
|
})
|
|
|
|
|
|
// ANIMATION STUFF /////////////////////////////////////////////////////////////
|
|
//
|
|
//function update(step){
|
|
//
|
|
// if(!hit_finished) elapsed_time = `${new Date((Date.now() - request_time)).format('MM"m "ss"s"')}`
|
|
// if(hit_started){
|
|
// divs['elapsed_time'].innerHTML = elapsed_time
|
|
// }else{
|
|
// divs['elapsed_time'].innerHTML = `—`
|
|
// }
|
|
//}
|