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'>
|
||||
|
||||
let ws = new ReconnectingWebSocket('ws://localhost:8888/status/ws')
|
||||
|
||||
let justOpened = false;
|
||||
|
||||
ws.addEventListener('open', () => {
|
||||
// ws.send('hi server')
|
||||
justOpened = true;
|
||||
})
|
||||
|
||||
|
||||
|
||||
ws.addEventListener('message', (event) => {
|
||||
console.log('message: ' + event.data)
|
||||
|
||||
let data = JSON.parse(event.data)
|
||||
if(data.property === 'hit_id') {
|
||||
window.location.reload();
|
||||
if(data.property == 'hit_id') {
|
||||
// on connect all
|
||||
if(!justOpened){
|
||||
setTimeout(function(){
|
||||
window.location.reload();
|
||||
console.log(justOpened + ' reloaded')
|
||||
},20000)
|
||||
}
|
||||
justOpened = false;
|
||||
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue