From 57e4579dfe0cf4e24d1bc974641e88aa27a54970 Mon Sep 17 00:00:00 2001 From: Squidly271 Date: Mon, 24 Mar 2025 13:46:33 -0400 Subject: [PATCH] Stop monitored on unload if live updates enabled --- .../plugins/dynamix/include/DefaultPageLayout.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/emhttp/plugins/dynamix/include/DefaultPageLayout.php b/emhttp/plugins/dynamix/include/DefaultPageLayout.php index 124ad9daf..43c7906f6 100644 --- a/emhttp/plugins/dynamix/include/DefaultPageLayout.php +++ b/emhttp/plugins/dynamix/include/DefaultPageLayout.php @@ -723,7 +723,7 @@ unset($buttons,$button); // Build page content // Reload page every X minutes during extended viewing? -if (isset($myPage['Load']) && $myPage['Load']>0) echo "\n\n";echo "
"; +if (isset($myPage['Load']) && $myPage['Load']>0 && $display['liveUpdate'] !== "no") echo "\n\n";echo "
"; $tab = 1; $pages = []; if (!empty($myPage['text'])) $pages[$myPage['name']] = $myPage; @@ -1235,7 +1235,7 @@ $('body').on('click','a,.ca_href', function(e) { } } }); - + // Start & stop live updates when window loses focus var nchanPaused = false; @@ -1251,9 +1251,9 @@ $(window).focus(function() { // Stop nchan on loss of focus $(window).blur(function() { - nchanFocusStop(true); + nchanFocusStop(); }); - + // Include both beforeunload and unload as this may be unreliable in certain circumstances on mobile devices window.onbeforeunload = function() { nchanFocusStop(false); @@ -1263,14 +1263,14 @@ window.onunload = function() { nchanFocusStop(false); } -function nchanFocusStop(banner) { +function nchanFocusStop(banner=true) { if ( subscribers.length ) { if ( nchanPaused === false ) { var newsub = subscribers; subscribers.forEach(function(e) { try { e.stop(); - } catch { + } catch(err) { newsub.splice(newsub.indexOf(e,1)); } }); @@ -1281,7 +1281,6 @@ function nchanFocusStop(banner) { } } } -