2020-10-04 10:44:24 +08:00
|
|
|
var form = $j('#controlForm');
|
2009-04-01 16:37:10 +08:00
|
|
|
|
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) {
|
2019-01-19 23:32:40 +08:00
|
|
|
if ( !respObj ) {
|
2017-05-19 01:50:56 +08:00
|
|
|
return;
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
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
|
|
|
}
|
2009-04-01 16:37:10 +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();
|
2009-04-01 16:37:10 +08:00
|
|
|
|
2020-12-20 22:29:39 +08:00
|
|
|
var x = event.pageX - offset.left;
|
|
|
|
var y = event.pageY - offset.top;
|
2009-04-01 16:37:10 +08:00
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
if ( xtell ) {
|
2020-12-20 22:29:39 +08:00
|
|
|
var xge = parseInt( (x*100)/width );
|
2019-01-19 23:32:40 +08:00
|
|
|
if ( xtell == -1 ) {
|
2017-05-19 01:50:56 +08:00
|
|
|
xge = 100 - xge;
|
2019-01-19 23:32:40 +08:00
|
|
|
} else if ( xtell == 2 ) {
|
2017-05-19 01:50:56 +08:00
|
|
|
xge = 2*(50 - xge);
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
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 );
|
2019-01-19 23:32:40 +08:00
|
|
|
if ( ytell == -1 ) {
|
2017-05-19 01:50:56 +08:00
|
|
|
yge = 100 - yge;
|
2019-01-19 23:32:40 +08:00
|
|
|
} else if ( ytell == 2 ) {
|
2017-05-19 01:50:56 +08:00
|
|
|
yge = 2*(50 - yge);
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2020-12-20 22:29:39 +08:00
|
|
|
data.yge = yge;
|
2009-04-01 16:37:10 +08:00
|
|
|
}
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
2020-12-20 22:29:39 +08:00
|
|
|
data.id = mid;
|
|
|
|
data.control = control;
|
|
|
|
controlReq(data);
|
2009-04-01 16:37:10 +08:00
|
|
|
}
|
2020-10-04 10:44:24 +08:00
|
|
|
|
|
|
|
function initPage() {
|
|
|
|
$j('#mid').change(function() {
|
|
|
|
form.submit();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
$j(document).ready(initPage);
|