2009-04-01 16:37:10 +08:00
|
|
|
var controlParms = "view=request&request=control";
|
|
|
|
var controlReq = new Request.JSON( { url: thisUrl, method: 'post', timeout: AJAX_TIMEOUT, onSuccess: getControlResponse } );
|
|
|
|
|
|
|
|
function getControlResponse( respObj, respText )
|
|
|
|
{
|
|
|
|
if ( !respObj )
|
|
|
|
return;
|
|
|
|
//console.log( respText );
|
|
|
|
if ( respObj.result != 'Ok' )
|
|
|
|
{
|
|
|
|
alert( "Control response was status = "+respObj.status+"\nmessage = "+respObj.message );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function controlCmd( control, event, xtell, ytell )
|
|
|
|
{
|
|
|
|
var locParms = "&id="+$('mid').get('value');
|
|
|
|
if ( event && (xtell || ytell) )
|
|
|
|
{
|
|
|
|
var xEvent = new Event( event );
|
|
|
|
var target = xEvent.target;
|
|
|
|
var coords = $(target).getCoordinates();
|
|
|
|
|
|
|
|
var l = coords.left;
|
|
|
|
var t = coords.top;
|
|
|
|
var x = xEvent.page.x - l;
|
|
|
|
var y = xEvent.page.y - t;
|
|
|
|
|
2017-03-18 15:00:51 +08:00
|
|
|
if ( xtell )
|
2009-04-01 16:37:10 +08:00
|
|
|
{
|
|
|
|
var xge = parseInt( (x*100)/coords.width );
|
|
|
|
if ( xtell == -1 )
|
|
|
|
xge = 100 - xge;
|
|
|
|
else if ( xtell == 2 )
|
|
|
|
xge = 2*(50 - xge);
|
|
|
|
locParms += "&xge="+xge;
|
|
|
|
}
|
2017-03-18 15:00:51 +08:00
|
|
|
if ( ytell )
|
2009-04-01 16:37:10 +08:00
|
|
|
{
|
|
|
|
var yge = parseInt( (y*100)/coords.height );
|
|
|
|
if ( ytell == -1 )
|
|
|
|
yge = 100 - yge;
|
|
|
|
else if ( ytell == 2 )
|
|
|
|
yge = 2*(50 - yge);
|
|
|
|
locParms += "&yge="+yge;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
controlReq.send( controlParms+"&control="+control+locParms );
|
|
|
|
}
|