api tweak

This commit is contained in:
Jeremy Kauffman 2016-03-16 17:56:51 -04:00
parent 7974c66515
commit 8c39a0716f
2 changed files with 13 additions and 12 deletions

View file

@ -6,6 +6,15 @@ var lbry = {
} }
}; };
lbry.call = function(method, params, callback)
{
/*
* XHR magic
*/
//when XHR returns and is successful
// callback(JSON.parse(xhr.responseText));
}
//core //core
lbry.connect = function(callback) lbry.connect = function(callback)
{ {
@ -16,24 +25,16 @@ lbry.connect = function(callback)
}, 1500); }, 1500);
} }
lbry.getBalance = function() lbry.getBalance = function(callback)
{ {
var method = "get_balance"; lbry.call("get_balance", {}, callback);
var request = new XmlRpcRequest("http://localhost:7080/", method);
var amount = Number(request.send().parseXML());
return amount;
} }
lbry.search = function(query, callback) lbry.search = function(query, callback)
{ {
//simulate searching via setTimeout with //simulate searching via setTimeout with
setTimeout(function() { setTimeout(function() {
var method = "search_nametrie" lbry.call("search_nametrie", { query: query }, callback);
var request = new XmlRpcRequest("http://localhost:7080/", method);
request.addParam(query);
var results = request.send().parseXML();
callback(results);
}, 300); }, 300);
} }

View file

@ -11,5 +11,5 @@ if [ $1 != "jeremyisbadatnode" ]; then
babel --presets es2015,react --out-dir dist/js/ --watch js/ babel --presets es2015,react --out-dir dist/js/ --watch js/
else else
#yes I am dumb, but not a high prio fix - Jeremy #yes I am dumb, but not a high prio fix - Jeremy
babel --presets /home/jeremy/local/lib/node_modules/babel-preset-es2015,/home/jeremy/local/lib/node_modules/babel-preset-react --out-dir dist/js/ --watch ~/code/lbry-web-gui/js/ babel --presets /home/jeremy/local/lib/node_modules/babel-preset-es2015,/home/jeremy/local/lib/node_modules/babel-preset-react --out-dir dist/js/ --watch ~/code/lbry-web-ui/js/
fi fi