From e3f073b275e4e60e5fd8e6e55cf3d0a1950925aa Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 14 Jan 2017 09:58:36 -0500 Subject: [PATCH 01/11] update to add binary options, dput to ppa and use alternate fork. Also support newer distros and wheezy. --- utils/do_debian_package.sh | 139 ++++++++++++++++++++++++++++--------- 1 file changed, 105 insertions(+), 34 deletions(-) diff --git a/utils/do_debian_package.sh b/utils/do_debian_package.sh index 49c91acfc..3a47704ec 100755 --- a/utils/do_debian_package.sh +++ b/utils/do_debian_package.sh @@ -12,44 +12,78 @@ fi DATE=`date -R` DISTRO=$1 SNAPSHOT=$2 -if [ "$SNAPSHOT" == "stable" ]; then -SNAPSHOT=""; -fi; - TYPE=$3 if [ "$TYPE" == "" ]; then -TYPE="source"; + echo "Defaulting to source build" + TYPE="source"; fi; BRANCH=$4 - - -if [ ! -d 'zoneminder_release' ]; then - git clone https://github.com/ZoneMinder/ZoneMinder.git zoneminder_release +GITHUB_FORK=$5 +if [ "$GITHUB_FORK" == "" ]; then + echo "Defaulting to ZoneMinder upstream git" + GITHUB_FORK="ZoneMinder" fi; -if [ "$BRANCH" != "" ]; then - cd zoneminder_release - if [ "$BRANCH" == "stable" ]; then - BRANCH=$(git describe --tags $(git rev-list --tags --max-count=1)); - echo "Latest stable branch is $BRANCH"; - - fi - git checkout $BRANCH - cd ../ + +if [ "$SNAPSHOT" == "stable" ]; then + if [ "$BRANCH" == "" ]; then + BRANCH=$(git describe --tags $(git rev-list --tags --max-count=1)); + echo "Latest stable branch is $BRANCH"; + fi; +else + if [ "$BRANCH" == "" ]; then + echo "Defaulting to master branch"; + BRANCH="master"; + fi; fi; -VERSION=`cat zoneminder_release/version` + +# Instead of cloning from github each time, if we have a fork lying around, update it and pull from there instead. +if [ ! -d "${GITHUB_FORK}_zoneminder_release" ]; then + if [ -d "${GITHUB_FORK}_ZoneMinder.git" ]; then + echo "Using local clone ${GITHUB_FORK}_ZoneMinder.git to pull from." + cd "${GITHUB_FORK}_ZoneMinder.git" + echo "git checkout $BRANCH" + git checkout $BRANCH + echo "git pull..." + git pull + cd ../ + echo "git clone ${GITHUB_FORK}_ZoneMinder.git ${GITHUB_FORK}_zoneminder_release" + git clone "${GITHUB_FORK}_ZoneMinder.git" "${GITHUB_FORK}_zoneminder_release" + else + echo "git clone https://github.com/$GITHUB_FORK/ZoneMinder.git ${GITHUB_FORK}_zoneminder_release" + git clone "https://github.com/$GITHUB_FORK/ZoneMinder.git" "${GITHUB_FORK}_zoneminder_release" + fi +else + echo "release dir already exists. Please remove it." + exit 0; +fi; + +cd "${GITHUB_FORK}_zoneminder_release" +git checkout $BRANCH +cd ../ + +VERSION=`cat ${GITHUB_FORK}_zoneminder_release/version` if [ $VERSION == "" ]; then exit 1; fi; -echo "Doing $TYPE release zoneminder_$VERSION-$DISTRO-$SNAPSHOT"; -mv zoneminder_release zoneminder_$VERSION-$DISTRO-$SNAPSHOT.orig -cd zoneminder_$VERSION-$DISTRO-$SNAPSHOT.orig +DIRECTORY="zoneminder_$VERSION-$DISTRO"; +if [ "$SNAPSHOT" != "stable" ] && [ "$SNAPSHOT" != "" ]; then + DIRECTORY="$DIRECTORY-$SNAPSHOT"; +fi; +echo "Doing $TYPE release $DIRECTORY"; +mv "${GITHUB_FORK}_zoneminder_release" "$DIRECTORY.orig"; +cd "$DIRECTORY.orig"; + git submodule init git submodule update --init --recursive -if [ $DISTRO == "trusty" ]; then -ln -sf distros/ubuntu1204 debian -else -ln -sf distros/ubuntu1604 debian +if [ $DISTRO == "trusty" ] || [ $DISTRO == "precise" ]; then + ln -sf distros/ubuntu1204 debian +else + if [ $DISTRO == "wheezy" ]; then + ln -sf distros/debian debian + else + ln -sf distros/ubuntu1604 debian + fi; fi; # Auto-install all ZoneMinder's depedencies using the Debian control file @@ -62,14 +96,25 @@ else AUTHOR="`getent passwd $USER | cut -d ':' -f 5 | cut -d ',' -f 1` <`whoami`@`hostname`>" fi +if [ "$SNAPSHOT" == "stable" ]; then +cat < debian/changelog +zoneminder ($VERSION-$DISTRO) $DISTRO; urgency=medium + + * Release $VERSION + + -- $AUTHOR $DATE + +EOF +else cat < debian/changelog zoneminder ($VERSION-$DISTRO-$SNAPSHOT) $DISTRO; urgency=medium * - -- $AUTHOR $DATE + -- $AUTHOR $DATE EOF +fi; #rm -rf .git #rm .gitignore #cd ../ @@ -78,18 +123,44 @@ EOF if [ $TYPE == "binary" ]; then debuild else - if [ $TYPE == "local" ]; then - debuild -i -us -uc -b - else - debuild -S -sa - fi; + if [ $TYPE == "local" ]; then + debuild -i -us -uc -b + else + debuild -S -sa + fi; fi; cd ../ - read -p "Do you want to keep the checked out version of Zoneminder (incase you want to modify it later) [y/N]" -[[ $REPLY == [yY] ]] && { mv zoneminder_$VERSION-$DISTRO-$SNAPSHOT.orig zoneminder_release; echo "The checked out copy is preserved in zoneminder_release"; } || { rm -fr zoneminder_$VERSION-$DISTRO-$SNAPSHOT.orig; echo "The checked out copy has been deleted"; } +[[ $REPLY == [yY] ]] && { mv $DIRECTORY zoneminder_release; echo "The checked out copy is preserved in zoneminder_release"; } || { rm -fr $DIRECTORY; echo "The checked out copy has been deleted"; } echo "Done!" +if [ $TYPE == "binary" ]; then + echo "Not doing dput since it's a binary release. Do you want to install it? (Y/N)" + read install + if [ "$install" == "Y" ]; then + sudo dpkg -i $DIRECTORY*.deb + fi; +else + SC=""; + PPA=""; + if [ "$SNAPSHOT" == "stable" ]; then + PPA="ppa:iconnor/zoneminder"; + SC="zoneminder_${VERSION}-${DISTRO}_source.changes"; + else + SC="zoneminder_${VERSION}-${DISTRO}-${SNAPSHOT}_source.changes"; + if [ "$BRANCH" == "" ]; then + PPA="ppa:iconnor/zoneminder-master"; + else + PPA="ppa:iconnor/zoneminder-$BRANCH"; + fi; + fi; + + echo "Ready to dput $SC to $PPA ? Y/N..."; + read dput + if [ "$dput" == "Y" -o "$dput" == "y" ]; then + dput $PPA $SC + fi; +fi; From b8dcebadd5f6faa53e118f3f88ce4cad4f89c0af Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 14 Jan 2017 10:01:55 -0500 Subject: [PATCH 02/11] remove iconnor references --- utils/do_debian_package.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/do_debian_package.sh b/utils/do_debian_package.sh index 3a47704ec..5eba828c6 100755 --- a/utils/do_debian_package.sh +++ b/utils/do_debian_package.sh @@ -102,7 +102,7 @@ zoneminder ($VERSION-$DISTRO) $DISTRO; urgency=medium * Release $VERSION - -- $AUTHOR $DATE + -- $AUTHOR $DATE EOF else @@ -111,7 +111,7 @@ zoneminder ($VERSION-$DISTRO-$SNAPSHOT) $DISTRO; urgency=medium * - -- $AUTHOR $DATE + -- $AUTHOR $DATE EOF fi; From d7f81393a8ad07f0c146d8e63a82914e17348a0c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 14 Jan 2017 10:53:05 -0500 Subject: [PATCH 03/11] fixes to detect and use environment variables for AUTHOR and debsign keys --- utils/do_debian_package.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/utils/do_debian_package.sh b/utils/do_debian_package.sh index 5eba828c6..ae2fff45f 100755 --- a/utils/do_debian_package.sh +++ b/utils/do_debian_package.sh @@ -90,10 +90,14 @@ fi; sudo apt-get install devscripts equivs sudo mk-build-deps -ir ./debian/control -if [ -z `hostname -d` ] ; then - AUTHOR="`getent passwd $USER | cut -d ':' -f 5 | cut -d ',' -f 1` <`whoami`@`hostname`.local>" +if [ "$DEBEMAIL" != "" ] && [ "$DEBFULLNAME" != "" ]; then + AUTHOR="$DEBFULLNAME <$DEBEMAIL>" else - AUTHOR="`getent passwd $USER | cut -d ':' -f 5 | cut -d ',' -f 1` <`whoami`@`hostname`>" + if [ -z `hostname -d` ] ; then + AUTHOR="`getent passwd $USER | cut -d ':' -f 5 | cut -d ',' -f 1` <`whoami`@`hostname`.local>" + else + AUTHOR="`getent passwd $USER | cut -d ':' -f 5 | cut -d ',' -f 1` <`whoami`@`hostname`>" + fi fi if [ "$SNAPSHOT" == "stable" ]; then @@ -121,14 +125,18 @@ fi; #tar zcf zoneminder_$VERSION-$DISTRO.orig.tar.gz zoneminder_$VERSION-$DISTRO-$SNAPSHOT.orig #cd zoneminder_$VERSION-$DISTRO-$SNAPSHOT.orig if [ $TYPE == "binary" ]; then - debuild + DEBUILD=debuild else if [ $TYPE == "local" ]; then - debuild -i -us -uc -b + DEBUILD="debuild -i -us -uc -b" else - debuild -S -sa + DEBUILD="debuild -S -sa" fi; fi; +if [ "$DEBSIGN_KEYID" != "" ]; then + DEBUILD="$DEBUILD -k$DEBSIGN_KEYID" +fi +$DEBUILD cd ../ read -p "Do you want to keep the checked out version of Zoneminder (incase you want to modify it later) [y/N]" From a30af05bcf17ce4d0fd95b72588b2c73725ffd2a Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 15 Jan 2017 12:18:51 -0500 Subject: [PATCH 04/11] change parameters to use -o= or --option= and add interactive flag --- utils/do_debian_package.sh | 69 +++++++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 15 deletions(-) diff --git a/utils/do_debian_package.sh b/utils/do_debian_package.sh index ae2fff45f..46436d2a2 100755 --- a/utils/do_debian_package.sh +++ b/utils/do_debian_package.sh @@ -8,18 +8,48 @@ exit; fi +for i in "$@" +do +case $i in + -b=*|--branch=*) + BRANCH="${i#*=}" + shift # past argument=value + ;; + -d=*|--distro=*) + DISTRO="${i#*=}" + shift # past argument=value + ;; + -i=*|--interactive=*) + INTERACTIVE="${i#*=}" + shift # past argument=value + ;; + -s=*|--snapshot=*) + SNAPSHOT="${i#*=}" + shift # past argument=value + ;; + -t=*|--type=*) + TYPE="${i#*=}" + shift # past argument=value + ;; + -f=*|--fork=*) + GITHUB_FORK="${i#*=}" + shift # past argument=value + ;; + --default) + DEFAULT=YES + shift # past argument with no value + ;; + *) + # unknown option + ;; +esac +done DATE=`date -R` -DISTRO=$1 -SNAPSHOT=$2 - -TYPE=$3 if [ "$TYPE" == "" ]; then echo "Defaulting to source build" TYPE="source"; fi; -BRANCH=$4 -GITHUB_FORK=$5 if [ "$GITHUB_FORK" == "" ]; then echo "Defaulting to ZoneMinder upstream git" GITHUB_FORK="ZoneMinder" @@ -139,15 +169,21 @@ fi $DEBUILD cd ../ -read -p "Do you want to keep the checked out version of Zoneminder (incase you want to modify it later) [y/N]" -[[ $REPLY == [yY] ]] && { mv $DIRECTORY zoneminder_release; echo "The checked out copy is preserved in zoneminder_release"; } || { rm -fr $DIRECTORY; echo "The checked out copy has been deleted"; } -echo "Done!" +if [ "$INTERACTIVE" != "no" ]; then + read -p "Do you want to keep the checked out version of Zoneminder (incase you want to modify it later) [y/N]" + [[ $REPLY == [yY] ]] && { mv $DIRECTORY zoneminder_release; echo "The checked out copy is preserved in zoneminder_release"; } || { rm -fr $DIRECTORY; echo "The checked out copy has been deleted"; } + echo "Done!" +else + rm -fr $DIRECTORY; echo "The checked out copy has been deleted"; +fi if [ $TYPE == "binary" ]; then - echo "Not doing dput since it's a binary release. Do you want to install it? (Y/N)" - read install - if [ "$install" == "Y" ]; then - sudo dpkg -i $DIRECTORY*.deb + if [ "$INTERACTIVE" != "no" ]; then + echo "Not doing dput since it's a binary release. Do you want to install it? (Y/N)" + read install + if [ "$install" == "Y" ]; then + sudo dpkg -i $DIRECTORY*.deb + fi; fi; else SC=""; @@ -164,8 +200,11 @@ else fi; fi; - echo "Ready to dput $SC to $PPA ? Y/N..."; - read dput + dput="Y"; + if [ "$INTERACTIVE" != "no" ]; then + echo "Ready to dput $SC to $PPA ? Y/N..."; + read dput + fi if [ "$dput" == "Y" -o "$dput" == "y" ]; then dput $PPA $SC fi; From 0e8d1baebbc016a50cc583672942eb6f7e771218 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 16 Jan 2017 21:13:56 -0500 Subject: [PATCH 05/11] add an urgency flag --- utils/do_debian_package.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/utils/do_debian_package.sh b/utils/do_debian_package.sh index 46436d2a2..bc836788f 100755 --- a/utils/do_debian_package.sh +++ b/utils/do_debian_package.sh @@ -31,6 +31,10 @@ case $i in TYPE="${i#*=}" shift # past argument=value ;; + -u=*|--urgency=*) + URGENCY="${i#*=}" + shift # past argument=value + ;; -f=*|--fork=*) GITHUB_FORK="${i#*=}" shift # past argument=value @@ -66,6 +70,10 @@ else BRANCH="master"; fi; fi; +if [ "$URGENCY" = "" ]; then + URGENCY="medium" +fi; + # Instead of cloning from github each time, if we have a fork lying around, update it and pull from there instead. if [ ! -d "${GITHUB_FORK}_zoneminder_release" ]; then @@ -132,7 +140,7 @@ fi if [ "$SNAPSHOT" == "stable" ]; then cat < debian/changelog -zoneminder ($VERSION-$DISTRO) $DISTRO; urgency=medium +zoneminder ($VERSION-$DISTRO) $DISTRO; urgency=$URGENCY * Release $VERSION @@ -141,7 +149,7 @@ zoneminder ($VERSION-$DISTRO) $DISTRO; urgency=medium EOF else cat < debian/changelog -zoneminder ($VERSION-$DISTRO-$SNAPSHOT) $DISTRO; urgency=medium +zoneminder ($VERSION-$DISTRO-$SNAPSHOT) $DISTRO; urgency=$URGENCY * From c7955cd1b6abea504d793b5f6d2acc4c5e703b6e Mon Sep 17 00:00:00 2001 From: Matthew Noorenberghe Date: Sat, 18 Mar 2017 00:00:51 -0700 Subject: [PATCH 06/11] Add eslint configuration files extending Google's rules --- .eslintignore | 4 +++ .eslintrc.js | 29 ++++++++++++++++ web/js/logger.js | 4 +-- web/js/overlay.js | 4 +-- web/skins/classic/js/classic.js | 2 +- web/skins/classic/js/dark.js | 2 +- web/skins/classic/js/flat.js | 2 +- web/skins/classic/js/skin.js | 8 ++--- web/skins/classic/views/js/console.js | 27 +++++++-------- web/skins/classic/views/js/control.js | 4 +-- web/skins/classic/views/js/controlcap.js | 1 - web/skins/classic/views/js/event.js | 20 +++++------ web/skins/classic/views/js/group.js | 1 - web/skins/classic/views/js/log.js | 30 ++++++++-------- web/skins/classic/views/js/montage.js | 15 ++++---- web/skins/classic/views/js/onvifprobe.js | 2 +- web/skins/classic/views/js/state.js | 4 +-- web/skins/classic/views/js/timeline.js | 4 +-- web/skins/classic/views/js/watch.js | 44 ++++++++++++------------ web/skins/classic/views/js/zone.js | 23 ++++++------- 20 files changed, 128 insertions(+), 102 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc.js diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..682db9004 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,4 @@ +web/api/lib +web/skins/classic/js/jquery-1.11.3.js +web/skins/classic/js/jquery.js +web/tools/mootools diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 000000000..fa4d6b6e5 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,29 @@ +"use strict"; + +module.exports = { + "env": { + "browser": true, + }, + "extends": ["google"], + "rules": { + "brace-style": "off", + "camelcase": "off", + "comma-dangle": "off", + "key-spacing": "off", + "max-len": "off", + "new-cap": ["error", { + capIsNewExceptions: ["Error", "Warning", "Debug", "Polygon_calcArea", "Play", "Stop"], + newIsCapExceptionPattern: "^Asset\.." + }], + "no-array-constructor": "off", + "no-caller": "off", + "no-new-object": "off", + "no-unused-vars": "off", + "no-var": "off", + "object-curly-spacing": "off", + "prefer-rest-params": "off", + "quotes": "off", + "require-jsdoc": "off", + "spaced-comment": "off", + }, +}; diff --git a/web/js/logger.js b/web/js/logger.js index c4e072541..9cbe50268 100644 --- a/web/js/logger.js +++ b/web/js/logger.js @@ -46,7 +46,7 @@ function logReport( level, message, file, line ) return; if ( arguments && arguments.callee && arguments.callee.caller && arguments.callee.caller.name ) - message += ' - '+arguments.callee.caller.caller.name+'()'; + message += ' - '+arguments.callee.caller.caller.name+'()'; if ( !debugReq ) { @@ -115,4 +115,4 @@ window.onerror = function( message, url, line ) { logReport( "ERR", message, url, line ); - } + }; diff --git a/web/js/overlay.js b/web/js/overlay.js index 74423e7ef..9738487b0 100644 --- a/web/js/overlay.js +++ b/web/js/overlay.js @@ -84,7 +84,7 @@ var Overlay = new Class({ showAnimation:function() { showOverlay(); - + //console.log( "Showing overlay loading" ); if ( !this.loading ) { @@ -116,7 +116,7 @@ function setupOverlays() overlay.getElements('.overlayCloser').each( function( closer ) { - closer.addEvent( 'click', function() { overlay.element.hide(); } ) + closer.addEvent( 'click', function() { overlay.element.hide(); } ); } ); overlay.overlayShow = function() { overlay.element.show(); }; diff --git a/web/skins/classic/js/classic.js b/web/skins/classic/js/classic.js index 33061eee5..938b05224 100644 --- a/web/skins/classic/js/classic.js +++ b/web/skins/classic/js/classic.js @@ -33,7 +33,7 @@ var popupSizes = { 'device': { 'width': 260, 'height': 150 }, 'devices': { 'width': 400, 'height': 240 }, 'donate': { 'width': 500, 'height': 280 }, - 'event': { 'addWidth': 108, 'minWidth': 496, 'addHeight': 230, minHeight: 540 }, + 'event': { 'addWidth': 108, 'minWidth': 496, 'addHeight': 230, 'minHeight': 540 }, 'eventdetail': { 'width': 600, 'height': 220 }, 'events': { 'width': 960, 'height': 780 }, 'export': { 'width': 400, 'height': 340 }, diff --git a/web/skins/classic/js/dark.js b/web/skins/classic/js/dark.js index 4331ddddd..37e3889c0 100644 --- a/web/skins/classic/js/dark.js +++ b/web/skins/classic/js/dark.js @@ -33,7 +33,7 @@ var popupSizes = { 'device': { 'width': 260, 'height': 150 }, 'devices': { 'width': 400, 'height': 240 }, 'donate': { 'width': 500, 'height': 280 }, - 'event': { 'addWidth': 108, 'minWidth': 496, 'addHeight': 230, minHeight: 540 }, + 'event': { 'addWidth': 108, 'minWidth': 496, 'addHeight': 230, 'minHeight': 540 }, 'eventdetail': { 'width': 600, 'height': 220 }, 'events': { 'width': 960, 'height': 780 }, 'export': { 'width': 400, 'height': 340 }, diff --git a/web/skins/classic/js/flat.js b/web/skins/classic/js/flat.js index 5e878a8b5..ab6cdda83 100644 --- a/web/skins/classic/js/flat.js +++ b/web/skins/classic/js/flat.js @@ -33,7 +33,7 @@ var popupSizes = { 'device': { 'width': 260, 'height': 150 }, 'devices': { 'width': 400, 'height': 240 }, 'donate': { 'width': 500, 'height': 280 }, - 'event': { 'addWidth': 108, 'minWidth': 496, 'addHeight': 230, minHeight: 540 }, + 'event': { 'addWidth': 108, 'minWidth': 496, 'addHeight': 230, 'minHeight': 540 }, 'eventdetail': { 'width': 600, 'height': 220 }, 'events': { 'width': 1080, 'height': 780 }, 'export': { 'width': 400, 'height': 340 }, diff --git a/web/skins/classic/js/skin.js b/web/skins/classic/js/skin.js index 859b34fcd..545f309af 100644 --- a/web/skins/classic/js/skin.js +++ b/web/skins/classic/js/skin.js @@ -31,11 +31,11 @@ function checkSize() { var h = window.outerHeight; var prevH = h; if (h > screen.availHeight) - h = screen.availHeight; + h = screen.availHeight; if (w > screen.availWidth) - w = screen.availWidth; + w = screen.availWidth; if (w != prevW || h != prevH) - window.resizeTo(w,h); + window.resizeTo(w, h); } } @@ -56,7 +56,7 @@ function getPopupSize( tag, width, height ) if ( popupSize.width && popupSize.height ) { if ( width || height ) - Warning( "Ignoring passed dimensions "+width+"x"+height+" when getting popup size for tag '"+tag+"'" ); + Warning( "Ignoring passed dimensions "+width+"x"+height+" when getting popup size for tag '"+tag+"'" ); return( popupSize ); } if ( popupSize.addWidth ) diff --git a/web/skins/classic/views/js/console.js b/web/skins/classic/views/js/console.js index 99f175c23..5321fdded 100644 --- a/web/skins/classic/views/js/console.js +++ b/web/skins/classic/views/js/console.js @@ -25,15 +25,14 @@ function setButtonStates( element ) function addMonitor( element) { - - var form = element.form; - var dupParam; - var monitorId=-1; - if (form.addBtn.value == jsTranslatedCloneText) + var form = element.form; + var dupParam; + var monitorId=-1; + if (form.addBtn.value == jsTranslatedCloneText) { - // get the value of the first checkbox - for ( var i = 0; i < form.elements.length; i++ ) - { + // get the value of the first checkbox + for ( var i = 0; i < form.elements.length; i++ ) + { if ( form.elements[i].type == "checkbox" ) { if ( form.elements[i].checked ) @@ -42,10 +41,10 @@ function addMonitor( element) break; } } - } - } - dupParam = (monitorId == -1 ) ? '': '&dupId='+monitorId; - createPopup( '?view=monitor'+dupParam, 'zmMonitor0','monitor' ); + } + } + dupParam = (monitorId == -1 ) ? '': '&dupId='+monitorId; + createPopup( '?view=monitor'+dupParam, 'zmMonitor0', 'monitor' ); } function editMonitor( element ) @@ -85,8 +84,8 @@ function reloadWindow() function initPage() { - jsTranslatedAddText = translatedAddText; - jsTranslatedCloneText = translatedCloneText; + jsTranslatedAddText = translatedAddText; + jsTranslatedCloneText = translatedCloneText; reloadWindow.periodical( consoleRefreshTimeout ); if ( showVersionPopup ) createPopup( '?view=version', 'zmVersion', 'version' ); diff --git a/web/skins/classic/views/js/control.js b/web/skins/classic/views/js/control.js index 819f088d8..3b095c624 100644 --- a/web/skins/classic/views/js/control.js +++ b/web/skins/classic/views/js/control.js @@ -26,7 +26,7 @@ function controlCmd( control, event, xtell, ytell ) var x = xEvent.page.x - l; var y = xEvent.page.y - t; - if ( xtell ) + if ( xtell ) { var xge = parseInt( (x*100)/coords.width ); if ( xtell == -1 ) @@ -35,7 +35,7 @@ function controlCmd( control, event, xtell, ytell ) xge = 2*(50 - xge); locParms += "&xge="+xge; } - if ( ytell ) + if ( ytell ) { var yge = parseInt( (y*100)/coords.height ); if ( ytell == -1 ) diff --git a/web/skins/classic/views/js/controlcap.js b/web/skins/classic/views/js/controlcap.js index 44e266943..81bbacca0 100644 --- a/web/skins/classic/views/js/controlcap.js +++ b/web/skins/classic/views/js/controlcap.js @@ -19,6 +19,5 @@ function validateForm( form ) { return( false ); } return( true ); - } diff --git a/web/skins/classic/views/js/event.js b/web/skins/classic/views/js/event.js index e1553e6e5..fd480fe1d 100644 --- a/web/skins/classic/views/js/event.js +++ b/web/skins/classic/views/js/event.js @@ -15,7 +15,7 @@ function changeScale() streamScale( scale ); Cookie.write( 'zmEventScale'+eventData.MonitorId, scale, { duration: 10*365 } ); - /*Stream could be an applet so can't use moo tools*/ + /*Stream could be an applet so can't use moo tools*/ var streamImg = document.getElementById('evtStream'); streamImg.style.width = newWidth + "px"; streamImg.style.height = newHeight + "px"; @@ -25,7 +25,7 @@ function changeReplayMode() { var replayMode = $('replayMode').get('value'); - Cookie.write( 'replayMode', replayMode, { duration: 10*365 }) + Cookie.write( 'replayMode', replayMode, { duration: 10*365 }); refreshWindow(); } @@ -38,7 +38,7 @@ var lastEventId = 0; function getCmdResponse( respObj, respText ) { - if ( checkStreamForErrors( "getCmdResponse" ,respObj ) ) + if ( checkStreamForErrors( "getCmdResponse", respObj ) ) return; if ( streamCmdTimer ) @@ -58,7 +58,7 @@ function getCmdResponse( respObj, respText ) $('rate').addClass( 'hidden' ); streamPause( false ); } - else + else { $('modeValue').set( 'text', "Replay" ); $('rateValue').set( 'text', streamStatus.rate ); @@ -198,9 +198,9 @@ function streamSeek( offset ) } function streamQuery() -{ +{ streamReq.send( streamParms+"&command="+CMD_QUERY ); -} +} var slider = null; var scroll = null; @@ -438,7 +438,7 @@ function getFrameResponse( respObj, respText ) eventData['frames'] = new Object(); eventData['frames'][frame.FrameId] = frame; - + loadEventThumb( eventData, frame, respObj.loopback=="true" ); } @@ -477,7 +477,7 @@ function checkFrames( eventId, frameId, loadImage ) if ( !$('eventThumb'+fid) ) { var img = new Element( 'img', { 'id': 'eventThumb'+fid, 'src': 'graphics/transparent.gif', 'alt': fid, 'class': 'placeholder' } ); - img.addEvent( 'click', function () { eventData['frames'][fid] = null; checkFrames( eventId, fid ) } ); + img.addEvent( 'click', function() { eventData['frames'][fid] = null; checkFrames( eventId, fid ); } ); frameQuery( eventId, fid, loadImage && (fid == frameId) ); var imgs = $('eventThumbs').getElements( 'img' ); var injected = false; @@ -689,7 +689,7 @@ function drawProgressBar() var offset = parseInt((index*eventData.Length)/$$(cells).length); $(cell).setProperty( 'title', '+'+secsToTime(offset)+'s' ); $(cell).removeEvent( 'click' ); - $(cell).addEvent( 'click', function(){ streamSeek( offset ); } ); + $(cell).addEvent( 'click', function() { streamSeek( offset ); } ); barWidth += $(cell).getCoordinates().width; } ); @@ -730,7 +730,7 @@ function handleClick( event ) var target = event.target; var x = event.page.x - $(target).getLeft(); var y = event.page.y - $(target).getTop(); - + if ( event.shift ) streamPan( x, y ); else diff --git a/web/skins/classic/views/js/group.js b/web/skins/classic/views/js/group.js index c1ab79581..ee3d1a27d 100644 --- a/web/skins/classic/views/js/group.js +++ b/web/skins/classic/views/js/group.js @@ -9,7 +9,6 @@ if ( refreshParent ) } function configureButtons( element ) { - if ( canEditGroups ) { var form = element.form; form.saveBtn.disabled = (element.value == 0); diff --git a/web/skins/classic/views/js/log.js b/web/skins/classic/views/js/log.js index e6f7fa30e..e27db6517 100644 --- a/web/skins/classic/views/js/log.js +++ b/web/skins/classic/views/js/log.js @@ -22,7 +22,7 @@ var logTimeout = maxSampleTime; var firstLoad = true; var initialDisplayLimit = 200; var sortReversed = false; -var filterFields = [ 'Component', 'ServerId', 'Pid', 'Level', 'File', 'Line']; +var filterFields = ['Component', 'ServerId', 'Pid', 'Level', 'File', 'Line']; var options = {}; function buildFetchParms( parms ) @@ -68,7 +68,7 @@ function logResponse( respObj ) maxLogTime = log.TimeKey; if ( !minLogTime || log.TimeKey < minLogTime ) minLogTime = log.TimeKey; - var row = logTable.push( [ { content: log.DateTime, properties: { style: 'white-space: nowrap' }}, log.Component, log.Server, log.Pid, log.Code, log.Message, log.File, log.Line ] ); + var row = logTable.push( [{ content: log.DateTime, properties: { style: 'white-space: nowrap' }}, log.Component, log.Server, log.Pid, log.Code, log.Message, log.File, log.Line] ); delete log.Message; row.tr.store( 'log', log ); if ( log.Level <= -3 ) @@ -81,7 +81,7 @@ function logResponse( respObj ) row.tr.addClass( 'log-dbg' ); if ( !firstLoad ) { - var color = document.defaultView.getComputedStyle(row.tr,null).getPropertyValue('color'); + var color = document.defaultView.getComputedStyle(row.tr, null).getPropertyValue('color'); var colorParts = color.match(/^rgb.*\((\d+),\s*(\d+),\s*(\d+)/); rowOrigColor = '#' + parseInt(colorParts[1]).toString(16) + parseInt(colorParts[2]).toString(16) + parseInt(colorParts[3]).toString(16); new Fx.Tween( row.tr, { duration: 10000, transition: Fx.Transitions.Sine } ).start( 'color', '#6495ED', rowOrigColor ); @@ -90,15 +90,15 @@ function logResponse( respObj ) ); options = respObj.options; updateFilterSelectors(); - $('lastUpdate').set('text',respObj.updated); - $('logState').set('text',respObj.state); + $('lastUpdate').set('text', respObj.updated); + $('logState').set('text', respObj.state); $('logState').removeClass('ok'); $('logState').removeClass('alert'); $('logState').removeClass('alarm'); $('logState').addClass(respObj.state); - $('totalLogs').set('text',respObj.total); - $('availLogs').set('text',respObj.available); - $('displayLogs').set('text',logCount); + $('totalLogs').set('text', respObj.total); + $('availLogs').set('text', respObj.available); + $('displayLogs').set('text', logCount); if ( firstLoad ) { if ( logCount < displayLimit ) @@ -123,7 +123,7 @@ function logResponse( respObj ) } } logTimer = fetchNextLogs.delay( logTimeout ); -} +} function refreshLog() { @@ -151,7 +151,7 @@ function clearLog() logCount = 0; logTimeout = maxSampleTime; displayLimit = initialDisplayLimit; - $('displayLogs').set('text',logCount); + $('displayLogs').set('text', logCount); options = {}; logTable.empty(); } @@ -265,12 +265,12 @@ function updateFilterSelectors() selector.options[selector.options.length] = new Option( value, label ); } ); - } + } else if ( key == 'ServerId' ) { Object.each(values, function( value, label ) - { + { selector.options[selector.options.length] = new Option( value, label ); } ); @@ -285,7 +285,7 @@ function updateFilterSelectors() ); } if ( filter[key] ) - selector.set('value',filter[key]); + selector.set('value', filter[key]); } ); } @@ -315,13 +315,13 @@ function initPage() if ( sortReversed ) startIndex = displayLimit; else - startIndex = 0;; + startIndex = 0; for ( var i = startIndex; logCount > displayLimit; i++ ) { rows[i].destroy(); logCount--; } - $('displayLogs').set('text',logCount); + $('displayLogs').set('text', logCount); } } ); diff --git a/web/skins/classic/views/js/montage.js b/web/skins/classic/views/js/montage.js index a6c459760..dd6c5b5a9 100644 --- a/web/skins/classic/views/js/montage.js +++ b/web/skins/classic/views/js/montage.js @@ -15,7 +15,7 @@ function Monitor( index, monitorData ) this.start = function( delay ) { this.streamCmdTimer = this.streamCmdQuery.delay( delay, this ); - } + }; this.setStateClass = function( element, stateClass ) { @@ -29,7 +29,7 @@ function Monitor( index, monitorData ) element.removeClass( 'idle' ); element.addClass( stateClass ); } - } + }; this.getStreamCmdResponse = function( respObj, respText ) { @@ -58,7 +58,7 @@ function Monitor( index, monitorData ) } this.setStateClass( $('monitor'+this.index), stateClass ); - /*Stream could be an applet so can't use moo tools*/ + /*Stream could be an applet so can't use moo tools*/ stream.className = stateClass; var isAlarmed = ( this.alarmState == STATE_ALARM || this.alarmState == STATE_ALERT ); @@ -93,15 +93,14 @@ function Monitor( index, monitorData ) console.error( respObj.message ); // Try to reload the image stream. if ( stream ) - stream.src = stream.src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) )); - + stream.src = stream.src.replace(/rand=\d+/i, 'rand='+Math.floor((Math.random() * 1000000) )); } var streamCmdTimeout = statusRefreshTimeout; if ( this.alarmState == STATE_ALARM || this.alarmState == STATE_ALERT ) streamCmdTimeout = streamCmdTimeout/5; this.streamCmdTimer = this.streamCmdQuery.delay( streamCmdTimeout, this ); this.lastAlarmState = this.alarmState; - } + }; this.streamCmdQuery = function( resent ) { @@ -109,7 +108,7 @@ function Monitor( index, monitorData ) //console.log( this.connKey+": Resending" ); //this.streamCmdReq.cancel(); this.streamCmdReq.send( this.streamCmdParms+"&command="+CMD_QUERY ); - } + }; this.streamCmdReq = new Request.JSON( { url: this.server_url, method: 'get', timeout: AJAX_TIMEOUT, onSuccess: this.getStreamCmdResponse.bind( this ), onTimeout: this.streamCmdQuery.bind( this, true ), link: 'cancel' } ); @@ -134,7 +133,7 @@ function changeScale() var monitor = monitors[x]; var newWidth = ( monitorData[x].width * scale ) / SCALE_BASE; var newHeight = ( monitorData[x].height * scale ) / SCALE_BASE; - /*Stream could be an applet so can't use moo tools*/ + /*Stream could be an applet so can't use moo tools*/ var streamImg = document.getElementById( 'liveStream'+monitor.id ); streamImg.style.width = newWidth + "px"; streamImg.style.height = newHeight + "px"; diff --git a/web/skins/classic/views/js/onvifprobe.js b/web/skins/classic/views/js/onvifprobe.js index f70765dda..93b2c53e9 100644 --- a/web/skins/classic/views/js/onvifprobe.js +++ b/web/skins/classic/views/js/onvifprobe.js @@ -31,7 +31,7 @@ function configureButtons( element ) if(form.elements.namedItem("nextBtn")) { form.nextBtn.disabled = (form.probe.selectedIndex==0) || (form.username == "") || (form.username == null) || - (form.password == "") || (form.password == null); + (form.password == "") || (form.password == null); } if(form.elements.namedItem("saveBtn")) { form.saveBtn.disabled = (form.probe.selectedIndex==0); diff --git a/web/skins/classic/views/js/state.js b/web/skins/classic/views/js/state.js index 9935eb0db..d5d94a03d 100644 --- a/web/skins/classic/views/js/state.js +++ b/web/skins/classic/views/js/state.js @@ -1,6 +1,5 @@ function checkState( element ) { - var form = element.form; var minIndex = running?2:1; @@ -23,9 +22,8 @@ function checkState( element ) if (element.value.toLowerCase() == 'default' ) { form.saveBtn.disabled = false; - form.deleteBtn.disabled = true; + form.deleteBtn.disabled = true; } - } function saveState( element ) diff --git a/web/skins/classic/views/js/timeline.js b/web/skins/classic/views/js/timeline.js index 89d2ecd34..7400d952c 100644 --- a/web/skins/classic/views/js/timeline.js +++ b/web/skins/classic/views/js/timeline.js @@ -114,10 +114,10 @@ function loadEventImage( imagePath, eid, fid, width, height ) var imageSrc = $('imageSrc'); imageSrc.setProperty( 'src', imagePrefix+imagePath ); imageSrc.removeEvent( 'click' ); - imageSrc.addEvent( 'click', showEvent.pass( [ eid, fid, width, height ] ) ); + imageSrc.addEvent( 'click', showEvent.pass( [eid, fid, width, height] ) ); var eventData = $('eventData'); eventData.removeEvent( 'click' ); - eventData.addEvent( 'click', showEvent.pass( [ eid, fid, width, height ] ) ); + eventData.addEvent( 'click', showEvent.pass( [eid, fid, width, height] ) ); } function tlZoomBounds( minTime, maxTime ) diff --git a/web/skins/classic/views/js/watch.js b/web/skins/classic/views/js/watch.js index 9b3b7ea21..d7fd496cb 100644 --- a/web/skins/classic/views/js/watch.js +++ b/web/skins/classic/views/js/watch.js @@ -34,13 +34,13 @@ function changeScale() Cookie.write( 'zmWatchScale'+monitorId, scale, { duration: 10*365 } ); - /*Stream could be an applet so can't use moo tools*/ + /*Stream could be an applet so can't use moo tools*/ var streamImg = document.getElementById('liveStream'); if ( streamImg ) { streamImg.style.width = newWidth + "px"; streamImg.style.height = newHeight + "px"; - streamImg.src = streamImg.src.replace(/scale=\d+/i,'scale='+scale); + streamImg.src = streamImg.src.replace(/scale=\d+/i, 'scale='+scale); } else { console.error("No element found for liveStream."); } @@ -168,7 +168,7 @@ function getStreamCmdResponse( respObj, respText ) streamCmdFastRev( false ); } } - else + else { $('modeValue').set( 'text', "Live" ); $('rate').addClass( 'hidden' ); @@ -210,18 +210,18 @@ function getStreamCmdResponse( respObj, respText ) } } else { - checkStreamForErrors("getStreamCmdResponse",respObj);//log them + checkStreamForErrors("getStreamCmdResponse", respObj);//log them // Try to reload the image stream. var streamImg = document.getElementById('liveStream'); if ( streamImg ) - streamImg.src = streamImg.src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) )); + streamImg.src = streamImg.src.replace(/rand=\d+/i, 'rand='+Math.floor((Math.random() * 1000000) )); } var streamCmdTimeout = statusRefreshTimeout; if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT ) streamCmdTimeout = streamCmdTimeout/5; streamCmdTimer = streamCmdQuery.delay( streamCmdTimeout ); -} +} function streamCmdPause( action ) { @@ -354,7 +354,7 @@ function streamCmdPan( x, y ) function streamCmdQuery() { streamCmdReq.send( streamCmdParms+"&command="+CMD_QUERY ); -} +} var statusCmdParms = "view=request&request=status&entity=monitor&id="+monitorId+"&element[]=Status&element[]=FrameRate"; var statusCmdReq = new Request.JSON( { url: monitorUrl+thisUrl, method: 'post', data: statusCmdParms, timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getStatusCmdResponse } ); @@ -372,18 +372,18 @@ function getStatusCmdResponse( respObj, respText ) setAlarmState( respObj.monitor.Status ); } else - checkStreamForErrors("getStatusCmdResponse",respObj); + checkStreamForErrors("getStatusCmdResponse", respObj); var statusCmdTimeout = statusRefreshTimeout; if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT ) statusCmdTimeout = statusCmdTimeout/5; statusCmdTimer = statusCmdQuery.delay( statusCmdTimeout ); -} +} function statusCmdQuery() { statusCmdReq.send(); -} +} var alarmCmdParms = "view=request&request=alarm&id="+monitorId; var alarmCmdReq = new Request.JSON( { url: monitorUrl+thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getAlarmCmdResponse, onTimeout: streamCmdQuery } ); @@ -391,7 +391,7 @@ var alarmCmdFirst = true; function getAlarmCmdResponse( respObj, respText ) { - checkStreamForErrors("getAlarmCmdResponse",respObj); + checkStreamForErrors("getAlarmCmdResponse", respObj); } function cmdDisableAlarms() @@ -477,26 +477,26 @@ function getEventCmdResponse( respObj, respText ) var cells = row.getElements( 'td' ); - var link = new Element( 'a', { 'href': '#', 'events': { 'click': createEventPopup.pass( [ event.Id, '&trms=1&attr1=MonitorId&op1=%3d&val1='+monitorId+'&page=1', event.Width, event.Height ] ) } }); + var link = new Element( 'a', { 'href': '#', 'events': { 'click': createEventPopup.pass( [event.Id, '&trms=1&attr1=MonitorId&op1=%3d&val1='+monitorId+'&page=1', event.Width, event.Height] ) } }); link.set( 'text', event.Id ); link.inject( row.getElement( 'td.colId' ) ); - link = new Element( 'a', { 'href': '#', 'events': { 'click': createEventPopup.pass( [ event.Id, '&trms=1&attr1=MonitorId&op1=%3d&val1='+monitorId+'&page=1', event.Width, event.Height ] ) } }); + link = new Element( 'a', { 'href': '#', 'events': { 'click': createEventPopup.pass( [event.Id, '&trms=1&attr1=MonitorId&op1=%3d&val1='+monitorId+'&page=1', event.Width, event.Height] ) } }); link.set( 'text', event.Name ); link.inject( row.getElement( 'td.colName' ) ); row.getElement( 'td.colTime' ).set( 'text', event.StartTime ); row.getElement( 'td.colSecs' ).set( 'text', event.Length ); - link = new Element( 'a', { 'href': '#', 'events': { 'click': createFramesPopup.pass( [ event.Id, event.Width, event.Height ] ) } }); + link = new Element( 'a', { 'href': '#', 'events': { 'click': createFramesPopup.pass( [event.Id, event.Width, event.Height] ) } }); link.set( 'text', event.Frames+'/'+event.AlarmFrames ); link.inject( row.getElement( 'td.colFrames' ) ); - link = new Element( 'a', { 'href': '#', 'events': { 'click': createFramePopup.pass( [ event.Id, '0', event.Width, event.Height ] ) } }); + link = new Element( 'a', { 'href': '#', 'events': { 'click': createFramePopup.pass( [event.Id, '0', event.Width, event.Height] ) } }); link.set( 'text', event.AvgScore+'/'+event.MaxScore ); link.inject( row.getElement( 'td.colScore' ) ); - link = new Element( 'a', { 'href': '#', 'title': deleteString, 'events': { 'click': function( e ) { deleteEvent( e, event.Id ); }.bind( link ), 'mouseover': highlightRow.pass( row ), 'mouseout': highlightRow.pass( row ) } }); + link = new Element( 'a', { 'href': '#', 'title': deleteString, 'events': { 'click': function( e ) { deleteEvent( e, event.Id ); }, 'mouseover': highlightRow.pass( row ), 'mouseout': highlightRow.pass( row ) } }); link.set( 'text', 'X' ); link.inject( row.getElement( 'td.colDelete' ) ); @@ -537,7 +537,7 @@ function getEventCmdResponse( respObj, respText ) } } else - checkStreamForErrors("getEventCmdResponse",respObj); + checkStreamForErrors("getEventCmdResponse", respObj); var eventCmdTimeout = eventsRefreshTimeout; if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT ) @@ -581,7 +581,7 @@ function controlCmd( control, event, xtell, ytell ) var x = xEvent.page.x - l; var y = xEvent.page.y - t; - if ( xtell ) + if ( xtell ) { var xge = parseInt( (x*100)/coords.width ); if ( xtell == -1 ) @@ -590,7 +590,7 @@ function controlCmd( control, event, xtell, ytell ) xge = 2*(50 - xge); locParms += "&xge="+xge; } - if ( ytell ) + if ( ytell ) { var yge = parseInt( (y*100)/coords.height ); if ( ytell == -1 ) @@ -614,7 +614,7 @@ function controlCmdImage( x, y ) controlReq.send( imageControlParms+"&x="+x+"&y="+y ); if ( streamMode == "single" ) fetchImage.pass( $('imageFeed').getElement('img') ).delay( 1000 ); -} +} var tempImage = null; function fetchImage( streamImage ) @@ -631,7 +631,7 @@ function handleClick( event ) var target = event.target; var x = event.page.x - $(target).getLeft(); var y = event.page.y - $(target).getTop(); - + if ( showMode == "events" || !imageControlMode ) { if ( event.shift ) @@ -706,7 +706,7 @@ function initPage() streamCmdTimer = streamCmdQuery.delay( (Math.random()+0.1)*statusRefreshTimeout ); watchdogCheck.pass('stream').periodical(statusRefreshTimeout*2); } - + eventCmdTimer = eventCmdQuery.delay( (Math.random()+0.1)*statusRefreshTimeout ); watchdogCheck.pass('event').periodical(eventsRefreshTimeout*2); diff --git a/web/skins/classic/views/js/zone.js b/web/skins/classic/views/js/zone.js index a8e456778..21bad6128 100644 --- a/web/skins/classic/views/js/zone.js +++ b/web/skins/classic/views/js/zone.js @@ -145,7 +145,7 @@ function applyZoneType() form.elements['newZone[MaxAlarmPixels]'].disabled = false; form.elements['newZone[OverloadFrames]'].disabled = false; form.elements['newZone[ExtendAlarmFrames]'].disabled = true; - applyCheckMethod(); + applyCheckMethod(); } } @@ -353,7 +353,7 @@ function updateActivePoint( index ) $('newZone[Points]['+index+'][y]').value = y; zone['Points'][index].x = x; zone['Points'][index].y = y; - var Point = $('zonePoly').points.getItem(index); + var Point = $('zonePoly').points.getItem(index); Point.x =x; Point.y =y; updateArea(); @@ -384,7 +384,7 @@ function delPoint( index ) function limitPointValue( point, loVal, hiVal ) { - point.value = constrainValue(point.value, loVal, hiVal) + point.value = constrainValue(point.value, loVal, hiVal); } function updateArea( ) { @@ -393,7 +393,6 @@ function updateArea( ) { var form = $('zoneForm'); form.elements['newZone[Area]'].value = area; if ( form.elements['newZone[Units]'].value == 'Percent' ) { - form.elements['newZone[TempArea]'].value = Math.round( area/monitorArea*100 ); } else if ( form.elements['newZone[Units]'].value == 'Pixels' ) { form.elements['newZone[TempArea]'].value = area; @@ -411,7 +410,7 @@ function updateX( index ) point.setStyle( 'left', x+'px' ); zone['Points'][index].x = x; - var Point = $('zonePoly').points.getItem(index); + var Point = $('zonePoly').points.getItem(index); Point.x = x; } @@ -424,7 +423,7 @@ function updateY( index ) point.setStyle( 'top', y+'px' ); zone['Points'][index].y = y; - var Point = $('zonePoly').points.getItem(index); + var Point = $('zonePoly').points.getItem(index); Point.y = y; } @@ -568,18 +567,18 @@ function getStreamCmdResponse( respObj, respText ) { streamCmdPlay( false ); } } else { - checkStreamForErrors("getStreamCmdResponse",respObj);//log them + checkStreamForErrors("getStreamCmdResponse", respObj);//log them // Try to reload the image stream. var streamImg = document.getElementById('liveStream'); if ( streamImg ) - streamImg.src = streamImg.src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) )); + streamImg.src = streamImg.src.replace(/rand=\d+/i, 'rand='+Math.floor((Math.random() * 1000000) )); } var streamCmdTimeout = statusRefreshTimeout; if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT ) streamCmdTimeout = streamCmdTimeout/5; streamCmdTimer = streamCmdQuery.delay( streamCmdTimeout ); -} +} var streamPause = false; @@ -613,7 +612,7 @@ function streamCmdStop( action ) { function streamCmdQuery() { streamCmdReq.send( streamCmdParms+"&command="+CMD_QUERY ); -} +} var statusCmdParms = "view=request&request=status&entity=monitor&id="+monitorId+"&element[]=Status&element[]=FrameRate"; var statusCmdReq = new Request.JSON( { url: monitorUrl+thisUrl, method: 'post', data: statusCmdParms, timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getStatusCmdResponse } ); @@ -630,13 +629,13 @@ function getStatusCmdResponse( respObj, respText ) { setAlarmState( respObj.monitor.Status ); } else - checkStreamForErrors("getStatusCmdResponse",respObj); + checkStreamForErrors("getStatusCmdResponse", respObj); var statusCmdTimeout = statusRefreshTimeout; if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT ) statusCmdTimeout = statusCmdTimeout/5; statusCmdTimer = statusCmdQuery.delay( statusCmdTimeout ); -} +} function statusCmdQuery() { statusCmdReq.send(); From c5d2652d1b76011116445acaef2c591bd4842b16 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 24 Apr 2017 16:50:33 -0400 Subject: [PATCH 07/11] add code to specifically handle a release, and package versions --- utils/do_debian_package.sh | 103 ++++++++++++++++++++++++++----------- 1 file changed, 72 insertions(+), 31 deletions(-) diff --git a/utils/do_debian_package.sh b/utils/do_debian_package.sh index bc836788f..194499af2 100755 --- a/utils/do_debian_package.sh +++ b/utils/do_debian_package.sh @@ -23,6 +23,10 @@ case $i in INTERACTIVE="${i#*=}" shift # past argument=value ;; + -r=*|--release=*) + RELEASE="${i#*=}" + shift + ;; -s=*|--snapshot=*) SNAPSHOT="${i#*=}" shift # past argument=value @@ -39,6 +43,10 @@ case $i in GITHUB_FORK="${i#*=}" shift # past argument=value ;; + -v=*|--version=*) + PACKAGE_VERSION="${i#*=}" + shift + ;; --default) DEFAULT=YES shift # past argument with no value @@ -54,25 +62,38 @@ if [ "$TYPE" == "" ]; then echo "Defaulting to source build" TYPE="source"; fi; -if [ "$GITHUB_FORK" == "" ]; then - echo "Defaulting to ZoneMinder upstream git" - GITHUB_FORK="ZoneMinder" -fi; -if [ "$SNAPSHOT" == "stable" ]; then - if [ "$BRANCH" == "" ]; then - BRANCH=$(git describe --tags $(git rev-list --tags --max-count=1)); - echo "Latest stable branch is $BRANCH"; - fi; +# Release is a special mode... it uploads to the release ppa and cannot have a snapshot +if [ "$RELEASE" != "" ]; then + if [ "$SNAPSHOT" != "" ]; then + echo "Releases cannot have a snapshot.... exiting." + exit 0; + fi + if [ "$GITHUB_FORK" != "" ] && [ "$GITHUB_FORK" != "ZoneMinder" ]; then + echo "Releases cannot have a fork ($GITHUB_FORK).... exiting." + exit 0; + fi + BRANCH="release-$RELEASE" else - if [ "$BRANCH" == "" ]; then - echo "Defaulting to master branch"; - BRANCH="master"; + if [ "$GITHUB_FORK" == "" ]; then + echo "Defaulting to ZoneMinder upstream git" + GITHUB_FORK="ZoneMinder" fi; -fi; -if [ "$URGENCY" = "" ]; then - URGENCY="medium" -fi; + if [ "$SNAPSHOT" == "stable" ]; then + if [ "$BRANCH" == "" ]; then + BRANCH=$(git describe --tags $(git rev-list --tags --max-count=1)); + echo "Latest stable branch is $BRANCH"; + fi; + else + if [ "$BRANCH" == "" ]; then + echo "Defaulting to master branch"; + BRANCH="master"; + fi; + if [ "$SNAPSHOT" == "NOW" ]; then + SNAPSHOT=`date +%Y%m%d%H%M%S`; + fi; + fi; +fi # Instead of cloning from github each time, if we have a fork lying around, update it and pull from there instead. @@ -80,6 +101,8 @@ if [ ! -d "${GITHUB_FORK}_zoneminder_release" ]; then if [ -d "${GITHUB_FORK}_ZoneMinder.git" ]; then echo "Using local clone ${GITHUB_FORK}_ZoneMinder.git to pull from." cd "${GITHUB_FORK}_ZoneMinder.git" + echo "git pull..." + git pull echo "git checkout $BRANCH" git checkout $BRANCH echo "git pull..." @@ -97,37 +120,39 @@ else fi; cd "${GITHUB_FORK}_zoneminder_release" -git checkout $BRANCH +if [ $RELEASE ]; then + git checkout $RELEASE +else + git checkout $BRANCH +fi; cd ../ VERSION=`cat ${GITHUB_FORK}_zoneminder_release/version` + if [ $VERSION == "" ]; then exit 1; fi; -DIRECTORY="zoneminder_$VERSION-$DISTRO"; if [ "$SNAPSHOT" != "stable" ] && [ "$SNAPSHOT" != "" ]; then - DIRECTORY="$DIRECTORY-$SNAPSHOT"; + VERSION="$VERSION~$SNAPSHOT"; fi; + +DIRECTORY="zoneminder_$VERSION-$DISTRO${PACKAGE_VERSION}"; echo "Doing $TYPE release $DIRECTORY"; mv "${GITHUB_FORK}_zoneminder_release" "$DIRECTORY.orig"; cd "$DIRECTORY.orig"; git submodule init git submodule update --init --recursive -if [ $DISTRO == "trusty" ] || [ $DISTRO == "precise" ]; then +if [ "$DISTRO" == "trusty" ] || [ "$DISTRO" == "precise" ]; then ln -sf distros/ubuntu1204 debian else - if [ $DISTRO == "wheezy" ]; then + if [ "$DISTRO" == "wheezy" ]; then ln -sf distros/debian debian else ln -sf distros/ubuntu1604 debian fi; fi; -# Auto-install all ZoneMinder's depedencies using the Debian control file -sudo apt-get install devscripts equivs -sudo mk-build-deps -ir ./debian/control - if [ "$DEBEMAIL" != "" ] && [ "$DEBFULLNAME" != "" ]; then AUTHOR="$DEBFULLNAME <$DEBEMAIL>" else @@ -138,9 +163,13 @@ else fi fi +if [ "$URGENCY" = "" ]; then + URGENCY="medium" +fi; + if [ "$SNAPSHOT" == "stable" ]; then cat < debian/changelog -zoneminder ($VERSION-$DISTRO) $DISTRO; urgency=$URGENCY +zoneminder ($VERSION-$DISTRO${PACKAGE_VERSION}) $DISTRO; urgency=$URGENCY * Release $VERSION @@ -149,7 +178,7 @@ zoneminder ($VERSION-$DISTRO) $DISTRO; urgency=$URGENCY EOF else cat < debian/changelog -zoneminder ($VERSION-$DISTRO-$SNAPSHOT) $DISTRO; urgency=$URGENCY +zoneminder ($VERSION-$DISTRO${PACKAGE_VERSION}) $DISTRO; urgency=$URGENCY * @@ -157,6 +186,12 @@ zoneminder ($VERSION-$DISTRO-$SNAPSHOT) $DISTRO; urgency=$URGENCY EOF fi; + +# Auto-install all ZoneMinder's depedencies using the Debian control file +sudo apt-get install devscripts equivs +sudo mk-build-deps -ir ./debian/control +echo "Status: $?" + #rm -rf .git #rm .gitignore #cd ../ @@ -175,6 +210,7 @@ if [ "$DEBSIGN_KEYID" != "" ]; then DEBUILD="$DEBUILD -k$DEBSIGN_KEYID" fi $DEBUILD +echo "Status: $?" cd ../ if [ "$INTERACTIVE" != "no" ]; then @@ -192,15 +228,20 @@ if [ $TYPE == "binary" ]; then if [ "$install" == "Y" ]; then sudo dpkg -i $DIRECTORY*.deb fi; + if [ "$DISTRO" == "jessie" ]; then + echo "Do you want to upload this binary to zmrepo? (y/N)" + read install + if [ "$install" == "Y" ]; then + scp "zoneminder_*-${VERSION}-${DISTRO}*" "zmrepo@zmrepo.connortechnology.com:debian/${BRANCH}/mini-dinstall/incoming/" + fi; + fi; fi; else - SC=""; + SC="zoneminder_${VERSION}-${DISTRO}${PACKAGE_VERSION}_source.changes"; PPA=""; - if [ "$SNAPSHOT" == "stable" ]; then + if [ "$RELEASE" != "" ]; then PPA="ppa:iconnor/zoneminder"; - SC="zoneminder_${VERSION}-${DISTRO}_source.changes"; else - SC="zoneminder_${VERSION}-${DISTRO}-${SNAPSHOT}_source.changes"; if [ "$BRANCH" == "" ]; then PPA="ppa:iconnor/zoneminder-master"; else From 4d851dc00f1f13fcde03db7c24e2ee4d87b5f5e0 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 24 Apr 2017 16:54:01 -0400 Subject: [PATCH 08/11] Add Distribution guessing --- utils/do_debian_package.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils/do_debian_package.sh b/utils/do_debian_package.sh index 194499af2..bc862a48f 100755 --- a/utils/do_debian_package.sh +++ b/utils/do_debian_package.sh @@ -63,6 +63,11 @@ if [ "$TYPE" == "" ]; then TYPE="source"; fi; +if [ "$DISTRO" == "" ]; then + DISTRO=`lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'`; + echo "Guessed distro as $DISTRO"; +fi; + # Release is a special mode... it uploads to the release ppa and cannot have a snapshot if [ "$RELEASE" != "" ]; then if [ "$SNAPSHOT" != "" ]; then From 998aa2199b82d0e6c97c9d943764f4a655b094f9 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 24 Apr 2017 16:55:08 -0400 Subject: [PATCH 09/11] fix message for consistency --- utils/do_debian_package.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/do_debian_package.sh b/utils/do_debian_package.sh index bc862a48f..acc412550 100755 --- a/utils/do_debian_package.sh +++ b/utils/do_debian_package.sh @@ -65,7 +65,7 @@ fi; if [ "$DISTRO" == "" ]; then DISTRO=`lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'`; - echo "Guessed distro as $DISTRO"; + echo "Defaulting to $DISTRO for distribution"; fi; # Release is a special mode... it uploads to the release ppa and cannot have a snapshot From 3dff8a5da5e55361a9558e2b8272f3f03d3b6ad3 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 24 Apr 2017 17:01:24 -0400 Subject: [PATCH 10/11] update doc references to do_debian_package.sh --- docs/installationguide/ubuntu.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/installationguide/ubuntu.rst b/docs/installationguide/ubuntu.rst index 6e7ac45e4..903bf79d4 100644 --- a/docs/installationguide/ubuntu.rst +++ b/docs/installationguide/ubuntu.rst @@ -287,19 +287,19 @@ To build the latest master snapshot: :: - ./do_debian_package.sh `lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'` `date +%Y%m%d`01 local master + ./do_debian_package.sh --snapshot=NOW --branch=master --type=local To build the latest stable release: :: - ./do_debian_package.sh `lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'` `date +%Y%m%d`01 local stable + ./do_debian_package.sh --snapshot=stable --type=local -Note that the ``lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'`` -part simply extracts your distribution name - like "vivid", "trusty" etc. You -can always replace it by your distro name if you know it. As far as the script +Note that the distribution will be guessed using ``lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'`` +which simply extracts your distribution name - like "vivid", "trusty" etc. You +can always specify it using --distro=your distro name if you know it. As far as the script goes, it checks if your distro is "trusty" in which case it pulls in pre-systemd release configurations and if its not "trusty" it assumes its based on systemd and pulls in systemd related config files. @@ -378,4 +378,4 @@ change the $default array to reflect your new details. Example: 'database' => 'zm', 'prefix' => '', //'encoding' => 'utf8', - ); \ No newline at end of file + ); From 3215f2e702b6beaa2d225b9e281bcabf830fecf7 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 9 May 2017 16:57:28 -0400 Subject: [PATCH 11/11] merge latest updates --- utils/do_debian_package.sh | 42 ++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/utils/do_debian_package.sh b/utils/do_debian_package.sh index acc412550..554dd9c38 100755 --- a/utils/do_debian_package.sh +++ b/utils/do_debian_package.sh @@ -52,7 +52,9 @@ case $i in shift # past argument with no value ;; *) - # unknown option + # unknown option + read -p "Unknown option $i, continue? (Y|n)" + [[ $REPLY == [yY] ]] && { echo "continuing..."; } || exit 1; ;; esac done @@ -66,6 +68,8 @@ fi; if [ "$DISTRO" == "" ]; then DISTRO=`lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'`; echo "Defaulting to $DISTRO for distribution"; +else + echo "Building for $DISTRO"; fi; # Release is a special mode... it uploads to the release ppa and cannot have a snapshot @@ -141,7 +145,7 @@ if [ "$SNAPSHOT" != "stable" ] && [ "$SNAPSHOT" != "" ]; then VERSION="$VERSION~$SNAPSHOT"; fi; -DIRECTORY="zoneminder_$VERSION-$DISTRO${PACKAGE_VERSION}"; +DIRECTORY="zoneminder_$VERSION"; echo "Doing $TYPE release $DIRECTORY"; mv "${GITHUB_FORK}_zoneminder_release" "$DIRECTORY.orig"; cd "$DIRECTORY.orig"; @@ -149,12 +153,12 @@ cd "$DIRECTORY.orig"; git submodule init git submodule update --init --recursive if [ "$DISTRO" == "trusty" ] || [ "$DISTRO" == "precise" ]; then - ln -sf distros/ubuntu1204 debian + mv distros/ubuntu1204 debian else if [ "$DISTRO" == "wheezy" ]; then - ln -sf distros/debian debian + mv distros/debian debian else - ln -sf distros/ubuntu1604 debian + mv distros/ubuntu1604 debian fi; fi; @@ -192,20 +196,24 @@ zoneminder ($VERSION-$DISTRO${PACKAGE_VERSION}) $DISTRO; urgency=$URGENCY EOF fi; -# Auto-install all ZoneMinder's depedencies using the Debian control file -sudo apt-get install devscripts equivs -sudo mk-build-deps -ir ./debian/control -echo "Status: $?" +rm -rf .git +rm .gitignore +cd ../ +tar zcf $DIRECTORY.orig.tar.gz $DIRECTORY.orig +cd $DIRECTORY.orig -#rm -rf .git -#rm .gitignore -#cd ../ -#tar zcf zoneminder_$VERSION-$DISTRO.orig.tar.gz zoneminder_$VERSION-$DISTRO-$SNAPSHOT.orig -#cd zoneminder_$VERSION-$DISTRO-$SNAPSHOT.orig if [ $TYPE == "binary" ]; then + # Auto-install all ZoneMinder's depedencies using the Debian control file + sudo apt-get install devscripts equivs + sudo mk-build-deps -ir ./debian/control + echo "Status: $?" DEBUILD=debuild else if [ $TYPE == "local" ]; then + # Auto-install all ZoneMinder's depedencies using the Debian control file + sudo apt-get install devscripts equivs + sudo mk-build-deps -ir ./debian/control + echo "Status: $?" DEBUILD="debuild -i -us -uc -b" else DEBUILD="debuild -S -sa" @@ -215,7 +223,11 @@ if [ "$DEBSIGN_KEYID" != "" ]; then DEBUILD="$DEBUILD -k$DEBSIGN_KEYID" fi $DEBUILD -echo "Status: $?" +if [ $? -ne 0 ]; then +echo "Error status code is: $?" + echo "Build failed."; + exit $?; +fi; cd ../ if [ "$INTERACTIVE" != "no" ]; then