Fix backend reload

This commit is contained in:
mt 2019-11-04 11:34:10 +01:00
parent 52cb098421
commit 3fe4599408

View file

@ -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') {
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>