From 23a7d60e1701abe413bd8de27d6d83f58d916d95 Mon Sep 17 00:00:00 2001 From: Satinder Grewal Date: Thu, 18 May 2017 21:12:30 +1200 Subject: [PATCH] Check Wallet Balance step and code added --- index.html | 38 +++++++++++++++++++++ js/dexactions.js | 86 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) diff --git a/index.html b/index.html index 8a345da..15b1862 100644 --- a/index.html +++ b/index.html @@ -214,6 +214,44 @@ +
+ +
+
+ +
+
+ + + +
+
+ +
+
Coin:
+
+ + + +
Main Address
Balance
+
+ +
+
+ +
+

+                  
+ +
+
+
diff --git a/js/dexactions.js b/js/dexactions.js index 3340ed3..815c969 100644 --- a/js/dexactions.js +++ b/js/dexactions.js @@ -192,3 +192,89 @@ $('.dexratio-btn').click(function() { }); }) + +$('.showwalletinfo').click(function() { + var ajax_data = {"agent":"SuperNET","method":"activehandle"}; + var url = "http://127.0.0.1:7778/"; + + $.ajax({ + data: JSON.stringify(ajax_data), + dataType: 'json', + type: 'POST', + url: 'http://127.0.0.1:7778' + }).done(function(data) { + // If successful + console.log(data); + $('.checkwallet-output').html(JSON.stringify(data, null, 2)); + }).fail(function(jqXHR, textStatus, errorThrown) { + // If fail + console.log(textStatus + ': ' + errorThrown); + }); +}) + + +$('.show-btcbalance').click(function() { + var ajax_activehandle = {"agent":"SuperNET","method":"activehandle"}; + var url = "http://127.0.0.1:7778/"; + + var a1 = $.ajax({ + data: JSON.stringify(ajax_activehandle), + dataType: 'json', + type: 'POST', + url: 'http://127.0.0.1:7778' + }), + a2 = a1.then(function(data) { + console.log(data); + $('.coin_mainaddr').html(data.BTC); + $('.coin_id').html('Bitcoin (BTC)') + var ajax_dexgetbalance = {"agent":"dex","method":"getbalance","address":data.BTC,"symbol":"BTC"} + //return data + // .then() returns a new promise + return $.ajax({ + data: JSON.stringify(ajax_dexgetbalance), + dataType: 'json', + type: 'POST', + url: 'http://127.0.0.1:7778' + }); + }); + + a2.done(function(data) { + console.log(data); + $('.checkwallet-output').html(JSON.stringify(data, null, 2)); + $('.coin_balance').html(data.balance); + }); +}) + + +$('.show-kmdbalance').click(function() { + var ajax_activehandle = {"agent":"SuperNET","method":"activehandle"}; + var url = "http://127.0.0.1:7778/"; + + var a1 = $.ajax({ + data: JSON.stringify(ajax_activehandle), + dataType: 'json', + type: 'POST', + url: 'http://127.0.0.1:7778' + }), + a2 = a1.then(function(data) { + console.log(data); + $('.coin_mainaddr').html(data.KMD); + $('.coin_id').html('Komodo (KMD)') + var ajax_dexgetbalance = {"agent":"dex","method":"getbalance","address":data.KMD,"symbol":"KMD"} + //return data + // .then() returns a new promise + return $.ajax({ + data: JSON.stringify(ajax_dexgetbalance), + dataType: 'json', + type: 'POST', + url: 'http://127.0.0.1:7778' + }); + }); + + a2.done(function(data) { + console.log(data); + $('.checkwallet-output').html(JSON.stringify(data, null, 2)); + $('.coin_balance').html(data.balance); + }); +}) +