diff --git a/js/lbry.js b/js/lbry.js index 9abb5f606..96d161ad9 100644 --- a/js/lbry.js +++ b/js/lbry.js @@ -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 lbry.connect = function(callback) { @@ -16,24 +25,16 @@ lbry.connect = function(callback) }, 1500); } -lbry.getBalance = function() +lbry.getBalance = function(callback) { - var method = "get_balance"; - var request = new XmlRpcRequest("http://localhost:7080/", method); - var amount = Number(request.send().parseXML()); - return amount; + lbry.call("get_balance", {}, callback); } lbry.search = function(query, callback) { //simulate searching via setTimeout with setTimeout(function() { - var method = "search_nametrie" - var request = new XmlRpcRequest("http://localhost:7080/", method); - request.addParam(query); - var results = request.send().parseXML(); - - callback(results); + lbry.call("search_nametrie", { query: query }, callback); }, 300); } diff --git a/watch.sh b/watch.sh index 4eb4c3c21..092143ebb 100755 --- a/watch.sh +++ b/watch.sh @@ -11,5 +11,5 @@ if [ $1 != "jeremyisbadatnode" ]; then babel --presets es2015,react --out-dir dist/js/ --watch js/ else #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