diff options
Diffstat (limited to 'juick-ws/src/main/static/scripts.js')
-rw-r--r-- | juick-ws/src/main/static/scripts.js | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/juick-ws/src/main/static/scripts.js b/juick-ws/src/main/static/scripts.js index 9b4c721f..1a212563 100644 --- a/juick-ws/src/main/static/scripts.js +++ b/juick-ws/src/main/static/scripts.js @@ -9,6 +9,25 @@ function ready(fn) { } } +function refreshStatus() { + setTimeout(function() { + fetch("/api/status") + .then(function(response) { + return response.text(); + }).then(function(body) { + status.textContent = JSON.parse(body).status; + refreshStatus(); + }) + }, 5000); +} + +function keepalive() { + setTimeout(function() { + ws.send(" "); + keepalive(); + }, 60000); +} + ready(function() { var ws = new WebSocket('wss://ws.juick.com/'); var term = new Terminal('terminal', {}, {}); @@ -22,15 +41,6 @@ ready(function() { ws.onmessage = function(msg) { term.output("<br/>" + JSON.stringify(JSON.parse(msg.data), null, 2)); } - setTimeout(function() { - ws.send(" "); - }, 60000); - setTimeout(function() { - fetch("/api/status") - .then(function(response) { - return response.text(); - }).then(function(body) { - status.textContent = JSON.parse(body).status; - }) - }, 5000); + refreshStatus(); + keepalive(); })
\ No newline at end of file |