zoneminder/web/skins/classic/views/js/control.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

63 lines
1.4 KiB
JavaScript
Raw Normal View History

var form = $j('#controlForm');
2020-12-20 22:29:39 +08:00
function controlReq(data) {
$j.getJSON(thisUrl + '?view=request&request=control', data)
.done(getControlResponse)
.fail(logAjaxFail);
}
function getControlResponse(respObj, respText) {
if ( !respObj ) {
2017-05-19 01:50:56 +08:00
return;
}
2017-05-19 01:50:56 +08:00
//console.log( respText );
if ( respObj.result != 'Ok' ) {
2020-12-20 22:29:39 +08:00
alert("Control response was status = "+respObj.status+"\nmessage = "+respObj.message);
2017-05-19 01:50:56 +08:00
}
}
2017-05-19 01:50:56 +08:00
function controlCmd( control, event, xtell, ytell ) {
2020-12-20 22:29:39 +08:00
var mid = $j('#mid').getAttribute('value');
2017-05-19 01:50:56 +08:00
if ( event && (xtell || ytell) ) {
2020-12-20 22:29:39 +08:00
var data = {};
var target = $j(event.target);
var offset = target.offset();
var width = target.width();
var height = target.height();
2020-12-20 22:29:39 +08:00
var x = event.pageX - offset.left;
var y = event.pageY - offset.top;
2017-05-19 01:50:56 +08:00
if ( xtell ) {
2020-12-20 22:29:39 +08:00
var xge = parseInt( (x*100)/width );
if ( xtell == -1 ) {
2017-05-19 01:50:56 +08:00
xge = 100 - xge;
} else if ( xtell == 2 ) {
2017-05-19 01:50:56 +08:00
xge = 2*(50 - xge);
}
2020-12-20 22:29:39 +08:00
data.xge = xge;
2017-05-19 01:50:56 +08:00
}
if ( ytell ) {
2020-12-20 22:29:39 +08:00
var yge = parseInt( (y*100)/height );
if ( ytell == -1 ) {
2017-05-19 01:50:56 +08:00
yge = 100 - yge;
} else if ( ytell == 2 ) {
2017-05-19 01:50:56 +08:00
yge = 2*(50 - yge);
}
2020-12-20 22:29:39 +08:00
data.yge = yge;
}
2017-05-19 01:50:56 +08:00
}
2020-12-20 22:29:39 +08:00
data.id = mid;
data.control = control;
controlReq(data);
}
function initPage() {
$j('#mid').change(function() {
form.submit();
});
}
$j(document).ready(initPage);