From 9cf31eafa06f5a2c1c12e57110994b1bec9258d0 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 24 Oct 2018 12:43:43 -0400 Subject: [PATCH] Use a button element instead of an anchor tag for plus and minus point buttons. Cleanup dead code --- web/skins/classic/views/js/zone.js | 30 ++++++---- web/skins/classic/views/zone.php | 94 +++++++++++++----------------- 2 files changed, 59 insertions(+), 65 deletions(-) diff --git a/web/skins/classic/views/js/zone.js b/web/skins/classic/views/js/zone.js index 6389e3ce9..094ea54c8 100644 --- a/web/skins/classic/views/js/zone.js +++ b/web/skins/classic/views/js/zone.js @@ -49,9 +49,9 @@ function validateForm( form ) { } if ( errors.length ) { alert( errors.join( "\n" ) ); - return( false ); + return false; } - return( true ); + return true; } function submitForm( form ) { @@ -324,7 +324,7 @@ function limitPointValue( point, loVal, hiVal ) { } function updateArea( ) { - area = Polygon_calcArea( zone['Points'] ); + area = Polygon_calcArea(zone['Points']); zone.Area = area; var form = $('zoneForm'); form.elements['newZone[Area]'].value = area; @@ -333,7 +333,7 @@ function updateArea( ) { } else if ( form.elements['newZone[Units]'].value == 'Pixels' ) { form.elements['newZone[TempArea]'].value = area; } else { - alert("Unknown units: " + form.elements['newZone[Units]'].value ); + alert("Unknown units: " + form.elements['newZone[Units]'].value); } } @@ -368,15 +368,23 @@ function saveChanges( element ) { if ( form.elements['newZone[Type]'].value == 'Privacy' ) { alert( 'Capture process for this monitor will be restarted for the Privacy zone changes to take effect.' ); } - return( true ); + return true; } - return( false ); + return false; } function drawZonePoints() { $('imageFrame').getElements( 'div.zonePoint' ).each( function( element ) { element.destroy(); } ); for ( var i = 0; i < zone['Points'].length; i++ ) { - var div = new Element( 'div', { 'id': 'point'+i, 'class': 'zonePoint', 'title': 'Point '+(i+1), 'styles': { 'left': zone['Points'][i].x, 'top': zone['Points'][i].y } } ); + var div = new Element( 'div', { + 'id': 'point'+i, + 'class': 'zonePoint', + 'title': 'Point '+(i+1), + 'styles': { + 'left': zone['Points'][i].x, + 'top': zone['Points'][i].y + } + } ); div.addEvent( 'mouseover', highlightOn.pass( i ) ); div.addEvent( 'mouseout', highlightOff.pass( i ) ); div.inject( $('imageFrame') ); @@ -410,9 +418,11 @@ function drawZonePoints() { cell.inject( row ); cell = new Element( 'td' ); - new Element( 'a', { 'href': '#', 'events': { 'click': addPoint.pass( i ) } } ).set( 'text', '+' ).inject( cell ); - if ( zone['Points'].length > 3 ) - new Element( 'a', { 'id': 'delete'+i, 'href': '#', 'events': { 'click': delPoint.pass( i ) } } ).set( 'text', '-' ).inject( cell ); + new Element( 'button', { 'type': 'button', 'events': { 'click': addPoint.pass( i ) } } ).set( 'text', '+' ).inject( cell ); + if ( zone['Points'].length > 3 ) { + cell.appendText(' '); + new Element( 'button', { 'id': 'delete'+i, 'type': 'button', 'events': { 'click': delPoint.pass( i ) } } ).set( 'text', '-' ).inject( cell ); + } cell.inject( row ); row.inject( tables[i%tables.length].getElement( 'tbody' ) ); diff --git a/web/skins/classic/views/zone.php b/web/skins/classic/views/zone.php index f6a763c19..0ab5d2770 100644 --- a/web/skins/classic/views/zone.php +++ b/web/skins/classic/views/zone.php @@ -18,9 +18,9 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // -if ( !canView( 'Monitors' ) ) { - $view = 'error'; - return; +if ( !canView('Monitors') ) { + $view = 'error'; + return; } $mid = validInt($_REQUEST['mid']); @@ -62,39 +62,39 @@ $minY = 0; $maxY = $monitor->Height()-1; if ( !isset($newZone) ) { - if ( $zid > 0 ) { - $zone = dbFetchOne( 'SELECT * FROM Zones WHERE MonitorId = ? AND Id=?', NULL, array( $monitor->Id(), $zid ) ); - } else { - $zone = array( - 'Id' => 0, - 'Name' => translate('New'), - 'Type' => 'Active', - 'MonitorId' => $monitor->Id(), - 'NumCoords' => 4, - 'Coords' => sprintf( "%d,%d %d,%d, %d,%d %d,%d", $minX, $minY, $maxX, $minY, $maxX, $maxY, $minX, $maxY ), - 'Area' => $monitor->Width() * $monitor->Height(), - 'AlarmRGB' => 0xff0000, - 'CheckMethod' => 'Blobs', - 'MinPixelThreshold' => '', - 'MaxPixelThreshold' => '', - 'MinAlarmPixels' => '', - 'MaxAlarmPixels' => '', - 'FilterX' => '', - 'FilterY' => '', - 'MinFilterPixels' => '', - 'MaxFilterPixels' => '', - 'MinBlobPixels' => '', - 'MaxBlobPixels' => '', - 'MinBlobs' => '', - 'MaxBlobs' => '', - 'OverloadFrames' => '', - 'ExtendAlarmFrames' => '', - ); - } - $zone['Points'] = coordsToPoints( $zone['Coords'] ); - $zone['AreaCoords'] = preg_replace( '/\s+/', ',', $zone['Coords'] ); + if ( $zid > 0 ) { + $zone = dbFetchOne( 'SELECT * FROM Zones WHERE MonitorId = ? AND Id=?', NULL, array( $monitor->Id(), $zid ) ); + } else { + $zone = array( + 'Id' => 0, + 'Name' => translate('New'), + 'Type' => 'Active', + 'MonitorId' => $monitor->Id(), + 'NumCoords' => 4, + 'Coords' => sprintf("%d,%d %d,%d, %d,%d %d,%d", $minX, $minY, $maxX, $minY, $maxX, $maxY, $minX, $maxY), + 'Area' => $monitor->Width() * $monitor->Height(), + 'AlarmRGB' => 0xff0000, + 'CheckMethod' => 'Blobs', + 'MinPixelThreshold' => '', + 'MaxPixelThreshold' => '', + 'MinAlarmPixels' => '', + 'MaxAlarmPixels' => '', + 'FilterX' => '', + 'FilterY' => '', + 'MinFilterPixels' => '', + 'MaxFilterPixels' => '', + 'MinBlobPixels' => '', + 'MaxBlobPixels' => '', + 'MinBlobs' => '', + 'MaxBlobs' => '', + 'OverloadFrames' => '', + 'ExtendAlarmFrames' => '', + ); + } + $zone['Points'] = coordsToPoints( $zone['Coords'] ); + $zone['AreaCoords'] = preg_replace( '/\s+/', ',', $zone['Coords'] ); - $newZone = $zone; + $newZone = $zone; } # end if new Zone # Ensure Zone fits within the limits of the Monitor @@ -235,16 +235,15 @@ if ( count( $other_zones ) ) {
 -  fps
- +
- +
@@ -254,26 +253,11 @@ for ( $i = 0; $i < $pointCols; $i++ ) - - - - - - - -
disabled="disabled"/> disabled="disabled"/>+ 3 ) { ?>  X