From 2123a565e246bae769d8fd237387f9896ee5d377 Mon Sep 17 00:00:00 2001 From: IgorA100 Date: Fri, 31 May 2024 17:27:10 +0300 Subject: [PATCH 1/4] Delay monitors stopping for 15 seconds when hiding page (montage.js) --- web/skins/classic/views/js/montage.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/web/skins/classic/views/js/montage.js b/web/skins/classic/views/js/montage.js index 50972c6913..7429604397 100644 --- a/web/skins/classic/views/js/montage.js +++ b/web/skins/classic/views/js/montage.js @@ -1105,11 +1105,15 @@ $j(window).on('load', () => initPage()); document.onvisibilitychange = () => { if (document.visibilityState === "hidden") { - //Stop monitors when closing or hiding page - for (let i = 0, length = monitorData.length; i < length; i++) { - monitors[i].kill(); - } + TimerHideShow = clearTimeout(TimerHideShow); + TimerHideShow = setTimeout(function() { + //Stop monitors when closing or hiding page + for (let i = 0, length = monitorData.length; i < length; i++) { + monitors[i].kill(); + } + }, 15*1000); } else { + TimerHideShow = clearTimeout(TimerHideShow); //Start monitors when show page for (let i = 0, length = monitorData.length; i < length; i++) { if (!monitors[i].started) { @@ -1119,6 +1123,7 @@ document.onvisibilitychange = () => { } }; + /* window.onbeforeunload = function(e) { console.log('unload'); From 1d5f049df22019034a40f15ac1a41f075221e552 Mon Sep 17 00:00:00 2001 From: IgorA100 Date: Fri, 31 May 2024 17:42:12 +0300 Subject: [PATCH 2/4] Delay monitors stopping for 15 seconds when hiding page (watch.js) --- web/skins/classic/views/js/watch.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/web/skins/classic/views/js/watch.js b/web/skins/classic/views/js/watch.js index df7df9428e..16e2d5d8af 100644 --- a/web/skins/classic/views/js/watch.js +++ b/web/skins/classic/views/js/watch.js @@ -24,6 +24,7 @@ var coordinateMouse = { }; var leftBtnStatus = {Down: false, UpAfterDown: false}; var updateScale = false; //Scale needs to be updated +var TimerHideShow; /* This is the format of the json object sent by bootstrap-table @@ -1407,8 +1408,11 @@ $j( window ).on("load", initPage); document.onvisibilitychange = () => { if (document.visibilityState === "hidden") { - //Stop monitor when closing or hiding page - monitorStream.kill(); + TimerHideShow = clearTimeout(TimerHideShow); + TimerHideShow = setTimeout(function() { + //Stop monitor when closing or hiding page + monitorStream.kill(); + }, 15*1000); } else { //Start monitor when show page if (!monitorStream.started) { From f9a55201cdadc47312667462374baaa0f8cc73a3 Mon Sep 17 00:00:00 2001 From: IgorA100 Date: Fri, 31 May 2024 17:53:18 +0300 Subject: [PATCH 3/4] Delay monitors stopping for 15 seconds when hiding page (zone.js) --- web/skins/classic/views/js/zone.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/web/skins/classic/views/js/zone.js b/web/skins/classic/views/js/zone.js index d8a1bdb921..4c3b9f3178 100644 --- a/web/skins/classic/views/js/zone.js +++ b/web/skins/classic/views/js/zone.js @@ -7,6 +7,7 @@ var refreshBtn = $j('#refreshBtn'); var analyseBtn = $j('#analyseBtn'); var monitors = []; var analyse_frames = true; +var TimerHideShow; function validateForm( form ) { var errors = []; @@ -763,10 +764,13 @@ function Polygon_calcArea(coords) { document.onvisibilitychange = () => { if (document.visibilityState === "hidden") { - //Stop monitors when closing or hiding page - for (let i = 0, length = monitorData.length; i < length; i++) { - monitors[i].kill(); - } + TimerHideShow = clearTimeout(TimerHideShow); + TimerHideShow = setTimeout(function() { + //Stop monitors when closing or hiding page + for (let i = 0, length = monitorData.length; i < length; i++) { + monitors[i].kill(); + } + }, 15*1000); } else { //Start monitors when show page for (let i = 0, length = monitorData.length; i < length; i++) { From 4b5d468af32a3cfef1267c1c5e3d7532e1315ff4 Mon Sep 17 00:00:00 2001 From: IgorA100 Date: Fri, 31 May 2024 17:55:42 +0300 Subject: [PATCH 4/4] Delay monitors stopping for 15 seconds when hiding page (zones.js) --- web/skins/classic/views/js/zones.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/web/skins/classic/views/js/zones.js b/web/skins/classic/views/js/zones.js index 132fb768af..0b7303cb98 100644 --- a/web/skins/classic/views/js/zones.js +++ b/web/skins/classic/views/js/zones.js @@ -5,6 +5,7 @@ function AddNewZone(el) { } var monitors = new Array(); +var TimerHideShow; function initPage() { for ( var i = 0, length = monitorData.length; i < length; i++ ) { @@ -54,10 +55,13 @@ window.addEventListener('DOMContentLoaded', initPage); document.onvisibilitychange = () => { if (document.visibilityState === "hidden") { - //Stop monitors when closing or hiding page - for (let i = 0, length = monitorData.length; i < length; i++) { - monitors[i].kill(); - } + TimerHideShow = clearTimeout(TimerHideShow); + TimerHideShow = setTimeout(function() { + //Stop monitors when closing or hiding page + for (let i = 0, length = monitorData.length; i < length; i++) { + monitors[i].kill(); + } + }, 15*1000); } else { //Start monitors when show page for (let i = 0, length = monitorData.length; i < length; i++) {