diff --git a/src/ratpack/handlebars/topic-watch.html.hbs b/src/ratpack/handlebars/topic-watch.html.hbs index 3c1152c..cbfc2ed 100644 --- a/src/ratpack/handlebars/topic-watch.html.hbs +++ b/src/ratpack/handlebars/topic-watch.html.hbs @@ -8,14 +8,18 @@ -
+
+ + +
+ +
Loading..
-
@@ -34,5 +38,17 @@ $('#grepfield').blur(); e.preventDefault(); }); + + $('#stop').click(function(e) { + $(e.target).toggle(); + $('#start').toggle(); + if (window.ws) { window.ws.close() }; + }); + + $('#start').click(function(e) { + $(e.target).toggle(); + $('#stop').toggle(); + watchTopic("{{name}}"); + }); {{> footer}} diff --git a/src/ratpack/public/js/ws.js b/src/ratpack/public/js/ws.js index 30559f1..cdfd537 100644 --- a/src/ratpack/public/js/ws.js +++ b/src/ratpack/public/js/ws.js @@ -31,13 +31,17 @@ function watchTopic(name) { }; window.ws.onclose = function(event) { $('.progress-bar').removeClass('active'); - var timer = setTimeout(function() { - console.log("Retrying connection..."); - watchTopic(name); - if (window.ws.readyState == WebSocket.OPEN) { - clearTimeout(timer); - } - }, 1000); + + // If our stop button is still visible, we didn't stop manually + if ($('#stop:visible').size() > 0) { + var timer = setTimeout(function() { + console.log("Retrying connection..."); + watchTopic(name); + if (window.ws.readyState == WebSocket.OPEN) { + clearTimeout(timer); + } + }, 1000); + } }; } }