diff options
Diffstat (limited to 'static')
-rw-r--r-- | static/js/lafargue.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/static/js/lafargue.js b/static/js/lafargue.js index 33c8e90..f1198cb 100644 --- a/static/js/lafargue.js +++ b/static/js/lafargue.js @@ -1,9 +1,19 @@ jQuery(function($) { if (WebSocket) { var websocket_base = $('head').attr('data-websocket-base'); - var socket = new WebSocket(websocket_base + '/lafargue/events'); - socket.onmessage = function(event) { - $('.lafargue-list').prepend(event.data); + var open_socket = function() { + var socket = new WebSocket(websocket_base + '/lafargue/events'); + socket.onmessage = function(event) { + $('.lafargue-list').prepend(event.data); + }; + var reconnect = function() { + window.setTimeout(function() { + open_socket(); + socket.close(); + }, 2000); + }; + socket.onclose = reconnect; }; + open_socket(); } }); |