Browse Source

Merge pull request #52 from pbca26/master

iguana_api.js cleanup
master
Satinder Grewal 8 years ago
committed by GitHub
parent
commit
9230bfa79b
  1. 132
      assets/scripts/dashboard.js
  2. 3582
      assets/scripts/iguana_api.js

132
assets/scripts/dashboard.js

@ -105,7 +105,7 @@ var Dashboard = function() {
} }
}); });
} }
EdexfillTxHistory(active_edexcoin); EdexfillTxHistory(active_edexcoin);
$('.edexcoin-send-form')[0].reset(); $('.edexcoin-send-form')[0].reset();
}); });
@ -247,7 +247,7 @@ var Dashboard = function() {
NProgress.start(); NProgress.start();
console.log('Sent control here after clicked in form...'); console.log('Sent control here after clicked in form...');
EDEXMainAddr($('[data-edexcoin]').attr("data-edexcoin")).then(function(result) { EDEXMainAddr($('[data-edexcoin]').attr('data-edexcoin')).then(function(result) {
$('#mdl_confirm_currency_sendfrom_addr').text(result); $('#mdl_confirm_currency_sendfrom_addr').text(result);
}); });
$('#mdl_confirm_currency_sendto_addr').text($('#edexcoin_sendto').val()); $('#mdl_confirm_currency_sendto_addr').text($('#edexcoin_sendto').val());
@ -564,7 +564,7 @@ var Dashboard = function() {
ExecuteAddCoinFn(); ExecuteAddCoinFn();
}); });
$( "#addcoin_select_coin_mdl_options" ).change(function() { $( '#addcoin_select_coin_mdl_options' ).change(function() {
var tmp_coin_val = $('#addcoin_select_coin_mdl_options').val(); var tmp_coin_val = $('#addcoin_select_coin_mdl_options').val();
if (tmp_coin_val !== 'KMD' || tmp_coin_val !== 'KMD' ) { if (tmp_coin_val !== 'KMD' || tmp_coin_val !== 'KMD' ) {
@ -626,7 +626,7 @@ var Dashboard = function() {
}); });
}); });
$(".btn_edexcoin_dashboard_validate").click(function() { $('.btn_edexcoin_dashboard_validate').click(function() {
var selected_coin = $(this).data('edexcoin'); var selected_coin = $(this).data('edexcoin');
EDEXMainAddr(selected_coin).then(function(result) { EDEXMainAddr(selected_coin).then(function(result) {
Iguana_DEXValidateAddr(selected_coin,result); Iguana_DEXValidateAddr(selected_coin,result);
@ -639,6 +639,7 @@ var Dashboard = function() {
var selected_coin = $(this).data('edexcoin'), var selected_coin = $(this).data('edexcoin'),
selected_coin_mode = sessionStorage.getItem('edexTmpMode'), selected_coin_mode = sessionStorage.getItem('edexTmpMode'),
selected_txid = $(this).data('txid'); selected_txid = $(this).data('txid');
$( '#nav-iguana-atomic-explorer' ).trigger( 'click' ); $( '#nav-iguana-atomic-explorer' ).trigger( 'click' );
$('#atomic_explorer_select_coin_options option[value=' + selected_coin + ']').attr('selected', 'selected'); $('#atomic_explorer_select_coin_options option[value=' + selected_coin + ']').attr('selected', 'selected');
if ( selected_coin_mode == 'Full') { if ( selected_coin_mode == 'Full') {
@ -930,7 +931,7 @@ function edexCoinBtnAction() {
} }
}); });
} }
EdexfillTxHistory(coincode); EdexfillTxHistory(coincode);
} else { } else {
$('#currency-progressbars').hide(); $('#currency-progressbars').hide();
@ -959,7 +960,7 @@ function getActiveEdexcoin() {
}*/ }*/
function EdexfillTxHistory(coin) { function EdexfillTxHistory(coin) {
$('#edexcoin_txhistory').data('panel-api').load() $('#edexcoin_txhistory').data('panel-api').load();
NProgress.done(true); NProgress.done(true);
NProgress.configure({ NProgress.configure({
template: '<div class="bar nprogress-bar-header nprogress-bar-info" role="bar"></div>' + template: '<div class="bar nprogress-bar-header nprogress-bar-info" role="bar"></div>' +
@ -992,8 +993,8 @@ function EdexfillTxHistory(coin) {
select: true, select: true,
retrieve: true retrieve: true
}); });
$('#edexcoin_txhistory').data('panel-api').done() $('#edexcoin_txhistory').data('panel-api').done();
$('.panel-loading').remove() $('.panel-loading').remove();
}); });
} }
@ -1018,8 +1019,8 @@ function EdexfillTxHistory(coin) {
select: true, select: true,
retrieve: true retrieve: true
}); });
$('#edexcoin_txhistory').data('panel-api').done() $('#edexcoin_txhistory').data('panel-api').done();
$('.panel-loading').remove() $('.panel-loading').remove();
}); });
} }
} }
@ -1033,10 +1034,10 @@ function getDEXCoinBalance(coin) {
function getDEXGetBalance(coin) { function getDEXGetBalance(coin) {
NProgress.done(true); NProgress.done(true);
NProgress.configure({ NProgress.configure({
template: '<div class="bar nprogress-bar-header nprogress-bar-info" role="bar"></div>' + template: '<div class="bar nprogress-bar-header nprogress-bar-info" role="bar"></div>' +
'<div class="spinner" role="spinner">' + '<div class="spinner" role="spinner">' +
'<div class="spinner-icon"></div>' + '<div class="spinner-icon"></div>' +
'</div>' '</div>'
}); });
NProgress.start(); NProgress.start();
return new Promise((resolve) => { return new Promise((resolve) => {
@ -1104,66 +1105,61 @@ function getDEXGetBalance(coin) {
}); });
} }
function getDEXGetBalance_cache(coin) { function getDEXGetBalance_cache(coin) {
NProgress.done(true); NProgress.done(true);
NProgress.configure({ NProgress.configure({
template: '<div class="bar nprogress-bar-header nprogress-bar-info" role="bar"></div><div class="spinner" role="spinner"><div class="spinner-icon"></div></div>' template: '<div class="bar nprogress-bar-header nprogress-bar-info" role="bar"></div>' +
'<div class="spinner" role="spinner">' +
'<div class="spinner-icon"></div>' +
'</div>'
}); });
NProgress.start(); NProgress.start();
return new Promise((resolve) =>{
Shepherd_GetBasiliskCache().then(function(result){ return new Promise((resolve) => {
var _data = JSON.parse(result) Shepherd_GetBasiliskCache().then(function(result) {
var query = _data.result.basilisk var _data = JSON.parse(result),
//console.log(query[coin].addresses) query = _data.result.basilisk,
total_balance = 0,
var total_balance = 0 total_interest = 0;
var total_interest = 0
Promise.all(query[coin].addresses.map((coinaddr_value,coinaddr_index) => { Promise.all(query[coin].addresses.map((coinaddr_value,coinaddr_index) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
//console.log(coinaddr_index) if ( query[coin][coinaddr_value].getbalance !== undefined ) {
//console.log(coinaddr_value) var data = query[coin][coinaddr_value].getbalance;
if ( query[coin][coinaddr_value].getbalance !== undefined ) {
var data = query[coin][coinaddr_value].getbalance total_balance = parseFloat(total_balance) + parseFloat(data.balance);
//console.log(data) if (data.interest !== undefined) {
total_balance = parseFloat(total_balance) + parseFloat(data.balance) total_interest = parseFloat(total_interest) + parseFloat(data.interest);
if (data.interest !== undefined) { total_final = parseFloat(total_balance) + parseFloat(total_interest);
//console.log('interest is found') pass_data = {
//console.log(data) 'total': total_balance.toFixed(8),
total_interest = parseFloat(total_interest) + parseFloat(data.interest) 'interest': total_interest.toFixed(8),
total_final = parseFloat(total_balance) + parseFloat(total_interest) 'totalbalance': total_final.toFixed(8)
pass_data = {"total":total_balance.toFixed(8),"interest":total_interest.toFixed(8),"totalbalance":total_final.toFixed(8)} };
} }
if (data.interest == undefined) { if (data.interest == undefined) {
//console.log('interest NOT found') if (isNaN(total_balance)) {
//console.log(data) total_balance = parseFloat(0);
//console.log(total_balance)
if(isNaN(total_balance)) {
total_balance = parseFloat(0)
}
pass_data = {"total":total_balance.toFixed(8)}
} }
} else { pass_data = { 'total': total_balance.toFixed(8) };
//console.log('Balance NOT found')
//console.log(data)
pass_data = {"total":0.00000000}
} }
//console.log(pass_data)
//return pass_data
resolve(pass_data)
})
})).then(result => {
//console.log(result)
//console.log(result[result.length-1])
if ( result[result.length-1].total == 0 ) {
resolve(result[result.length-2])
} else { } else {
resolve(result[result.length-1]) pass_data = { 'total': 0.00000000 };
} }
NProgress.done();
}) resolve(pass_data)
}) })
}) })).then(result => {
if ( result[result.length - 1].total == 0 ) {
resolve(result[result.length - 2]);
} else {
resolve(result[result.length - 1]);
}
NProgress.done();
});
});
});
} }
function getDEXGetBalance2(coin) { function getDEXGetBalance2(coin) {
@ -1794,9 +1790,9 @@ function EdexGetTxList(coin) {
} else { } else {
params = { params = {
'userpass': tmpIguanaRPCAuth, 'userpass': tmpIguanaRPCAuth,
"coin": coin, 'coin': coin,
"method": "listtransactions", 'method': 'listtransactions',
"params": [ 'params': [
0, 0,
9999999, 9999999,
[] []
@ -1838,8 +1834,10 @@ function EdexGetTxList(coin) {
( active_edexcoinmodecode == 'Basilisk' && coin == 'CARB' ) || ( active_edexcoinmodecode == 'Basilisk' && coin == 'CARB' ) ||
( active_edexcoinmodecode == 'Basilisk' && coin == 'ANC' ) || ( active_edexcoinmodecode == 'Basilisk' && coin == 'ANC' ) ||
( active_edexcoinmodecode == 'Basilisk' && coin == 'FRK' ) ) { ( active_edexcoinmodecode == 'Basilisk' && coin == 'FRK' ) ) {
var tmp_category = '', var tmp_category = '',
tmp_amount = result_data[index].amount; tmp_amount = result_data[index].amount;
if (!('amount' in result_data[index])) { if (!('amount' in result_data[index])) {
tmp_amount = '<span class="label label-dark">Unknown</span>'; tmp_amount = '<span class="label label-dark">Unknown</span>';
} }

3582
assets/scripts/iguana_api.js

File diff suppressed because it is too large
Loading…
Cancel
Save