mirror of
https://github.com/unraid/webgui.git
synced 2026-05-07 21:01:19 -05:00
Stop monitored subs when unloading page
This commit is contained in:
@@ -1813,13 +1813,6 @@ $(function() {
|
||||
$('#netline').val(netline);
|
||||
$.removeCookie('lockbutton');
|
||||
// remember latest graph values
|
||||
$(window).on('beforeunload',function(e){
|
||||
var data = {};
|
||||
data.cpu = cpu.tail(cpuline);
|
||||
data.rxd = rxd.tail(netline);
|
||||
data.txd = txd.tail(netline);
|
||||
// $.post('/webGui/include/InitCharts.php',{cmd:'set',data:JSON.stringify(data)});
|
||||
});
|
||||
});
|
||||
|
||||
// Start graphs over again when window back in focus
|
||||
@@ -1830,13 +1823,5 @@ $(window).blur(function() {
|
||||
txd = [];
|
||||
});
|
||||
<?endif;?>
|
||||
window.onunload = function(){
|
||||
dashboard.stop();
|
||||
<?if ($vmusage == "Y"):?>
|
||||
vmdashusage.stop();
|
||||
<?endif;?>
|
||||
<?if ($apcupsd):?>
|
||||
apcups.stop();
|
||||
<?endif;?>
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@@ -1235,7 +1235,7 @@ $('body').on('click','a,.ca_href', function(e) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Start & stop live updates when window loses focus
|
||||
var nchanPaused = false;
|
||||
<? if ( $display['liveUpdate'] == "no" ):?>
|
||||
@@ -1249,7 +1249,21 @@ $(window).focus(function() {
|
||||
}
|
||||
});
|
||||
|
||||
// Stop nchan on loss of focus
|
||||
$(window).blur(function() {
|
||||
nchanFocusStop(true);
|
||||
});
|
||||
|
||||
// Include both beforeunload and unload as this may be unreliable in certain circumstances on mobile devices
|
||||
window.onbeforeunload = function() {
|
||||
nchanFocusStop(false);
|
||||
}
|
||||
|
||||
window.onunload = function() {
|
||||
nchanFocusStop(false);
|
||||
}
|
||||
|
||||
function nchanFocusStop(banner) {
|
||||
if ( subscribers.length ) {
|
||||
if ( nchanPaused === false ) {
|
||||
var newsub = subscribers;
|
||||
@@ -1261,12 +1275,12 @@ $(window).blur(function() {
|
||||
}
|
||||
});
|
||||
subscribers = newsub;
|
||||
if ( subscribers.length ) {
|
||||
if ( banner && subscribers.length ) {
|
||||
nchanPaused = addBannerWarning("<?=_('Live Updates Paused');?>",false,true );
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
<?endif;?>
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user