2014-12-05 07:44:23 +08:00
|
|
|
var optControl = <?php echo ZM_OPT_CONTROL ?>;
|
|
|
|
var defaultAspectRatio = '<?php echo ZM_DEFAULT_ASPECT_RATIO ?>';
|
2013-05-02 22:20:06 +08:00
|
|
|
|
|
|
|
<?php
|
|
|
|
if ( ZM_OPT_CONTROL )
|
|
|
|
{
|
|
|
|
?>
|
|
|
|
var controlOptions = new Object();
|
|
|
|
<?php
|
|
|
|
global $controlTypes;
|
2015-05-10 21:10:30 +08:00
|
|
|
$controlTypes = array( ''=>translate('None') );
|
2014-02-13 22:43:19 +08:00
|
|
|
# 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";
|
2013-05-02 22:20:06 +08:00
|
|
|
foreach( dbFetchAll( $sql ) as $row )
|
|
|
|
{
|
|
|
|
$controlTypes[$row['Id']] = $row['Name'];
|
|
|
|
?>
|
2014-12-05 07:44:23 +08:00
|
|
|
controlOptions[<?php echo $row['Id'] ?>] = new Array();
|
2013-05-02 22:20:06 +08:00
|
|
|
<?php
|
|
|
|
if ( $row['HasHomePreset'] )
|
|
|
|
{
|
|
|
|
?>
|
2015-05-10 21:10:30 +08:00
|
|
|
controlOptions[<?php echo $row['Id'] ?>][0] = '<?php echo translate('Home') ?>';
|
2013-05-02 22:20:06 +08:00
|
|
|
<?php
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
?>
|
2014-12-05 07:44:23 +08:00
|
|
|
controlOptions[<?php echo $row['Id'] ?>][0] = null;
|
2013-05-02 22:20:06 +08:00
|
|
|
<?php
|
|
|
|
}
|
|
|
|
for ( $i = 1; $i <= $row['NumPresets']; $i++ )
|
|
|
|
{
|
|
|
|
?>
|
2015-05-10 21:10:30 +08:00
|
|
|
controlOptions[<?php echo $row['Id'] ?>][<?php echo $i ?>] = '<?php echo translate('Preset').' '.$i ?>';
|
2013-05-02 22:20:06 +08:00
|
|
|
<?php
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
if ( empty($_REQUEST['mid']) )
|
|
|
|
{
|
|
|
|
?>
|
|
|
|
var monitorNames = new Object();
|
|
|
|
<?php
|
|
|
|
foreach ( dbFetchAll( "select Name from Monitors order by Name asc", "Name" ) as $name )
|
|
|
|
{
|
|
|
|
?>
|
2014-12-05 07:44:23 +08:00
|
|
|
monitorNames['<?php echo validJsStr($name) ?>'] = true;
|
2013-05-02 22:20:06 +08:00
|
|
|
<?php
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
|
|
function validateForm( form )
|
|
|
|
{
|
|
|
|
var errors = new Array();
|
|
|
|
|
|
|
|
if ( form.elements['newMonitor[Name]'].value.search( /[^\w-]/ ) >= 0 )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadNameChars') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
else if ( form.elements.mid.value == 0 && monitorNames[form.elements['newMonitor[Name]'].value] )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('DuplicateMonitorName') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
|
|
|
|
if ( form.elements['newMonitor[MaxFPS]'].value && !(parseFloat(form.elements['newMonitor[MaxFPS]'].value) > 0 ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadMaxFPS') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
if ( form.elements['newMonitor[AlarmMaxFPS]'].value && !(parseFloat(form.elements['newMonitor[AlarmMaxFPS]'].value) > 0 ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadAlarmMaxFPS') ?>";
|
2011-07-01 23:01:24 +08:00
|
|
|
if ( !form.elements['newMonitor[RefBlendPerc]'].value || (parseInt(form.elements['newMonitor[RefBlendPerc]'].value) > 100 ) || (parseInt(form.elements['newMonitor[RefBlendPerc]'].value) < 0 ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadRefBlendPerc') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
if ( form.elements['newMonitor[Type]'].value == 'Local' )
|
|
|
|
{
|
2011-05-05 17:52:00 +08:00
|
|
|
if ( !form.elements['newMonitor[Palette]'].value || !form.elements['newMonitor[Palette]'].value.match( /^\d+$/ ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadPalette') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
if ( !form.elements['newMonitor[Device]'].value )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadDevice') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
if ( !form.elements['newMonitor[Channel]'].value || !form.elements['newMonitor[Channel]'].value.match( /^\d+$/ ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadChannel') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
if ( !form.elements['newMonitor[Format]'].value || !form.elements['newMonitor[Format]'].value.match( /^\d+$/ ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadFormat') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
}
|
|
|
|
else if ( form.elements['newMonitor[Type]'].value == 'Remote' )
|
|
|
|
{
|
|
|
|
if ( !form.elements['newMonitor[Host]'].value || !form.elements['newMonitor[Host]'].value.match( /^[0-9a-zA-Z_.:@-]+$/ ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadHost') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
if ( form.elements['newMonitor[Port]'].value && !form.elements['newMonitor[Port]'].value.match( /^\d+$/ ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadPort') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
//if ( !form.elements['newMonitor[Path]'].value )
|
2015-05-10 21:10:30 +08:00
|
|
|
//errors[errors.length] = "<?php echo translate('BadPath') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
}
|
|
|
|
else if ( form.elements['newMonitor[Type]'].value == 'File' )
|
|
|
|
{
|
|
|
|
if ( !form.elements['newMonitor[Path]'].value )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadPath') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
}
|
2011-05-05 17:52:00 +08:00
|
|
|
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 ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadColours') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
if ( !form.elements['newMonitor[Width]'].value || !(parseInt(form.elements['newMonitor[Width]'].value) > 0 ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadWidth') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
if ( !form.elements['newMonitor[Height]'].value || !(parseInt(form.elements['newMonitor[Height]'].value) > 0 ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadHeight') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
if ( !form.elements['newMonitor[LabelX]'].value || !(parseInt(form.elements['newMonitor[LabelX]'].value) >= 0 ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadLabelX') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
if ( !form.elements['newMonitor[LabelY]'].value || !(parseInt(form.elements['newMonitor[LabelY]'].value) >= 0 ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadLabelY') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
if ( !form.elements['newMonitor[ImageBufferCount]'].value || !(parseInt(form.elements['newMonitor[ImageBufferCount]'].value) >= 10 ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadImageBufferCount') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
if ( !form.elements['newMonitor[WarmupCount]'].value || !(parseInt(form.elements['newMonitor[WarmupCount]'].value) >= 0 ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadWarmupCount') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
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)) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadPreEventCount') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
if ( !form.elements['newMonitor[PostEventCount]'].value || !(parseInt(form.elements['newMonitor[PostEventCount]'].value) >= 0 ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadPostEventCount') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
if ( !form.elements['newMonitor[StreamReplayBuffer]'].value || !(parseInt(form.elements['newMonitor[StreamReplayBuffer]'].value) >= 0 ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadStreamReplayBuffer') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
if ( !form.elements['newMonitor[AlarmFrameCount]'].value || !(parseInt(form.elements['newMonitor[AlarmFrameCount]'].value) > 0 ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadAlarmFrameCount') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
if ( !form.elements['newMonitor[SectionLength]'].value || !(parseInt(form.elements['newMonitor[SectionLength]'].value) >= 30 ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadSectionLength') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
if ( !form.elements['newMonitor[FPSReportInterval]'].value || !(parseInt(form.elements['newMonitor[FPSReportInterval]'].value) >= 0 ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadFPSReportInterval') ?>";
|
2015-07-22 04:52:52 +08:00
|
|
|
if ( !form.elements['newMonitor[AnalysisInterval]'].value || !(parseInt(form.elements['newMonitor[AnalysisInterval]'].value) >= 1 ) || (parseInt(form.elements['newMonitor[AnalysisInterval]'].value) > parseInt(form.elements['newMonitor[ImageBufferCount]'].value)) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadAnalysisInterval') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
if ( !form.elements['newMonitor[FrameSkip]'].value || !(parseInt(form.elements['newMonitor[FrameSkip]'].value) >= 0 ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadFrameSkip') ?>";
|
2014-04-10 19:56:14 +08:00
|
|
|
if ( !form.elements['newMonitor[MotionFrameSkip]'].value || !(parseInt(form.elements['newMonitor[MotionFrameSkip]'].value) >= 0 ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadMotionFrameSkip') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
if ( form.elements['newMonitor[Type]'].value == 'Local' )
|
|
|
|
if ( !form.elements['newMonitor[SignalCheckColour]'].value || !form.elements['newMonitor[SignalCheckColour]'].value.match( /^[#0-9a-zA-Z]+$/ ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadSignalCheckColour') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
if ( !form.elements['newMonitor[WebColour]'].value || !form.elements['newMonitor[WebColour]'].value.match( /^[#0-9a-zA-Z]+$/ ) )
|
2015-05-10 21:10:30 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadWebColour') ?>";
|
2013-05-02 22:20:06 +08:00
|
|
|
|
|
|
|
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' :
|
|
|
|
{
|
|
|
|
<?php
|
|
|
|
foreach( $httpMethods as $value=>$label )
|
|
|
|
{
|
|
|
|
?>
|
2014-12-05 07:44:23 +08:00
|
|
|
methodSelector.options[methodSelector.options.length] = new Option( "<?php echo htmlspecialchars($label) ?>", "<?php echo $value ?>" );
|
|
|
|
if ( origMethod.value == "<?php echo $value ?>" )
|
2013-05-02 22:20:06 +08:00
|
|
|
methodSelector.selectedIndex = methodSelector.options.length-1;
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'rtsp' :
|
|
|
|
{
|
|
|
|
<?php
|
|
|
|
foreach( $rtspMethods as $value=>$label )
|
|
|
|
{
|
|
|
|
?>
|
2014-12-05 07:44:23 +08:00
|
|
|
methodSelector.options[methodSelector.options.length] = new Option( "<?php echo htmlspecialchars($label) ?>", "<?php echo $value ?>" );
|
|
|
|
if ( origMethod.value == "<?php echo $value ?>" )
|
2013-05-02 22:20:06 +08:00
|
|
|
methodSelector.selectedIndex = form.elements['newMonitor[Method]'].options.length-1;
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return( true );
|
|
|
|
}
|