fix inline javascript in ptz buttons

This commit is contained in:
Isaac Connor 2020-04-10 11:30:30 -04:00
parent 042086b565
commit 96774bd038
2 changed files with 45 additions and 40 deletions

View File

@ -25,15 +25,15 @@ function controlFocus($monitor, $cmds) {
?> ?>
<div class="arrowControl focusControls"> <div class="arrowControl focusControls">
<div class="arrowLabel"><?php echo translate('Near') ?></div> <div class="arrowLabel"><?php echo translate('Near') ?></div>
<button type="button" class="longArrowBtn upBtn" onclick="controlCmd('<?php echo $cmds['FocusNear'] ?>',event,0,-1)"></button> <button type="button" class="longArrowBtn upBtn" value="<?php echo $cmds['FocusNear'] ?>" data-on-click-this="controlCmd" data-xtell="0" data-ytell="-1"></button>
<button type="button" class="arrowCenter"<?php if ( $control->CanFocusCon() ) { ?> onclick="controlCmd('<?php echo $cmds['FocusStop'] ?>')"<?php } ?>><?php echo translate('Focus') ?></button> <button type="button" class="arrowCenter"<?php if ( $control->CanFocusCon() ) { ?> data-on-click-this="controlCmd" value="<?php echo $cmds['FocusStop'] ?>"<?php } ?>><?php echo translate('Focus') ?></button>
<button type="button" class="longArrowBtn downBtn" onclick="controlCmd('<?php echo $cmds['FocusFar'] ?>',event,0,1)"></button> <button type="button" class="longArrowBtn downBtn" data-on-click-this="controlCmd" value="<?php echo $cmds['FocusFar'] ?>" data-xtell="0" data-ytell="1"></button>
<div class="arrowLabel"><?php echo translate('Far') ?></div> <div class="arrowLabel"><?php echo translate('Far') ?></div>
<?php <?php
if ( $control->CanAutoFocus() ) { if ( $control->CanAutoFocus() ) {
?> ?>
<button type="button" class="ptzTextBtn" value="<?php echo $cmds['FocusAuto'] ?>" onclick="controlCmd('<?php echo $cmds['FocusAuto'] ?>')"><?php echo translate('Auto') ?></button> <button type="button" class="ptzTextBtn" value="<?php echo $cmds['FocusAuto'] ?>" data-on-click-this="controlCmd"><?php echo translate('Auto') ?></button>
<button type="button" class="ptzTextBtn" value="<?php echo $cmds['FocusMan'] ?>" onclick="controlCmd('<?php echo $cmds['FocusMan'] ?>')"><?php echo translate('Man') ?></button> <button type="button" class="ptzTextBtn" value="<?php echo $cmds['FocusMan'] ?>" data-on-click-this="controlCmd"><?php echo translate('Man') ?></button>
<?php <?php
} }
?> ?>
@ -48,15 +48,15 @@ function controlZoom($monitor, $cmds) {
?> ?>
<div class="arrowControl zoomControls"> <div class="arrowControl zoomControls">
<div class="arrowLabel"><?php echo translate('Tele') ?></div> <div class="arrowLabel"><?php echo translate('Tele') ?></div>
<button type="button" class="longArrowBtn upBtn" onclick="controlCmd('<?php echo $cmds['ZoomTele'] ?>',event,0,-1)"></button> <button type="button" class="longArrowBtn upBtn" data-on-click-this="controlCmd" value="<?php echo $cmds['ZoomTele'] ?>" data-xtell="0" data-ytell="-1"></button>
<button type="button" class="arrowCenter"<?php if ( $control->CanZoomCon() ) { ?> onclick="controlCmd('<?php echo $cmds['ZoomStop'] ?>')"<?php } ?>><?php echo translate('Zoom') ?></button> <button type="button" class="arrowCenter"<?php if ( $control->CanZoomCon() ) { ?> data-on-click-this="controlCmd" value="<?php echo $cmds['ZoomStop'] ?>"<?php } ?>><?php echo translate('Zoom') ?></button>
<button type="button" class="longArrowBtn downBtn" onclick="controlCmd('<?php echo $cmds['ZoomWide'] ?>',event,0,1)"></button> <button type="button" class="longArrowBtn downBtn" data-on-click-data="controlCmd" value="<?php echo $cmds['ZoomWide'] ?>" data-xtell="0" data-ytell="1"></button>
<div class="arrowLabel"><?php echo translate('Wide') ?></div> <div class="arrowLabel"><?php echo translate('Wide') ?></div>
<?php <?php
if ( $control->CanAutoZoom() ) { if ( $control->CanAutoZoom() ) {
?> ?>
<button type="button" class="ptzTextBtn" value="Auto" onclick="controlCmd('<?php echo $cmds['ZoomAuto'] ?>')"><?php echo translate('Auto') ?></button> <button type="button" class="ptzTextBtn" value="Auto" data-on-click-this="controlCmd" value="<?php echo $cmds['ZoomAuto'] ?>"><?php echo translate('Auto') ?></button>
<button type="button" class="ptzTextBtn" value="Man" onclick="controlCmd('<?php echo $cmds['ZoomMan'] ?>')"><?php echo translate('Man') ?></button> <button type="button" class="ptzTextBtn" value="Man" data-on-click-this="controlCmd" value="<?php echo $cmds['ZoomMan'] ?>"><?php echo translate('Man') ?></button>
<?php <?php
} }
?> ?>
@ -70,15 +70,15 @@ function controlIris($monitor, $cmds) {
?> ?>
<div class="arrowControl irisControls"> <div class="arrowControl irisControls">
<div class="arrowLabel"><?php echo translate('Open') ?></div> <div class="arrowLabel"><?php echo translate('Open') ?></div>
<button type="button" class="longArrowBtn upBtn" onclick="controlCmd('<?php echo $cmds['IrisOpen'] ?>',event,0,-1)"></button> <button type="button" class="longArrowBtn upBtn" data-on-click-this="controlCmd" value="<?php echo $cmds['IrisOpen'] ?>" data-xtell="0" data-ytell="-1"></button>
<button type="button" class="arrowCenter"<?php if ( $control->CanIrisCon() ) { ?> onclick="controlCmd('<?php echo $cmds['IrisStop'] ?>')"<?php } ?>><?php echo translate('Iris') ?></button> <button type="button" class="arrowCenter"<?php if ( $control->CanIrisCon() ) { ?> data-on-click-this="controlCmd" value="<?php echo $cmds['IrisStop'] ?>"<?php } ?>><?php echo translate('Iris') ?></button>
<button type="button" class="longArrowBtn downBtn" onclick="controlCmd('<?php echo $cmds['IrisClose'] ?>',event,0,1)"></button> <button type="button" class="longArrowBtn downBtn" data-on-click-this="controlCmd" value="<?php echo $cmds['IrisClose'] ?>" data-xtell="0" data-ytell="1"></button>
<div class="arrowLabel"><?php echo translate('Close') ?></div> <div class="arrowLabel"><?php echo translate('Close') ?></div>
<?php <?php
if ( $control->CanAutoIris() ) { if ( $control->CanAutoIris() ) {
?> ?>
<button type="button" class="ptzTextBtn" value="Auto" onclick="controlCmd('<?php echo $cmds['IrisAuto'] ?>')"><?php echo translate('Auto') ?></button> <button type="button" class="ptzTextBtn" value="Auto" data-on-click-this="controlCmd" value="<?php echo $cmds['IrisAuto'] ?>"><?php echo translate('Auto') ?></button>
<button type="button" class="ptzTextBtn" value="Man" onclick="controlCmd('<?php echo $cmds['IrisMan'] ?>')"><?php echo translate('Man') ?></button> <button type="button" class="ptzTextBtn" value="Man" data-on-click-this="controlCmd" value="<?php echo $cmds['IrisMan'] ?>"><?php echo translate('Man') ?></button>
<?php <?php
} }
?> ?>
@ -93,15 +93,15 @@ function controlWhite($monitor, $cmds) {
?> ?>
<div class="arrowControl whiteControls"> <div class="arrowControl whiteControls">
<div class="arrowLabel"><?php echo translate('In') ?></div> <div class="arrowLabel"><?php echo translate('In') ?></div>
<button type="button" class="longArrowBtn upBtn" onclick="controlCmd('<?php echo $cmds['WhiteIn'] ?>',event,0,-1)"></button> <button type="button" class="longArrowBtn upBtn" data-on-click-this="controlCmd" value="<?php echo $cmds['WhiteIn'] ?>" data-xtell="0" data-ytell="-1"></button>
<button type="button" class="arrowCenter"<?php if ( $control->CanWhiteCon() ) { ?> onclick="controlCmd('<?php echo $cmds['WhiteStop'] ?>')"<?php } ?>><?php echo translate('White') ?></button> <button type="button" class="arrowCenter"<?php if ( $control->CanWhiteCon() ) { ?> data-on-click-this="controlCmd" value="<?php echo $cmds['WhiteStop'] ?>"<?php } ?>><?php echo translate('White') ?></button>
<button type="button" class="longArrowBtn downBtn" onclick="controlCmd('<?php echo $cmds['WhiteOut'] ?>',event,0,1)"></button> <button type="button" class="longArrowBtn downBtn" data-on-click-this="controlCmd" value="<?php echo $cmds['WhiteOut'] ?>" data-xtell="0" data-ytell="1)"></button>
<div class="arrowLabel"><?php echo translate('Out') ?></div> <div class="arrowLabel"><?php echo translate('Out') ?></div>
<?php <?php
if ( $control->CanAutoWhite() ) { if ( $control->CanAutoWhite() ) {
?> ?>
<button type="button" class="ptzTextBtn" value="Auto" onclick="controlCmd('<?php echo $cmds['WhiteAuto'] ?>')"><?php echo translate('Auto') ?></button> <button type="button" class="ptzTextBtn" value="Auto" data-on-click-this="controlCmd" value="<?php echo $cmds['WhiteAuto'] ?>"><?php echo translate('Auto') ?></button>
<button type="button" class="ptzTextBtn" value="Man" onclick="controlCmd('<?php echo $cmds['WhiteMan'] ?>')"><?php echo translate('Man') ?></button> <button type="button" class="ptzTextBtn" value="Man" data-on-click-this="controlCmd" value="<?php echo $cmds['WhiteMan'] ?>"><?php echo translate('Man') ?></button>
<?php <?php
} }
?> ?>
@ -122,19 +122,19 @@ function controlPanTilt($monitor, $cmds) {
$hasTilt = $control->CanTilt(); $hasTilt = $control->CanTilt();
$hasDiag = $hasPan && $hasTilt && $control->CanMoveDiag(); $hasDiag = $hasPan && $hasTilt && $control->CanMoveDiag();
?> ?>
<button type="button" class="arrowBtn upLeftBtn<?php echo $hasDiag?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveUpLeft'] ?>',event,-1,-1)"></button> <button type="button" class="arrowBtn upLeftBtn<?php echo $hasDiag?'':' invisible' ?>" data-on-click-this="controlCmd" value="<?php echo $cmds['MoveUpLeft'] ?>" data-xtell="-1" data-ytell="-1"></button>
<button type="button" class="arrowBtn upBtn<?php echo $hasTilt?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveUp'] ?>',event,0,-1)"></button> <button type="button" class="arrowBtn upBtn<?php echo $hasTilt?'':' invisible' ?>" data-on-click-this="controlCmd" value="<?php echo $cmds['MoveUp'] ?>" data-xtell="0" data-ytell="-1"></button>
<button type="button" class="arrowBtn upRightBtn<?php echo $hasDiag?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveUpRight'] ?>',event,1,-1)"></button> <button type="button" class="arrowBtn upRightBtn<?php echo $hasDiag?'':' invisible' ?>" data-on-click-this="controlCmd" value="<?php echo $cmds['MoveUpRight'] ?>" data-xtell="1" data-ytell="-1"></button>
<button type="button" class="arrowBtn leftBtn<?php echo $hasPan?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveLeft'] ?>',event,-1,0)"></button> <button type="button" class="arrowBtn leftBtn<?php echo $hasPan?'':' invisible' ?>" data-on-click-this="controlCmd" value="<?php echo $cmds['MoveLeft'] ?>" data-xtell="-1" data-ytell="0"></button>
<?php if ( isset($cmds['Center']) ) { ?> <?php if ( isset($cmds['Center']) ) { ?>
<button type="button" class="arrowBtn centerBtn" onclick="controlCmd('<?php echo $cmds['Center'] ?>')"></button> <button type="button" class="arrowBtn centerBtn" data-on-click-this="controlCmd" value="<?php echo $cmds['Center'] ?>"></button>
<?php } else { ?> <?php } else { ?>
<button type="button" class="arrowBtn NocenterBtn"></button> <button type="button" class="arrowBtn NocenterBtn"></button>
<?php } ?> <?php } ?>
<button type="button" class="arrowBtn rightBtn<?php echo $hasPan?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveRight'] ?>',event,1,0)"></button> <button type="button" class="arrowBtn rightBtn<?php echo $hasPan?'':' invisible' ?>" data-on-click-this="controlCmd" value="<?php echo $cmds['MoveRight'] ?>" data-xtell="1" data-ytell="0"></button>
<button type="button" class="arrowBtn downLeftBtn<?php echo $hasDiag?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveDownLeft'] ?>',event,-1,1)"></button> <button type="button" class="arrowBtn downLeftBtn<?php echo $hasDiag?'':' invisible' ?>" data-on-click-this="controlCmd" value="<?php echo $cmds['MoveDownLeft'] ?>" data-xtell="-1" data-ytell="1"></button>
<button type="button" class="arrowBtn downBtn<?php echo $hasTilt?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveDown'] ?>',event,0,1)"></button> <button type="button" class="arrowBtn downBtn<?php echo $hasTilt?'':' invisible' ?>" data-on-click-this="controlCmd" value="<?php echo $cmds['MoveDown'] ?>" data-xtell="0" data-ytell="1"></button>
<button type="button" class="arrowBtn downRightBtn<?php echo $hasDiag?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveDownRight'] ?>',event,1,1)"></button> <button type="button" class="arrowBtn downRightBtn<?php echo $hasDiag?'':' invisible' ?>" data-on-click-this="controlCmd" value="<?php echo $cmds['MoveDownRight'] ?>" data-xtell="1" data-ytell="1"></button>
</div> </div>
</div> </div>
<?php <?php
@ -148,7 +148,7 @@ function controlPresets($monitor, $cmds) {
$sql = 'SELECT * FROM ControlPresets WHERE MonitorId = ?'; $sql = 'SELECT * FROM ControlPresets WHERE MonitorId = ?';
$labels = array(); $labels = array();
foreach( dbFetchAll( $sql, NULL, array( $monitor->Id() ) ) as $row ) { foreach ( dbFetchAll($sql, NULL, array($monitor->Id())) as $row ) {
$labels[$row['Preset']] = $row['Label']; $labels[$row['Preset']] = $row['Label'];
} }
@ -162,7 +162,7 @@ function controlPresets($monitor, $cmds) {
<?php <?php
for ( $i = 1; $i <= $control->NumPresets(); $i++ ) { for ( $i = 1; $i <= $control->NumPresets(); $i++ ) {
?> ?>
<button type="button" class="ptzNumBtn" title="<?php echo isset($labels[$i])?htmlentities($labels[$i]):'' ?>" value="<?php echo $i ?>" onclick="controlCmd('<?php echo $cmds['PresetGoto'] ?><?php echo $i ?>');"/><?php echo $i ?></button> <button type="button" class="ptzNumBtn" title="<?php echo isset($labels[$i])?htmlentities($labels[$i]):'' ?>" value="<?php echo $i ?>" data-on-click-this="controlCmd" value="<?php echo $cmds['PresetGoto'] ?><?php echo $i ?>"/><?php echo $i ?></button>
<?php <?php
} // end foreach preset } // end foreach preset
?> ?>
@ -171,7 +171,7 @@ function controlPresets($monitor, $cmds) {
<?php <?php
if ( $control->HasHomePreset() ) { if ( $control->HasHomePreset() ) {
?> ?>
<button type="button" class="ptzTextBtn" value="Home" onclick="controlCmd('<?php echo $cmds['PresetHome'] ?>');"><?php echo translate('Home') ?></button> <button type="button" class="ptzTextBtn" data-on-click-this="controlCmd" value="<?php echo $cmds['PresetHome'] ?>"><?php echo translate('Home') ?></button>
<?php <?php
} }
if ( canEdit('Monitors') && $control->CanSetPresets() ) { if ( canEdit('Monitors') && $control->CanSetPresets() ) {
@ -196,22 +196,22 @@ function controlPower($monitor, $cmds) {
<?php <?php
if ( $control->CanWake() ) { if ( $control->CanWake() ) {
?> ?>
<button type="button" class="ptzTextBtn" value="Wake" onclick="controlCmd('<?php echo $cmds['Wake'] ?>')"><?php echo translate('Wake') ?></button> <button type="button" class="ptzTextBtn" data-on-click-this="controlCmd" value="<?php echo $cmds['Wake'] ?>"><?php echo translate('Wake') ?></button>
<?php <?php
} }
if ( $control->CanSleep() ) { if ( $control->CanSleep() ) {
?> ?>
<button type="button" class="ptzTextBtn" value="Sleep" onclick="controlCmd('<?php echo $cmds['Sleep'] ?>')"><?php echo translate('Sleep') ?></button> <button type="button" class="ptzTextBtn" data-on-click-this="controlCmd" value="<?php echo $cmds['Sleep'] ?>"><?php echo translate('Sleep') ?></button>
<?php <?php
} }
if ( $control->CanReset() ) { if ( $control->CanReset() ) {
?> ?>
<button type="button" class="ptzTextBtn" value="Reset" onclick="controlCmd('<?php echo $cmds['Reset'] ?>')"><?php echo translate('Reset') ?></button> <button type="button" class="ptzTextBtn" data-on-click-this="controlCmd" value="<?php echo $cmds['Reset'] ?>"><?php echo translate('Reset') ?></button>
<?php <?php
} }
if ( $control->CanReboot() ) { if ( $control->CanReboot() ) {
?> ?>
<button type="button" class="ptzTextBtn" value="Reboot" onclick="controlCmd('<?php echo $cmds['Reboot'] ?>')"><?php echo translate('Reboot') ?></button> <button type="button" class="ptzTextBtn" data-on-click-this="controlCmd" value="<?php echo $cmds['Reboot'] ?>"><?php echo translate('Reboot') ?></button>
<?php <?php
} }
?> ?>

View File

@ -651,8 +651,13 @@ function getControlResponse( respObj, respText ) {
} }
} }
function controlCmd( control, event, xtell, ytell ) { function controlCmd(button) {
var locParms = "";
control = button.getAttribute('value');
xtell = button.getAttribute('xtell');
ytell = button.getAttribute('ytell');
var locParms = '';
if ( event && (xtell || ytell) ) { if ( event && (xtell || ytell) ) {
console.log(event); console.log(event);
var target = event.target; var target = event.target;
@ -668,7 +673,7 @@ function controlCmd( control, event, xtell, ytell ) {
} else if ( xtell == 2 ) { } else if ( xtell == 2 ) {
xge = 2*(50 - xge); xge = 2*(50 - xge);
} }
locParms += "&xge="+xge; locParms += '&xge='+xge;
} }
if ( ytell ) { if ( ytell ) {
var yge = parseInt( (y*100)/coords.height ); var yge = parseInt( (y*100)/coords.height );
@ -677,7 +682,7 @@ function controlCmd( control, event, xtell, ytell ) {
} else if ( ytell == 2 ) { } else if ( ytell == 2 ) {
yge = 2*(50 - yge); yge = 2*(50 - yge);
} }
locParms += "&yge="+yge; locParms += '&yge='+yge;
} }
} }
controlReq.send( controlParms+"&control="+control+locParms ); controlReq.send( controlParms+"&control="+control+locParms );