Fix backend reload
This commit is contained in:
parent
52cb098421
commit
3fe4599408
1 changed files with 20 additions and 3 deletions
|
@ -33,22 +33,39 @@
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
|
|
||||||
let ws = new ReconnectingWebSocket('ws://localhost:8888/status/ws')
|
let ws = new ReconnectingWebSocket('ws://localhost:8888/status/ws')
|
||||||
|
let justOpened = false;
|
||||||
|
|
||||||
ws.addEventListener('open', () => {
|
ws.addEventListener('open', () => {
|
||||||
// ws.send('hi server')
|
// ws.send('hi server')
|
||||||
|
justOpened = true;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ws.addEventListener('message', (event) => {
|
ws.addEventListener('message', (event) => {
|
||||||
console.log('message: ' + event.data)
|
console.log('message: ' + event.data)
|
||||||
|
|
||||||
let data = JSON.parse(event.data)
|
let data = JSON.parse(event.data)
|
||||||
if(data.property === 'hit_id') {
|
if(data.property == 'hit_id') {
|
||||||
|
// on connect all
|
||||||
|
if(!justOpened){
|
||||||
|
setTimeout(function(){
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
|
console.log(justOpened + ' reloaded')
|
||||||
|
},20000)
|
||||||
|
}
|
||||||
|
justOpened = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue