vineetbhargav86
9 years ago
6 changed files with 298 additions and 0 deletions
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 121 KiB |
After Width: | Height: | Size: 100 KiB |
After Width: | Height: | Size: 7.9 KiB |
@ -0,0 +1,132 @@ |
|||
/* |
|||
* To change this license header, choose License Headers in Project Properties. |
|||
* To change this template file, choose Tools | Templates |
|||
* and open the template in the editor. |
|||
*/ |
|||
|
|||
var prevXY={"X":0,"Y":0}; |
|||
var prevID=0; |
|||
|
|||
$(document).ready(function() { |
|||
loadImages(); |
|||
|
|||
|
|||
$('.imagAPI').click(function(e){ |
|||
e = window.event ? event.srcElement : e.target; |
|||
var id=e.getAttribute('data-id'); |
|||
var imagename=document.getElementById('name-imagAPI-'+id).value; |
|||
console.log("Clicked on image"+id); |
|||
|
|||
$.ajax({ |
|||
type: "GET", |
|||
url: "http://127.0.0.1:7778/api/mouse/click/name/"+imagename+"/x/"+Math.round(prevXY.X)+"/y/"+Math.round(prevXY.Y), |
|||
success: function( response ) { |
|||
console.log('AJAX Response is ' + response); |
|||
//if(typeof callback === 'function'){
|
|||
//callback(request, response);
|
|||
//}
|
|||
} |
|||
}); |
|||
}); |
|||
}); |
|||
|
|||
|
|||
var loadImages=function(){ |
|||
for(var i=1;i<=10;i++){ |
|||
|
|||
var img = document.getElementById("src-imagAPI-"+i); |
|||
var canvas = document.createElement('canvas'); |
|||
canvas.width = img.naturalWidth; |
|||
canvas.height = img.naturalHeight; |
|||
var context = canvas.getContext('2d'); |
|||
|
|||
//alert(img.src);
|
|||
context.drawImage(img, 0, 0 ); |
|||
var dataURL = {data:canvas.toDataURL('image/jpg'),height:img.height,width:img.width,type:'JPG'}; |
|||
var name='imagedata-'+i; |
|||
if(typeof localStorage !== 'undefined'){ |
|||
localStorage[name]=JSON.stringify(dataURL); |
|||
}else{ |
|||
chrome.storage.local.set({name: JSON.stringify(dataURL)}); |
|||
} |
|||
$("#dest-imagAPI-"+i).attr('src', dataURL.data); |
|||
|
|||
} |
|||
|
|||
}; |
|||
|
|||
$('.imagAPI').mousemove(function(e){ |
|||
//e = window.event ? event.srcElement : e.target;
|
|||
|
|||
|
|||
var id=event.srcElement.getAttribute('data-id'); |
|||
|
|||
var imagename=document.getElementById('name-imagAPI-'+id).value; |
|||
|
|||
var parentOffset = $("#dest-imagAPI-"+id).offset(); |
|||
var relX=e.pageX-parentOffset.left; |
|||
var relY=e.pageY-parentOffset.top; |
|||
prevXY.X=relX; |
|||
prevXY.Y=relY; |
|||
|
|||
if(prevID!==id){ |
|||
prevID=id; |
|||
|
|||
$.ajax({ |
|||
type: "GET", |
|||
url: "http://127.0.0.1:7778/api/mouse/image/name/"+imagename+"/x/"+Math.round(relX)+"/y/"+Math.round(relY), |
|||
success: function( response ) { |
|||
console.log('AJAX Response is ' + response); |
|||
//if(typeof callback === 'function'){
|
|||
//callback(request, response);
|
|||
//}
|
|||
} |
|||
}); |
|||
} |
|||
document.getElementById('mousexy').innerHTML="parent offset x:"+relX+" y:"+relY; |
|||
|
|||
console.log("Moved mouse on image "+id+" imagename "+imagename); |
|||
|
|||
console.log("calling API"); |
|||
// {"agent":"mouse","method":"image","name":"bitmap.jpg","x":<width>,"y":<height>}
|
|||
$.ajax({ |
|||
type: "GET", |
|||
url: "http://127.0.0.1:7778/api/mouse/change/name/"+imagename+"/x/"+Math.round(relX)+"/y/"+Math.round(relY), |
|||
success: function( response ) { |
|||
console.log('AJAX Response is ' + response); |
|||
//if(typeof callback === 'function'){
|
|||
//callback(request, response);
|
|||
//}
|
|||
} |
|||
}); |
|||
|
|||
|
|||
}); |
|||
|
|||
/* |
|||
* Function to test filesystem Access |
|||
*/ |
|||
|
|||
function filesystem_save(){ |
|||
|
|||
fileSystem.root.getFile('confs/iguana.4206523045167609019', {}, function(fileEntry) { |
|||
|
|||
// Get a File object representing the file,
|
|||
// then use FileReader to read its contents.
|
|||
fileEntry.file(function(file) { |
|||
var reader = new FileReader(); |
|||
|
|||
reader.onloadend = function(e) { |
|||
//var txtArea = document.createElement('textarea');
|
|||
console.log("Configuration file text: "+this.result.toString()); |
|||
console.log("Full path is:"+fileEntry.fullPath); |
|||
//document.body.appendChild(txtArea);
|
|||
document.getElementById('mousexy').innerHTML=this.result; |
|||
}; |
|||
|
|||
reader.readAsText(file); |
|||
}, errorHandler); |
|||
|
|||
}, errorHandler); |
|||
|
|||
} |
@ -0,0 +1,166 @@ |
|||
var pages = [ |
|||
{value:"InstantDEX", width:100,"click":InstantDEX}, |
|||
{ view:"button", value:"pangea", width:100,"click":Pangea }, |
|||
{ view:"button", value:"Jumblr", width:100,"click":Jumblr }, |
|||
{ view:"button", value:"Atomic", width:100,"click":Atomic }, |
|||
{ view:"button", value:"MGW", width:100,"click":MGW }, |
|||
{ view:"button", value:"PAX", width:100,"click":PAX }, |
|||
{ view:"button", value:"Wallet", width:100,"click":Wallet }, |
|||
{ view:"button", value:"Debug", width:100,"click":debuglog } |
|||
]; |
|||
|
|||
|
|||
var SPNAPI = (function(SPNAPI, $, undefined) { |
|||
|
|||
SPNAPI.methods.instantDEX = [ |
|||
{"id":1,"method":"allorderbooks","base":"","rel":"","exchange":"","price":"","volume":""}, |
|||
{"id":2,"method":"allexchanges","base":"","rel":"","exchange":"","price":"","volume":""}, |
|||
{"id":2,"method":"openorders","base":"","rel":"","exchange":"","price":"","volume":""}, |
|||
{"id":3,"method":"orderbook","base":"base","rel":"rel","exchange":"active","price":"","volume":""}, |
|||
{"id":4,"method":"placeask","base":"base","rel":"rel","exchange":"active","price":"price","volume":"volume"}, |
|||
{"id":5,"method":"placebid","base":"base","rel":"rel","exchange":"active","price":"price","volume":"volume"}, |
|||
{"id":6,"method":"orderstatus","base":"","rel":"","exchange":"","price":"","volume":"","orderid":"orderid"}, |
|||
{"id":7,"method":"cancelorder","base":"","rel":"","exchange":"","price":"","volume":"","orderid":"orderid"}, |
|||
{"id":8,"method":"enablequotes","base":"base","rel":"rel","exchange":"exchange","price":"","volume":""}, |
|||
{"id":9,"method":"disablequotes","base":"base","rel":"rel","exchange":"exchange","price":"","volume":""}, |
|||
{"id":10,"method":"lottostats","base":"","rel":"","exchange":"","price":"","volume":""}, |
|||
{"id":11,"method":"tradehistory","base":"","rel":"","exchange":"","price":"","volume":""}, |
|||
{"id":12,"method":"balance","base":"","rel":"","exchange":"exchange","price":"","volume":""}, |
|||
{"id":13,"method":"peggyrates","base":"base","rel":"","exchange":"","price":"","volume":""} |
|||
]; |
|||
|
|||
SPNAPI.methods.pangea = [ |
|||
{"id":1,"method":"start","base":"base","maxplayers":"maxplayers","bigblind":"bigblind","ante":"ante","hostrake":"hostrake"}, |
|||
{"id":2,"method":"status","tableid":"tableid"}, |
|||
{"id":3,"method":"turn","tableid":"tableid"}, |
|||
{"id":4,"method":"mode"}, |
|||
{"id":5,"method":"buyin","tableid":"tableid"}, |
|||
{"id":6,"method":"history","tableid":"tableid","handid":"handid"}, |
|||
{"id":7,"method":"rates","base":"base"}, |
|||
{"id":8,"method":"lobby"}, |
|||
{"id":9,"method":"tournaments"}, |
|||
{"id":10,"method":"rosetta","base":"base"} |
|||
]; |
|||
|
|||
SPNAPI.methods.jumblr = [ |
|||
{"id":1,"method":"jumblr","base":"base","maxplayers":"maxplayers","bigblind":"bigblind","ante":"ante"}, |
|||
{"id":2,"method":"status","tableid":"tableid"} |
|||
]; |
|||
|
|||
SPNAPI.methods.mgw =[ |
|||
{"id":1,"method":"MGW","base":"base","maxplayers":"maxplayers","bigblind":"bigblind","ante":"ante"}, |
|||
{"id":2,"method":"status","tableid":"tableid"} |
|||
]; |
|||
|
|||
SPNAPI.methods.atomic = [ |
|||
{"id":1,"method":"atomic","base":"base","maxplayers":"maxplayers","bigblind":"bigblind","ante":"ante"}, |
|||
{"id":2,"method":"status","tableid":"tableid"} |
|||
]; |
|||
|
|||
SPNAPI.methods.pax = [ |
|||
{"id":1,"method":"peggy","base":"base","maxplayers":"maxplayers","bigblind":"bigblind","ante":"ante"}, |
|||
{"id":2,"method":"status","tableid":"tableid"} |
|||
]; |
|||
|
|||
SPNAPI.methods.wallet = [ |
|||
{"id":1,"method":"wallet","base":"base","maxplayers":"maxplayers","bigblind":"bigblind","ante":"ante"}, |
|||
{"id":2,"method":"status","tableid":"tableid"} |
|||
]; |
|||
|
|||
|
|||
return SPNAPI; |
|||
}(SPNAPI || {}, jQuery)); |
|||
|
|||
|
|||
|
|||
var api_request = function(agent) |
|||
{ |
|||
var jsonstr = '';//$$("apirequest").getValues().jsonstr;
|
|||
var base = $$("formA").getValues().base; |
|||
var rel = $$("formB").getValues().rel; |
|||
var exchange = $$("formC").getValues().exchange; |
|||
var price = $$("formD").getValues().price; |
|||
var volume = $$("formE").getValues().volume; |
|||
var orderid = $$("formF").getValues().orderid; |
|||
var method = $$("method").getValues().method; |
|||
var request = '{"agent":"' + agent + '","method":"' + method + '","base":"' + base + '","rel":"' + rel + '","exchange":"' + exchange + '","price":"' + price + '","volume":"' + volume + '","orderid":"' + orderid + '"' + jsonstr + '}'; |
|||
return(request); |
|||
} |
|||
|
|||
function submit_request(e) |
|||
{ |
|||
var request = $$("apirequest").getValues().jsonstr; |
|||
postCall('SuperNET', request, function(jsonstr) |
|||
{ |
|||
$$("debuglog").add({value:jsonstr},0); |
|||
common.logMessage(jsonstr + '\n'); |
|||
}); |
|||
} |
|||
|
|||
function InstantDEX(e) |
|||
{ |
|||
$$('list').data.sync(Idata); |
|||
request = api_request('InstantDEX'); |
|||
$$("submitstr").setValue(request); |
|||
/*postCall('SuperNET', request, function(jsonstr) |
|||
{ |
|||
$$("debuglog").add({value:jsonstr},0); |
|||
common.logMessage(jsonstr + '\n'); |
|||
});*/ |
|||
} |
|||
|
|||
function Pangea(e) |
|||
{ |
|||
$$('list').data.sync(Pdata); |
|||
request = api_request('pangea'); |
|||
$$("submitstr").setValue(request); |
|||
} |
|||
|
|||
function Jumblr(e) |
|||
{ |
|||
$$('list').data.sync(Jdata); |
|||
request = api_request('jumblr'); |
|||
$$("submitstr").setValue(request); |
|||
} |
|||
|
|||
function MGW(e) |
|||
{ |
|||
$$('list').data.sync(Mdata); |
|||
request = api_request('MGW'); |
|||
$$("submitstr").setValue(request); |
|||
} |
|||
|
|||
function Atomic(e) |
|||
{ |
|||
$$('list').data.sync(Adata); |
|||
request = api_request('atomic'); |
|||
$$("submitstr").setValue(request); |
|||
} |
|||
|
|||
function PAX(e) |
|||
{ |
|||
$$('list').data.sync(Xdata); |
|||
request = api_request('peggy'); |
|||
$$("submitstr").setValue(request); |
|||
} |
|||
|
|||
function Wallet(e) |
|||
{ |
|||
$$('list').data.sync(Wdata); |
|||
request = api_request('wallet'); |
|||
$$("submitstr").setValue(request); |
|||
} |
|||
|
|||
var debug_on = 0; |
|||
function debuglog(e) { |
|||
if ( debug_on == 0 ) |
|||
{ |
|||
$(".debuglog").show(); |
|||
debug_on = 1; |
|||
} |
|||
else |
|||
{ |
|||
$(".debuglog").hide(); |
|||
debug_on = 0; |
|||
} |
|||
} |
Loading…
Reference in new issue