var optControl = ; var defaultAspectRatio = ''; var controlOptions = new Object(); translate('None') ); # Temporary workaround to show all ptz control types regardless of monitor source type # $sql = "select * from Controls where Type = '".$newMonitor['Type']."'"; $sql = "select * from Controls"; foreach( dbFetchAll( $sql ) as $row ) { $controlTypes[$row['Id']] = $row['Name']; ?> controlOptions[] = new Array(); controlOptions[][0] = ''; controlOptions[][0] = null; controlOptions[][] = ''; var monitorNames = new Object(); monitorNames[''] = true; function validateForm( form ) { var errors = new Array(); if ( form.elements['newMonitor[Name]'].value.search( /[^\w\-\.\(\)\:\/ ]/ ) >= 0 ) errors[errors.length] = ""; else if ( monitorNames[form.elements['newMonitor[Name]'].value] ) errors[errors.length] = ""; if ( form.elements['newMonitor[AnalysisFPSLimit]'].value && !(parseFloat(form.elements['newMonitor[AnalysisFPSLimit]'].value) > 0 ) ) errors[errors.length] = ""; if ( form.elements['newMonitor[MaxFPS]'].value && !(parseFloat(form.elements['newMonitor[MaxFPS]'].value) > 0 ) ) errors[errors.length] = ""; if ( form.elements['newMonitor[AlarmMaxFPS]'].value && !(parseFloat(form.elements['newMonitor[AlarmMaxFPS]'].value) > 0 ) ) errors[errors.length] = ""; if ( !form.elements['newMonitor[RefBlendPerc]'].value || (parseInt(form.elements['newMonitor[RefBlendPerc]'].value) > 100 ) || (parseInt(form.elements['newMonitor[RefBlendPerc]'].value) < 0 ) ) errors[errors.length] = ""; if ( form.elements['newMonitor[Type]'].value == 'Local' ) { if ( !form.elements['newMonitor[Palette]'].value || !form.elements['newMonitor[Palette]'].value.match( /^\d+$/ ) ) errors[errors.length] = ""; if ( !form.elements['newMonitor[Device]'].value ) errors[errors.length] = ""; if ( !form.elements['newMonitor[Channel]'].value || !form.elements['newMonitor[Channel]'].value.match( /^\d+$/ ) ) errors[errors.length] = ""; if ( !form.elements['newMonitor[Format]'].value || !form.elements['newMonitor[Format]'].value.match( /^\d+$/ ) ) errors[errors.length] = ""; } else if ( form.elements['newMonitor[Type]'].value == 'Remote' ) { //if ( !form.elements['newMonitor[Host]'].value || !form.elements['newMonitor[Host]'].value.match( /^[0-9a-zA-Z_.:@-]+$/ ) ) //errors[errors.length] = ""; if ( form.elements['newMonitor[Port]'].value && !form.elements['newMonitor[Port]'].value.match( /^\d+$/ ) ) errors[errors.length] = ""; //if ( !form.elements['newMonitor[Path]'].value ) //errors[errors.length] = ""; } else if ( form.elements['newMonitor[Type]'].value == 'File' ) { if ( !form.elements['newMonitor[Path]'].value ) errors[errors.length] = ""; } if ( !form.elements['newMonitor[Colours]'].value || (parseInt(form.elements['newMonitor[Colours]'].value) != 1 && parseInt(form.elements['newMonitor[Colours]'].value) != 3 && parseInt(form.elements['newMonitor[Colours]'].value) != 4 ) ) errors[errors.length] = ""; if ( !form.elements['newMonitor[Width]'].value || !(parseInt(form.elements['newMonitor[Width]'].value) > 0 ) ) errors[errors.length] = ""; if ( !form.elements['newMonitor[Height]'].value || !(parseInt(form.elements['newMonitor[Height]'].value) > 0 ) ) errors[errors.length] = ""; if ( !form.elements['newMonitor[LabelX]'].value || !(parseInt(form.elements['newMonitor[LabelX]'].value) >= 0 ) ) errors[errors.length] = ""; if ( !form.elements['newMonitor[LabelY]'].value || !(parseInt(form.elements['newMonitor[LabelY]'].value) >= 0 ) ) errors[errors.length] = ""; if ( !form.elements['newMonitor[ImageBufferCount]'].value || !(parseInt(form.elements['newMonitor[ImageBufferCount]'].value) >= 10 ) ) errors[errors.length] = ""; if ( !form.elements['newMonitor[WarmupCount]'].value || !(parseInt(form.elements['newMonitor[WarmupCount]'].value) >= 0 ) ) errors[errors.length] = ""; if ( !form.elements['newMonitor[PreEventCount]'].value || !(parseInt(form.elements['newMonitor[PreEventCount]'].value) >= 0 ) || (parseInt(form.elements['newMonitor[PreEventCount]'].value) > parseInt(form.elements['newMonitor[ImageBufferCount]'].value)) ) errors[errors.length] = ""; if ( !form.elements['newMonitor[PostEventCount]'].value || !(parseInt(form.elements['newMonitor[PostEventCount]'].value) >= 0 ) ) errors[errors.length] = ""; if ( !form.elements['newMonitor[StreamReplayBuffer]'].value || !(parseInt(form.elements['newMonitor[StreamReplayBuffer]'].value) >= 0 ) ) errors[errors.length] = ""; if ( !form.elements['newMonitor[AlarmFrameCount]'].value || !(parseInt(form.elements['newMonitor[AlarmFrameCount]'].value) > 0 ) ) errors[errors.length] = ""; if ( !form.elements['newMonitor[SectionLength]'].value || !(parseInt(form.elements['newMonitor[SectionLength]'].value) >= 30 ) ) errors[errors.length] = ""; if ( !form.elements['newMonitor[AnalysisUpdateDelay]'].value || !(parseInt(form.elements['newMonitor[AnalysisUpdateDelay]'].value) >= 0 ) ) errors[errors.length] = ""; if ( !form.elements['newMonitor[FPSReportInterval]'].value || !(parseInt(form.elements['newMonitor[FPSReportInterval]'].value) >= 0 ) ) errors[errors.length] = ""; if ( !form.elements['newMonitor[FrameSkip]'].value || !(parseInt(form.elements['newMonitor[FrameSkip]'].value) >= 0 ) ) errors[errors.length] = ""; if ( !form.elements['newMonitor[MotionFrameSkip]'].value || !(parseInt(form.elements['newMonitor[MotionFrameSkip]'].value) >= 0 ) ) errors[errors.length] = ""; if ( form.elements['newMonitor[Type]'].value == 'Local' ) if ( !form.elements['newMonitor[SignalCheckColour]'].value || !form.elements['newMonitor[SignalCheckColour]'].value.match( /^[#0-9a-zA-Z]+$/ ) ) errors[errors.length] = ""; if ( !form.elements['newMonitor[WebColour]'].value || !form.elements['newMonitor[WebColour]'].value.match( /^[#0-9a-zA-Z]+$/ ) ) errors[errors.length] = ""; if ( errors.length ) { alert( errors.join( "\n" ) ); return( false ); } return( true ); } function updateLinkedMonitors( element ) { var form = element.form; var monitorIds = new Array(); for ( var i = 0; i < element.options.length; i++ ) if ( element.options[i].selected ) monitorIds[monitorIds.length] = element.options[i].value; form.elements['newMonitor[LinkedMonitors]'].value = monitorIds.join( ',' ); } function updateMethods( element ) { var form = element.form; var origMethod = form.elements['origMethod']; var methodSelector = form.elements['newMonitor[Method]']; methodSelector.options.length = 0; switch ( element.value ) { case 'http' : { $label ) { ?> methodSelector.options[methodSelector.options.length] = new Option( "", "" ); if ( origMethod.value == "" ) methodSelector.selectedIndex = methodSelector.options.length-1; break; } case 'rtsp' : { $label ) { ?> methodSelector.options[methodSelector.options.length] = new Option( "", "" ); if ( origMethod.value == "" ) methodSelector.selectedIndex = form.elements['newMonitor[Method]'].options.length-1; break; } } return( true ); }