2019-11-01 17:30:50 +00:00
|
|
|
|
|
|
|
|
|
// DOM STUFF ///////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2020-01-13 15:13:42 +00:00
|
|
|
|
var app = new Vue({
|
|
|
|
|
el: '#wrapper',
|
|
|
|
|
data: {
|
|
|
|
|
message: 'Hello Vue!',
|
|
|
|
|
hits: {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
},
|
2020-01-22 15:04:13 +00:00
|
|
|
|
methods: {
|
|
|
|
|
formatPrice(value) {
|
|
|
|
|
let val = (value/1).toFixed(2).replace('.', ',')
|
|
|
|
|
return val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".")
|
|
|
|
|
},
|
|
|
|
|
duration(date1, date2){
|
|
|
|
|
let s1 = Date.parse(date1) / 1000;
|
|
|
|
|
let s2 = Date.parse(date2) / 1000;
|
|
|
|
|
let interval = s1 - s2;
|
|
|
|
|
let minutes = Math.floor(interval / 60);
|
|
|
|
|
let seconds = interval % 60;
|
|
|
|
|
let o = `${seconds}″`;
|
|
|
|
|
if( minutes > 0) {
|
|
|
|
|
o = `${minutes}′` + o;
|
|
|
|
|
}
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-13 15:13:42 +00:00
|
|
|
|
// watch: {
|
|
|
|
|
// hits: {
|
|
|
|
|
// deep: true
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2019-11-01 17:30:50 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
|
|
2020-01-13 15:13:42 +00:00
|
|
|
|
let hits = JSON.parse(event.data)
|
|
|
|
|
let a = {};
|
|
|
|
|
for(let hitid in app.hits) {
|
|
|
|
|
a[hitid] = app.hits[hitid];
|
2019-11-01 17:30:50 +00:00
|
|
|
|
}
|
2020-01-13 15:13:42 +00:00
|
|
|
|
for(let hit of hits){
|
|
|
|
|
a[hit.id] = hit;
|
2019-11-01 17:56:00 +00:00
|
|
|
|
}
|
2020-01-13 15:13:42 +00:00
|
|
|
|
app.hits = a;
|
2019-11-01 17:30:50 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ANIMATION STUFF /////////////////////////////////////////////////////////////
|
2020-01-13 15:13:42 +00:00
|
|
|
|
//
|
|
|
|
|
//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 = `—`
|
|
|
|
|
// }
|
|
|
|
|
//}
|