worker_specs
This commit is contained in:
parent
34199c394c
commit
9a1aa0312a
1 changed files with 18 additions and 15 deletions
|
@ -27,6 +27,7 @@ spec_names.forEach(function(name){
|
|||
|
||||
|
||||
let request_time = timeStamp(),
|
||||
hit_started = false,
|
||||
elapsed_time,
|
||||
hit_finished = false
|
||||
|
||||
|
@ -36,15 +37,6 @@ let request_time = timeStamp(),
|
|||
|
||||
let ws = new ReconnectingWebSocket('ws://localhost:8888/status/ws')
|
||||
|
||||
let test = `{"property": "os", "value": "213.127.20.197"}`
|
||||
|
||||
// fakeWs(test)
|
||||
//
|
||||
// function fakeWs(json){
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
ws.addEventListener('open', () => {
|
||||
// ws.send('hi server')
|
||||
|
@ -56,14 +48,21 @@ ws.addEventListener('message', (event) => {
|
|||
|
||||
let data = JSON.parse(event.data)
|
||||
if(data.property === 'hit_opened') {
|
||||
hit_finished = false
|
||||
request_time = timeStamp()
|
||||
divs[data.property].innerHTML = `${request_time.format('dd mmm HH:MM:ss')}`
|
||||
if(data.value != null){
|
||||
hit_started = true
|
||||
hit_finished = false
|
||||
request_time = timeStamp()
|
||||
divs[data.property].innerHTML = `${request_time.format('dd mmm HH:MM:ss')}`
|
||||
}else{
|
||||
hit_started = false
|
||||
}
|
||||
}
|
||||
else if(data.property === 'hit_submitted'){
|
||||
hit_finished = true;
|
||||
}
|
||||
else if(divs[data.property]) divs[data.property].innerHTML = `${data.value}`
|
||||
else if(divs[data.property]){
|
||||
data.value === null ? divs[data.property].innerHTML = `—` : divs[data.property].innerHTML = `${data.value}`
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
@ -103,8 +102,11 @@ function makeAnimation(){
|
|||
function update(step){
|
||||
|
||||
if(!hit_finished) elapsed_time = `${new Date((Date.now() - request_time)).format('MM"m "ss"s"')}`
|
||||
|
||||
divs['elapsed_time'].innerHTML = elapsed_time
|
||||
if(hit_started){
|
||||
divs['elapsed_time'].innerHTML = elapsed_time
|
||||
}else{
|
||||
divs['elapsed_time'].innerHTML = `—`
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -112,3 +114,4 @@ makeAnimation()
|
|||
|
||||
|
||||
function timeStamp(){return window.performance && window.performance.now ? window.performance.now() : new Date().getTime()}
|
||||
|
||||
|
|
Loading…
Reference in a new issue