From edab3e5e2e9533b4c5467a0bc6370879c1a8e125 Mon Sep 17 00:00:00 2001 From: stan Date: Tue, 27 Dec 2005 16:52:28 +0000 Subject: [PATCH] Databased zone presets. git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1742 e3e1d417-86f3-4887-817a-d78f3d33393f --- web/zm_html_view_zone.php | 110 +++++++++++++------------------------- web/zm_lang_en_gb.php | 8 +-- 2 files changed, 37 insertions(+), 81 deletions(-) diff --git a/web/zm_html_view_zone.php b/web/zm_html_view_zone.php index c9c6cc26f..67b705c43 100644 --- a/web/zm_html_view_zone.php +++ b/web/zm_html_view_zone.php @@ -38,15 +38,17 @@ $marker = array( "height"=>7, ); -$presets = array( - 0=>$zmSlangZonePresetChoose, - 1=>$zmSlangZonePresetFastLow, - 2=>$zmSlangZonePresetFastMed, - 3=>$zmSlangZonePresetFastHigh, - 11=>$zmSlangZonePresetBestLow, - 12=>$zmSlangZonePresetBestMed, - 13=>$zmSlangZonePresetBestHigh, -); +$result = mysql_query( "select *, Units-1 as UnitsIndex, CheckMethod-1 as CheckMethodIndex from ZonePresets order by Id asc" ); +if ( !$result ) + die( mysql_error() ); +$presets = array(); +$preset_names = array(); +$preset_names[0] = $zmSlangChoosePreset; +while ( $preset = mysql_fetch_assoc( $result ) ) +{ + $preset_names[$preset['Id']] = $preset['Name']; + $presets[] = $preset; +} $result = mysql_query( "select * from Monitors where Id = '$mid'" ); if ( !$result ) @@ -344,73 +346,33 @@ function applyPreset() var form = document.zone_form; var preset = form.elements['presetSelector'].options[form.elements['presetSelector'].selectedIndex].value; - if ( preset >= 1 && preset <= 3 ) + switch( preset ) { - form.elements['new_zone[Units]'].selectedIndex = 1; - form.elements['new_zone[CheckMethod]'].selectedIndex = 0; - form.elements['new_zone[MaxPixelThreshold]'].value = '' - form.elements['new_zone[FilterX]'].value = ''; - form.elements['new_zone[FilterY]'].value = ''; - form.elements['new_zone[MaxAlarmPixels]'].value = ''; - form.elements['new_zone[MinFilterPixels]'].value = ''; - form.elements['new_zone[MaxFilterPixels]'].value = ''; - form.elements['new_zone[MinBlobPixels]'].value = ''; - form.elements['new_zone[MaxBlobPixels]'].value = ''; - form.elements['new_zone[MinBlobs]'].value = ''; - form.elements['new_zone[MaxBlobs]'].value = ''; - if ( preset == 1 ) + + case '': { - form.elements['new_zone[MinPixelThreshold]'].value = 25; - form.elements['new_zone[MinAlarmPixels]'].value = 20; - } - else if ( preset == 2 ) - { - form.elements['new_zone[MinPixelThreshold]'].value = 15; - form.elements['new_zone[MinAlarmPixels]'].value = 10; - } - else if ( preset == 3 ) - { - form.elements['new_zone[MinPixelThreshold]'].value = 10; - form.elements['new_zone[MinAlarmPixels]'].value = 5; - } - } - else if ( preset >= 11 && preset <= 13 ) - { - form.elements['new_zone[Units]'].selectedIndex = 1; - form.elements['new_zone[CheckMethod]'].selectedIndex = 2; - form.elements['new_zone[MaxPixelThreshold]'].value = '' - form.elements['new_zone[MaxAlarmPixels]'].value = ''; - form.elements['new_zone[MaxFilterPixels]'].value = ''; - form.elements['new_zone[MaxBlobPixels]'].value = ''; - form.elements['new_zone[MinBlobs]'].value = 1; - form.elements['new_zone[MaxBlobs]'].value = ''; - if ( preset == 11 ) - { - form.elements['new_zone[MinPixelThreshold]'].value = 25; - form.elements['new_zone[FilterX]'].value = 7; - form.elements['new_zone[FilterY]'].value = 7; - form.elements['new_zone[MinAlarmPixels]'].value = 36; - form.elements['new_zone[MinFilterPixels]'].value = 24; - form.elements['new_zone[MinBlobPixels]'].value = 20; - } - else if ( preset == 12 ) - { - form.elements['new_zone[MinPixelThreshold]'].value = 15; - form.elements['new_zone[FilterX]'].value = 5; - form.elements['new_zone[FilterY]'].value = 5; - form.elements['new_zone[MinAlarmPixels]'].value = 16; - form.elements['new_zone[MinFilterPixels]'].value = 12; - form.elements['new_zone[MinBlobPixels]'].value = 10; - } - else if ( preset == 13 ) - { - form.elements['new_zone[MinPixelThreshold]'].value = 10; - form.elements['new_zone[FilterX]'].value = 3; - form.elements['new_zone[FilterY]'].value = 3; - form.elements['new_zone[MinAlarmPixels]'].value = 8; - form.elements['new_zone[MinFilterPixels]'].value = 6; - form.elements['new_zone[MinBlobPixels]'].value = 5; + form.elements['new_zone[Units]'].selectedIndex = ; + form.elements['new_zone[CheckMethod]'].selectedIndex = ; + form.elements['new_zone[MinPixelThreshold]'].value = ''; + form.elements['new_zone[MaxPixelThreshold]'].value = ''; + form.elements['new_zone[FilterX]'].value = ''; + form.elements['new_zone[FilterY]'].value = ''; + form.elements['new_zone[MinAlarmPixels]'].value = ''; + form.elements['new_zone[MaxAlarmPixels]'].value = ''; + form.elements['new_zone[MinFilterPixels]'].value = ''; + form.elements['new_zone[MaxFilterPixels]'].value = ''; + form.elements['new_zone[MinBlobPixels]'].value = ''; + form.elements['new_zone[MaxBlobPixels]'].value = ''; + form.elements['new_zone[MinBlobs]'].value = ''; + form.elements['new_zone[MaxBlobs]'].value = ''; + break; } + } applyCheckMethod(); form.elements['new_zone[TempArea]'].value = 100; @@ -689,7 +651,7 @@ foreach ( getEnumValues( 'Zones', 'Type' ) as $opt_type ) } ?> -"applyPreset()", "onBlur"=>"this.selectedIndex=0" ) ) ?> +"applyPreset()", "onBlur"=>"this.selectedIndex=0" ) ) ?>