From 96bd6397c69ef5fe9a3abb80330d762ba486cbbc Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Sat, 8 Aug 2020 10:38:58 -0500 Subject: [PATCH 01/11] eslint nanny --- web/skins/classic/includes/functions.php | 4 ++-- web/skins/classic/js/skin.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index 2bbc2ea54..31986c8df 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -154,9 +154,9 @@ if ( $css != 'base' ) } jQuery("#dropdown_bandwidth a").click(function() { var bwval = jQuery(this).data('pdsa-dropdown-val'); - setCookie("zmBandwidth",bwval,3600); + setCookie("zmBandwidth", bwval, 3600); getNavBar(); - }); + }); jQuery("#flip").click(function() { jQuery("#panel").slideToggle("slow"); var flip = jQuery("#flip"); diff --git a/web/skins/classic/js/skin.js b/web/skins/classic/js/skin.js index 67488f7a7..baca79ef6 100644 --- a/web/skins/classic/js/skin.js +++ b/web/skins/classic/js/skin.js @@ -346,9 +346,9 @@ if ( currentView != 'none' && currentView != 'login' ) { if ( key == 'getBandwidthHTML' ) { jQuery("#dropdown_bandwidth a").click(function() { var bwval = jQuery(this).data('pdsa-dropdown-val'); - setCookie("zmBandwidth",bwval,3600); + setCookie("zmBandwidth", bwval, 3600); getNavBar(); - }); + }); } } } From b626e0de1c4ef5e10b0dd5d41a42d627ca226d45 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Sat, 8 Aug 2020 11:19:29 -0500 Subject: [PATCH 02/11] eslint nanny strikes again --- web/skins/classic/js/skin.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/web/skins/classic/js/skin.js b/web/skins/classic/js/skin.js index baca79ef6..d98169b45 100644 --- a/web/skins/classic/js/skin.js +++ b/web/skins/classic/js/skin.js @@ -588,14 +588,14 @@ function setButtonState(element_id, butClass) { } } -function setCookie(name,value,days) { - var expires = ""; - if (days) { - var date = new Date(); - date.setTime(date.getTime() + (days*24*60*60*1000)); - expires = "; expires=" + date.toUTCString(); - } - document.cookie = name + "=" + (value || "") + expires + "; path=/"; +function setCookie(name, value, days) { + var expires = ""; + if (days) { + var date = new Date(); + date.setTime(date.getTime() + (days*24*60*60*1000)); + expires = "; expires=" + date.toUTCString(); + } + document.cookie = name + "=" + (value || "") + expires + "; path=/"; } function delCookie(name) { From fd4b9ba4f4564a6bbd140ce4e4f960e28a74ecbc Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Sat, 8 Aug 2020 12:06:57 -0500 Subject: [PATCH 03/11] move jquery in functions.php to skin.js --- web/skins/classic/includes/functions.php | 59 +------------------- web/skins/classic/js/skin.js | 70 +++++++++++++++++++++--- 2 files changed, 63 insertions(+), 66 deletions(-) diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index 31986c8df..36798e2f0 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -134,64 +134,7 @@ if ( $css != 'base' ) - + Date: Sat, 8 Aug 2020 12:13:05 -0500 Subject: [PATCH 04/11] move eslint check to the top let's us see the results quicker --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index de71ce36e..525f68450 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,7 @@ install: - update-binfmts --enable qemu-arm env: + - SMPFLAGS=-j4 OS=eslint DIST=eslint - SMPFLAGS=-j4 OS=el DIST=7 DOCKER_REPO=knnniggett/packpack - SMPFLAGS=-j4 OS=el DIST=8 DOCKER_REPO=knnniggett/packpack - SMPFLAGS=-j4 OS=fedora DIST=31 DOCKER_REPO=knnniggett/packpack @@ -45,7 +46,6 @@ env: - SMPFLAGS=-j4 OS=debian DIST=jessie DOCKER_REPO=iconzm/packpack - SMPFLAGS=-j4 OS=debian DIST=stretch DOCKER_REPO=iconzm/packpack - SMPFLAGS=-j4 OS=debian DIST=buster DOCKER_REPO=iconzm/packpack - - SMPFLAGS=-j4 OS=eslint DIST=eslint compiler: - gcc From a6ae4aee018c21f05aca5fc2dab95a3de03b0ccb Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Sat, 8 Aug 2020 12:26:42 -0500 Subject: [PATCH 05/11] eslint nanny --- web/skins/classic/js/skin.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/skins/classic/js/skin.js b/web/skins/classic/js/skin.js index 5cdd5ece5..db67d7e10 100644 --- a/web/skins/classic/js/skin.js +++ b/web/skins/classic/js/skin.js @@ -340,7 +340,7 @@ if ( currentView != 'none' && currentView != 'login' ) { var flip = $j("#flip"); if ( flip.html() == 'keyboard_arrow_up' ) { flip.html('keyboard_arrow_down'); - Cookie.write('zmHeaderFlip', 'down', {duration: 10*365} ); + Cookie.write('zmHeaderFlip', 'down', {duration: 10*365} ); } else { flip.html('keyboard_arrow_up'); Cookie.write('zmHeaderFlip', 'up', {duration: 10*365} ); @@ -352,7 +352,7 @@ if ( currentView != 'none' && currentView != 'login' ) { var fbflip = $j("#fbflip"); if ( fbflip.html() == 'keyboard_arrow_up' ) { fbflip.html('keyboard_arrow_down'); - Cookie.write('zmFilterBarFlip', 'down', {duration: 10*365} ); + Cookie.write('zmFilterBarFlip', 'down', {duration: 10*365} ); } else { fbflip.html('keyboard_arrow_up'); Cookie.write('zmFilterBarFlip', 'up', {duration: 10*365} ); From 6c831be61fce3338e8d693ec15e7550291a603be Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 8 Aug 2020 14:27:37 -0400 Subject: [PATCH 06/11] remove extra , --- web/includes/session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/includes/session.php b/web/includes/session.php index d34695616..47f85d877 100644 --- a/web/includes/session.php +++ b/web/includes/session.php @@ -16,7 +16,7 @@ function zm_session_start() { $currentCookieParams['path'], $currentCookieParams['domain'], $currentCookieParams['secure'], - $currentCookieParams['httponly'], + $currentCookieParams['httponly'] ); } else { # samesite was introduced in 7.3.0 From b22f12dadb4d6932181f2b4ff9a3cb00a6da8222 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Sun, 9 Aug 2020 12:20:11 -0500 Subject: [PATCH 07/11] rough in new zmversion widget --- web/skins/classic/includes/functions.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index 36798e2f0..2373eecfe 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -564,10 +564,24 @@ function getBandwidthHTML($bandwidth_options, $user) { function getZMVersionHTML() { $result = ''; - $class = (ZM_DYN_DB_VERSION&&(ZM_DYN_DB_VERSION!=ZM_VERSION))?'text-danger':''; - $result .= ''.PHP_EOL; + if ( ZM_DYN_DB_VERSION && (ZM_DYN_DB_VERSION != ZM_VERSION) ) { // Must upgrade before proceeding + $class = 'text-danger'; + $tt_text = translate('RunLocalUpdate'); + } else if ( verNum( ZM_DYN_LAST_VERSION ) <= verNum( ZM_VERSION ) ) { // No update needed + $class = ''; // Don't change the text color under normal conditions + $tt_text = translate('UpdateNotNecessary'); + } else { // An update is available + $class = 'text-warning'; + $tt_text = translate('UpdateAvailable'); + } + +// +// TO-DO: Click to open an overlay, which allows the administrator to delay the next update notice +// + + $result .= ''.PHP_EOL; return $result; } From d0e7443a3c5c8b043bb493d453ac314b3334b013 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Sun, 9 Aug 2020 14:18:44 -0500 Subject: [PATCH 08/11] rough in update reminder dropdown --- web/skins/classic/css/base/skin.css | 1 + web/skins/classic/includes/functions.php | 27 ++++++++++++++++++------ web/skins/classic/js/skin.js | 9 ++++++++ 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/web/skins/classic/css/base/skin.css b/web/skins/classic/css/base/skin.css index 5a4907a75..3e9428d41 100644 --- a/web/skins/classic/css/base/skin.css +++ b/web/skins/classic/css/base/skin.css @@ -711,6 +711,7 @@ li.search-choice { } #dropdown_storage, +#dropdown_reminder, #dropdown_bandwidth { background-color:#485460; } diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index 2373eecfe..d8135b627 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -563,24 +563,37 @@ function getBandwidthHTML($bandwidth_options, $user) { // Returns the html representing the version of ZoneMinder function getZMVersionHTML() { $result = ''; + $content = ''; if ( ZM_DYN_DB_VERSION && (ZM_DYN_DB_VERSION != ZM_VERSION) ) { // Must upgrade before proceeding $class = 'text-danger'; $tt_text = translate('RunLocalUpdate'); - } else if ( verNum( ZM_DYN_LAST_VERSION ) <= verNum( ZM_VERSION ) ) { // No update needed + $content = 'v'.ZM_VERSION.PHP_EOL; + } else if ( false ) { // No update needed $class = ''; // Don't change the text color under normal conditions $tt_text = translate('UpdateNotNecessary'); - } else { // An update is available + $content = 'v'.ZM_VERSION.PHP_EOL; + } else if ( canEdit('System') ) { // An update is available and the user is an administrator $class = 'text-warning'; $tt_text = translate('UpdateAvailable'); + $content = 'v' .ZM_VERSION. ''.PHP_EOL; + $content .= ''.PHP_EOL; + } else { // An update is available and the user is NOT an administrator + $class = 'text-warning'; + $tt_text = translate('UpdateAvailable'); + $content = 'v'.ZM_VERSION.PHP_EOL; } -// -// TO-DO: Click to open an overlay, which allows the administrator to delay the next update notice -// - $result .= ''.PHP_EOL; return $result; diff --git a/web/skins/classic/js/skin.js b/web/skins/classic/js/skin.js index db67d7e10..53d74da29 100644 --- a/web/skins/classic/js/skin.js +++ b/web/skins/classic/js/skin.js @@ -334,6 +334,8 @@ if ( currentView != 'none' && currentView != 'login' ) { } // Update zmBandwidth cookie when the user makes a selection from the dropdown bwClickFunction(); + // Update update reminders when the user makes a selection from the dropdown + reminderClickFunction(); // Manage the widget bar minimize chevron $j("#flip").click(function() { $j("#panel").slideToggle("slow"); @@ -655,3 +657,10 @@ function bwClickFunction() { getNavBar(); }); } + +function reminderClickFunction() { + $j("#dropdown_reminder a").click(function() { + var option = $j(this).data('pdsa-dropdown-val'); + $j.getJSON(thisUrl + '?view=version&action=version&option=' + option); + }); +} From 15005a2f1793b445e33c99d42ed66e01e27f9c9e Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Sun, 9 Aug 2020 14:25:11 -0500 Subject: [PATCH 09/11] fix typo --- web/skins/classic/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index d8135b627..0d038316e 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -569,7 +569,7 @@ function getZMVersionHTML() { $class = 'text-danger'; $tt_text = translate('RunLocalUpdate'); $content = 'v'.ZM_VERSION.PHP_EOL; - } else if ( false ) { // No update needed + } else if ( verNum( ZM_DYN_LAST_VERSION ) <= verNum( ZM_VERSION ) ) { // No update needed $class = ''; // Don't change the text color under normal conditions $tt_text = translate('UpdateNotNecessary'); $content = 'v'.ZM_VERSION.PHP_EOL; From 9a03a2c7d4d62c0042766e8d7e3ca77a2a116335 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Sun, 9 Aug 2020 17:43:07 -0500 Subject: [PATCH 10/11] Update skin.js --- web/skins/classic/js/skin.js | 1 + 1 file changed, 1 insertion(+) diff --git a/web/skins/classic/js/skin.js b/web/skins/classic/js/skin.js index 53d74da29..88986430a 100644 --- a/web/skins/classic/js/skin.js +++ b/web/skins/classic/js/skin.js @@ -662,5 +662,6 @@ function reminderClickFunction() { $j("#dropdown_reminder a").click(function() { var option = $j(this).data('pdsa-dropdown-val'); $j.getJSON(thisUrl + '?view=version&action=version&option=' + option); + window.location.reload(true); //Do a full refresh to update ZM_DYN_LAST_VERSION }); } From 42fe024681b6fb03eb9d58128cda563be3b5b4a7 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Sun, 9 Aug 2020 17:43:39 -0500 Subject: [PATCH 11/11] Update skin.js --- web/skins/classic/js/skin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/js/skin.js b/web/skins/classic/js/skin.js index 88986430a..cf50e1dd8 100644 --- a/web/skins/classic/js/skin.js +++ b/web/skins/classic/js/skin.js @@ -662,6 +662,6 @@ function reminderClickFunction() { $j("#dropdown_reminder a").click(function() { var option = $j(this).data('pdsa-dropdown-val'); $j.getJSON(thisUrl + '?view=version&action=version&option=' + option); - window.location.reload(true); //Do a full refresh to update ZM_DYN_LAST_VERSION + window.location.reload(true); //Do a full refresh to update ZM_DYN_LAST_VERSION }); }