diff --git a/burpui/templates/gerard.js b/burpui/templates/gerard.js index 43cfd99c..da70356a 100644 --- a/burpui/templates/gerard.js +++ b/burpui/templates/gerard.js @@ -469,7 +469,8 @@ $(function() { * auto-refresh our page if needed */ {% set autorefresh = config.REFRESH -%} - var auto_refresh = setInterval(function() { + var auto_refresh = undefined; + var auto_refresh_function = function() { {% if clients -%} _clients(); {% endif -%} @@ -479,8 +480,12 @@ $(function() { {% if servers and overview -%} _servers(); {% endif -%} - return; - }, {{ autorefresh * 1000 }}); + if (auto_refresh) { + clearTimeout(auto_refresh); + } + auto_refresh = setTimeout(auto_refresh_function, {{ autorefresh * 1000 }}); + }; + auto_refresh = setTimeout(auto_refresh_function, {{ autorefresh * 1000 }}); {% endif -%} {% if not login -%} @@ -488,9 +493,15 @@ $(function() { /*** * Javascript Loop */ - var refresh_running = setInterval(function () { + var refresh_running = undefined; + var refresh_function = function() { _check_running(); - }, {{ config.LIVEREFRESH * 1000 }}); + if (refresh_running) { + clearTimeout(refresh_running); + } + refresh_running = setTimeout(refresh_function, {{ config.LIVEREFRESH * 1000 }}); + }; + refresh_running = setTimeout(refresh_function, {{ config.LIVEREFRESH * 1000 }}); {% endif -%} {% endif -%} }); diff --git a/burpui/templates/js/client.js b/burpui/templates/js/client.js index e35b6842..38124cab 100644 --- a/burpui/templates/js/client.js +++ b/burpui/templates/js/client.js @@ -195,7 +195,7 @@ var refresh_status = function( is_running ) { var _span = $('#running-status'); var _inner_format_status = function(status) { var _content = ' '; - if (status.state == 'running') { + if (status.state == '{{ _("running") }}') { _client_running = true; _content += status.state+' - '+status.phase; if (status.percent > 0) { @@ -227,11 +227,11 @@ var refresh_status = function( is_running ) { _get_running = _inner_get_status(); } var _inner_callback_setup = function() { - if (__refresh_running && !(is_running || _client_running)) { - clearInterval(__refresh_running); - __refresh_running = undefined; - } else if (!__refresh_running && _client_running) { - __refresh_running = setInterval(function() { + if (__refresh_running) { + clearTimeout(__refresh_running); + } + if (_client_running) { + __refresh_running = setTimeout(function() { refresh_status(true); }, {{ config.LIVEREFRESH * 1000 }}); } diff --git a/burpui/templates/js/clients.js b/burpui/templates/js/clients.js index 296be98d..fbef2c58 100644 --- a/burpui/templates/js/clients.js +++ b/burpui/templates/js/clients.js @@ -196,17 +196,16 @@ var refresh_status = function( is_running ) { }); _promises.push(_p); }); - if (__refresh_running && (!is_running || _clients_running.length == 0)) { - // stop loop if no more clients are running - clearInterval(__refresh_running); - __refresh_running = undefined; - } else if (!__refresh_running && _clients_running.length > 0) { - __refresh_running = setInterval(function() { - refresh_status(true); - }, {{ config.LIVEREFRESH * 1000 }}); - } $.when.apply( $, _promises ).done( function() { _clients_table.draw(false); + if (_clients_running.length > 0) { + if (__refresh_running) { + clearTimeout(__refresh_running); + } + __refresh_running = setTimeout(function() { + refresh_status(true); + }, {{ config.LIVEREFRESH * 1000 }}); + } }); }; if (_get_running) {