diff --git a/web/zm.php b/web/zm.php index b20867051..67a0a2c89 100644 --- a/web/zm.php +++ b/web/zm.php @@ -1043,6 +1043,147 @@ opener.location.reload(); } ?> window.focus(); +function validateForm(theForm) +{ + return( true ); +} + +function applyZoneType(theForm) +{ + if ( theForm.new_type.value == 'Inactive' ) + { + theForm.new_alarm_rgb.disabled = true; + theForm.new_alarm_rgb.value = ""; + theForm.new_alarm_threshold.disabled = true; + theForm.new_alarm_threshold.value = ""; + theForm.new_min_alarm_pixels.disabled = true; + theForm.new_min_alarm_pixels.value = ""; + theForm.new_max_alarm_pixels.disabled = true; + theForm.new_max_alarm_pixels.value = ""; + theForm.new_filter_x.disabled = true; + theForm.new_filter_x.value = ""; + theForm.new_filter_y.disabled = true; + theForm.new_filter_y.value = ""; + theForm.new_min_filter_pixels.disabled = true; + theForm.new_min_filter_pixels.value = ""; + theForm.new_max_filter_pixels.disabled = true; + theForm.new_max_filter_pixels.value = ""; + theForm.new_min_blob_pixels.disabled = true; + theForm.new_min_blob_pixels.value = ""; + theForm.new_max_blob_pixels.disabled = true; + theForm.new_max_blob_pixels.value = ""; + theForm.new_min_blobs.disabled = true; + theForm.new_min_blobs.value = ""; + theForm.new_max_blobs.disabled = true; + theForm.new_max_blobs.value = ""; + } + else + { + theForm.new_alarm_rgb.disabled = false; + theForm.new_alarm_rgb.value = ; + theForm.new_alarm_threshold.disabled = false; + theForm.new_alarm_threshold.value = ; + theForm.new_min_alarm_pixels.disabled = false; + theForm.new_min_alarm_pixels.value = ; + theForm.new_max_alarm_pixels.disabled = false; + theForm.new_max_alarm_pixels.value = ; + theForm.new_filter_x.disabled = false; + theForm.new_filter_x.value = ; + theForm.new_filter_y.disabled = false; + theForm.new_filter_y.value = ; + theForm.new_min_filter_pixels.disabled = false; + theForm.new_min_filter_pixels.value = ; + theForm.new_max_filter_pixels.disabled = false; + theForm.new_max_filter_pixels.value = ; + theForm.new_min_blob_pixels.disabled = false; + theForm.new_min_blob_pixels.value = ; + theForm.new_max_blob_pixels.disabled = false; + theForm.new_max_blob_pixels.value = ; + theForm.new_min_blobs.disabled = false; + theForm.new_min_blobs.value = ; + theForm.new_max_blobs.disabled = false; + theForm.new_max_blobs.value = ; + } +} + +function toPixels(theField,maxValue) +{ + theField.value = Math.round((theField.value*maxValue)/100); +} + +function toPercent(theField,maxValue) +{ + theField.value = Math.round((100*theField.value)/maxValue); +} + +function applyZoneUnits(theForm) +{ + var max_width = ; + var max_height = ; + var area = (max_width+1) * (max_height+1); + + if ( theForm.new_units.value == 'Pixels' ) + { + toPixels( theForm.new_lo_x, max_width ); + toPixels( theForm.new_lo_y, max_height ); + toPixels( theForm.new_hi_x, max_width ); + toPixels( theForm.new_hi_y, max_height ); + toPixels( theForm.new_min_alarm_pixels, area ); + toPixels( theForm.new_max_alarm_pixels, area ); + toPixels( theForm.new_min_filter_pixels, area ); + toPixels( theForm.new_max_filter_pixels, area ); + toPixels( theForm.new_min_blob_pixels, area ); + toPixels( theForm.new_max_blob_pixels, area ); + } + else + { + toPercent( theForm.new_lo_x, max_width ); + toPercent( theForm.new_lo_y, max_height ); + toPercent( theForm.new_hi_x, max_width ); + toPercent( theForm.new_hi_y, max_height ); + toPercent( theForm.new_min_alarm_pixels, area ); + toPercent( theForm.new_max_alarm_pixels, area ); + toPercent( theForm.new_min_filter_pixels, area ); + toPercent( theForm.new_max_filter_pixels, area ); + toPercent( theForm.new_min_blob_pixels, area ); + toPercent( theForm.new_max_blob_pixels, area ); + } +} + +function checkBounds(theField,fieldText,minValue,maxValue) +{ + if ( document.zoneForm.new_units.value == "Percent" ) + { + minValue = 0; + maxValue = 100; + } + if ( theField.value < minValue ) + { + alert( fieldText + " must be greater than or equal to " + minValue ); + theField.value = minValue; + } + if ( theField.value > maxValue ) + { + alert( fieldText + " must be less than or equal to " + maxValue ); + theField.value = maxValue; + } +} + +function checkWidth(theField,fieldText) +{ + return( checkBounds( theField, fieldText, 0, ) ); +} + +function checkHeight(theField,fieldText) +{ + return( checkBounds( theField, fieldText, 0, ) ); +} + +function checkArea(theField,fieldText) +{ + return( checkBounds( theField, fieldText, 0, ) ); +} + function closeWindow() { window.close(); } @@ -1053,7 +1194,7 @@ function closeWindow() {