From 2b0a2b8286a97792b805d3b40d0e36df7703c831 Mon Sep 17 00:00:00 2001 From: Alexander Moisseev Date: Fri, 30 Dec 2016 16:49:16 +0300 Subject: [PATCH] [WebUI] Stop stats refreshing if the page is hidden --- interface/js/rspamd.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/interface/js/rspamd.js b/interface/js/rspamd.js index f2690baf5e..6f3fc5040c 100644 --- a/interface/js/rspamd.js +++ b/interface/js/rspamd.js @@ -69,7 +69,7 @@ symbols.destroy(); symbols = null; } - clearTimeout(stat_timeout); + Visibility.stop(stat_timeout); cleanCredentials(); connectRSPAMD(); // window.location.reload(); @@ -78,11 +78,14 @@ $('#refresh').on('click', function (event) { if (!$(this).attr('disabled')) { $(this).attr('disabled', true); - clearTimeout(stat_timeout); + Visibility.stop(stat_timeout); + statWidgets(); + stat_timeout = Visibility.every(10000, function () { + statWidgets(); + }); getChart(); getGraphData(selected.selData); - statWidgets(); setTimeout(function () { $('#refresh').removeAttr('disabled'); @@ -382,7 +385,6 @@ $('#statWidgets .left,#statWidgets .right').wrapAll('
  • '); $('#statWidgets').find('li.pull-right').appendTo('#statWidgets'); $(widgets).show(); - stat_timeout = window.setTimeout(statWidgets, 10000); } // @opem modal with target form enabled $(document).on('click', '[data-toggle="modal"]', function (e) { @@ -1264,6 +1266,9 @@ // @toggle auth and main var disconnect = $('#navBar .pull-right'); statWidgets(); + stat_timeout = Visibility.every(10000, function () { + statWidgets(); + }); $('#mainUI').show(); $('#progress').show(); -- 2.47.3