@ -267,7 +267,7 @@ var Dashboard = function() {
walletDivContent += '<div class="widget widget-shadow">' ;
walletDivContent += '<div class="widget-content text-center bg-white padding-20">' ;
//walletDivContent += '<a href="#" class="avatar margin-bottom-5">';
walletDivContent += '<a class="avatar margin-bottom-5 edexcoin-logo" href="javascript:void(0)" data-edexcoincode="' + AllcoinsDataOutput [ value ] [ index ] + '" data-edexcoinmodecode="' + modecode + '" id="edexcoin-logo">' ;
walletDivContent += '<a class="avatar margin-bottom-5 edexcoin-logo" href="javascript:void(0)" data-edexcoincode="' + AllcoinsDataOutput [ value ] [ index ] + '" data-edexcoinmodecode="' + modecode + '" data-edexcoinname="' + coinname + '" id="edexcoin-logo">' ;
walletDivContent += '<img class="img-responsive" src="assets/images/cryptologo/' + coinlogo + '.png" alt="' + coinname + '"/>' ;
walletDivContent += '<span class="badge up badge-' + modecolor + '" id="basfull" data-edexcoincode="' + AllcoinsDataOutput [ value ] [ index ] + '" data-toggle="tooltip" data-placement="top" data-original-title="' + modetip + '">' + modecode + '</span>' ;
walletDivContent += '</a>' ;
@ -283,7 +283,8 @@ var Dashboard = function() {
$ ( 'span[data-edexcoincode="' + AllcoinsDataOutput [ value ] [ index ] + '"][id="edexcoin-balance"]' ) . parent ( ) . hide ( ) ;
//getBasiliskCoinBalance(AllcoinsDataOutput[value][index])
}
getCoinBalance ( AllcoinsDataOutput [ value ] [ index ] ) ;
getCoinBalance_altfn ( AllcoinsDataOutput [ value ] [ index ] ) ;
$ ( '.scrollbar-dynamic' ) . scrollbar ( ) ; //Make sure widget-body has scrollbar for transactions history
$ ( '[data-toggle="tooltip"]' ) . tooltip ( ) ; //Make sure tooltips are working for wallet widgets and anywhere else in wallet.
//console.log(walletDivContent);
@ -372,6 +373,15 @@ var Dashboard = function() {
}
}
} , 1000 ) ;
var RefreshEdexWalletList = setInterval ( function ( ) {
if ( sessionStorage . getItem ( 'IguanaActiveAccount' ) === null || sessionStorage . getItem ( 'DashboardActions' ) === null || sessionStorage . getItem ( 'DashboardActions' ) === "stop" ) {
clearInterval ( RefreshEdexWalletList ) ;
//console.log('=> No wallet logged in, or Dashboard not ative. No need to Run History.');
} else if ( sessionStorage . getItem ( 'DashboardActions' ) === null || sessionStorage . getItem ( 'DashboardActions' ) === "start" ) {
refreshEDEXCoinWalletList ( )
}
} , 10000 ) ;
}
@ -421,6 +431,7 @@ var Dashboard = function() {
jQuery ( document ) . ready ( function ( ) {
//Dashboard.init();
} ) ;
@ -439,8 +450,10 @@ function edexCoinBtnAction() {
console . log ( $ ( this ) . data ( 'edexcoinmodecode' ) )
var selected_coin = $ ( this ) . data ( 'edexcoincode' )
var selected_coinmode = $ ( this ) . data ( 'edexcoinmodecode' )
var selected_coinname = $ ( this ) . data ( 'edexcoinname' )
sessionStorage . setItem ( 'edexTmpMode' , selected_coinmode ) ;
if ( selected_coinmode == 'Basilisk' ) { $ ( '#edex-footer' ) . hide ( ) ; StopShowCoinHistory ( ) ; }
if ( selected_coinmode == 'Full' ) { $ ( '#edex-footer' ) . show ( ) ; }
if ( selected_coinmode !== 'Native' ) {
$ ( '#edexcoin_dashoard_section' ) . show ( ) ;
$ ( '#header-dashboard' ) . show ( ) ;
@ -457,13 +470,24 @@ function edexCoinBtnAction() {
$ . each ( $ ( '[data-edexcoin]' ) , function ( index , value ) { $ ( '[data-edexcoin]' ) . attr ( "data-edexcoin" , coincode ) ; $ ( '[data-edexcoin="' + coincode + '"]' ) } ) ;
$ . each ( $ ( '[data-edexcoinmenu]' ) , function ( index , value ) { $ ( '[data-edexcoinmenu]' ) . attr ( "data-edexcoinmenu" , coincode ) ; $ ( '[data-edexcoinmenu="' + coincode + '"]' ) } ) ;
$ ( '#edexcoin-active' ) . text ( coincod e) ;
$ ( '#edexcoin-active' ) . text ( selected_coinnam e) ;
//populate selected coin's address
var coinmainaddr = EDEXMainAddr ( coincode ) ;
$ ( '#edexcoin_active_addr' ) . text ( coinmainaddr [ 0 ] ) ;
$ ( '#edexcoin_active_addr_clipboard' ) . attr ( "data-clipboard-text" , coinmainaddr [ 0 ] )
new Clipboard ( '.btn' ) ;
//populate selected coin's balance
if ( selected_coinmode == 'Basilisk' ) {
var tmp_get_coin_balance = EDEXlistunspent ( coincode )
if ( tmp_get_coin_balance [ 0 ] != undefined ) {
console . log ( tmp_get_coin_balance [ 0 ] )
$ ( '#edex_total_balance' ) . text ( tmp_get_coin_balance [ 0 ] . total ) ;
console . log ( tmp_get_coin_balance [ 0 ] . total )
} else {
$ ( '#edex_total_balance' ) . text ( '0' ) ;
}
/ * i f ( s e l e c t e d _ c o i n m o d e = = ' B a s i l i s k ' ) {
var coinwalletbalance = EDEX_DEXlistunspent ( coincode , coinmainaddr [ 0 ] ) ;
console . log ( coinwalletbalance [ 0 ] )
console . log ( coinwalletbalance [ 0 ] . amount )
@ -472,7 +496,7 @@ function edexCoinBtnAction() {
} else {
var coinwalletbalance = EDEXgetBalance ( coincode ) ;
$ ( '#edex_total_balance' ) . text ( coinwalletbalance [ 0 ] ) ;
}
} * /
//getCoinBalance(active_edexcoin);
EdexfillTxHistory ( coincode ) ;
@ -673,7 +697,7 @@ function ShowCoinHistory(getData) {
}
function getCoinBalance ( coin ) {
/ * f u n c t i o n g e t C o i n B a l a n c e ( c o i n ) {
var tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage . getItem ( 'IguanaRPCAuth' ) ;
var ajax_data = { 'userpass' : tmpIguanaRPCAuth , "agent" : "bitcoinrpc" , "method" : "getbalance" , "coin" : coin } ;
//console.log(ajax_data);
@ -699,6 +723,81 @@ function getCoinBalance(coin) {
console . log ( error ) ;
}
} ) ;
} * /
function getCoinBalance_altfn ( coin ) {
NProgress . done ( true ) ;
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>'
} ) ;
NProgress . start ( ) ;
var result = [ ] ;
var tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage . getItem ( 'IguanaRPCAuth' ) ;
var ajax_data = { 'userpass' : tmpIguanaRPCAuth , "coin" : coin , "method" : "listunspent" , "params" : [ ] }
//console.log(ajax_data);
$ . ajax ( {
async : false ,
type : 'POST' ,
data : JSON . stringify ( ajax_data ) ,
url : 'http://127.0.0.1:7778' ,
//dataType: 'text',
success : function ( data , textStatus , jqXHR ) {
var AjaxOutputData = JSON . parse ( data ) ; //Ajax output gets the whole list of unspent coin with addresses
//console.log('== Data OutPut ==');
//console.log(AjaxOutputData);
var unique_addresses = _ . keys ( _ . countBy ( AjaxOutputData , function ( data ) { return data . address ; } ) ) ; //This code using undscore.js takes only the address into an array which are unique in that list
// This function calls each unique address and calculates the total amount of coins in it.
$ . each ( unique_addresses , function ( index ) {
//console.log(unique_addresses[index]);
var unique_addr_tmp_array = _ . where ( AjaxOutputData , { address : unique_addresses [ index ] } ) ;
//console.log(unique_addr_tmp_array);
var tmpcalcnum = 0 ;
$ . each ( unique_addr_tmp_array , function ( index , value ) {
//console.log(value.amount);
tmpcalcnum = tmpcalcnum + value . amount ;
} ) ;
//console.log(tmpcalcnum);
var tmp_addr_total_balance_output = { "addr" : unique_addr_tmp_array [ 0 ] . address , "total" : tmpcalcnum } ;
//console.log(tmp_addr_total_balance_output);
result . push ( tmp_addr_total_balance_output ) ;
} ) ;
//console.log(result[0])
if ( result [ 0 ] != undefined ) {
console . log ( result [ 0 ] )
$ ( 'span[data-edexcoincode="' + coin + '"][id="edexcoin-balance"]' ) . text ( result [ 0 ] . total ) ;
console . log ( result [ 0 ] . total )
} else {
$ ( 'span[data-edexcoincode="' + coin + '"][id="edexcoin-balance"]' ) . text ( '0' ) ;
}
} ,
error : function ( xhr , textStatus , error ) {
console . log ( xhr . statusText ) ;
if ( xhr . readyState == 0 ) {
Iguana_ServiceUnavailable ( ) ;
}
console . log ( textStatus ) ;
console . log ( error ) ;
}
} ) ;
//console.log(result);
NProgress . done ( ) ;
return result ;
}
function getCoinBalance ( coin ) {
var tmp_get_coin_balance = EDEXlistunspent ( coin )
if ( tmp_get_coin_balance [ 0 ] != undefined ) {
//console.log(tmp_get_coin_balance[0])
$ ( 'span[data-edexcoincode="' + coin + '"][id="edexcoin-balance"]' ) . text ( tmp_get_coin_balance [ 0 ] . total ) ;
//console.log(tmp_get_coin_balance[0].total)
} else {
$ ( 'span[data-edexcoincode="' + coin + '"][id="edexcoin-balance"]' ) . text ( '0' ) ;
}
}
function getBasiliskCoinBalance ( coin ) {
@ -715,6 +814,109 @@ function StopShowCoinHistory() {
}
function refreshEDEXCoinWalletList ( ) {
var walletDivContent = '' ;
var AddColumnDiv = 0
$ . each ( [ 'native' , 'basilisk' , 'full' ] , function ( index , value ) {
var tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage . getItem ( 'IguanaRPCAuth' ) ;
var ajax_data = { 'userpass' : tmpIguanaRPCAuth , "agent" : "InstantDEX" , "method" : "allcoins" } ;
//console.log(ajax_data);
$ . ajax ( {
type : 'POST' ,
data : JSON . stringify ( ajax_data ) ,
url : 'http://127.0.0.1:7778' ,
//dataType: 'JSON',
success : function ( data , textStatus , jqXHR ) {
var AllcoinsDataOutput = JSON . parse ( data ) ;
//console.log('== AllCoins Data OutPut ==');
//console.log(value);
//console.log(AllcoinsDataOutput[value]);
$ . each ( AllcoinsDataOutput [ value ] , function ( index ) {
var coinlogo = '' ;
var coinname = '' ;
var modecode = '' ;
var modetip = '' ;
var modecolor = '' ;
if ( value == 'native' ) { modecode = 'Native' ; modetip = 'Native' ; modecolor = 'primary' ; }
if ( value == 'basilisk' ) { modecode = 'Basilisk' ; modetip = 'Basilisk' ; modecolor = 'info' ; }
if ( value == 'full' ) { modecode = 'Full' ; modetip = 'Full' ; modecolor = 'success' ; }
if ( value == 'virtual' ) { modecode = 'Virtual' ; modetip = 'Virtual' ; modecolor = 'danger' ; }
if ( value == 'notarychains' ) { modecode = 'Notarychains' ; modetip = 'Notarychains' ; modecolor = 'dark' ; }
if ( AllcoinsDataOutput [ value ] [ index ] == 'BTC' ) { coinlogo = 'bitcoin' ; coinname = 'Bitcoin' ; }
if ( AllcoinsDataOutput [ value ] [ index ] == 'BTCD' ) { coinlogo = 'bitcoindark' ; coinname = 'BitcoinDark' ; }
if ( AllcoinsDataOutput [ value ] [ index ] == 'LTC' ) { coinlogo = 'litecoin' ; coinname = 'Litecoin' ; }
if ( AllcoinsDataOutput [ value ] [ index ] == 'VPN' ) { coinlogo = 'vpncoin' ; coinname = 'VPNcoin' ; }
if ( AllcoinsDataOutput [ value ] [ index ] == 'SYS' ) { coinlogo = 'syscoin' ; coinname = 'Syscoin' ; }
if ( AllcoinsDataOutput [ value ] [ index ] == 'ZEC' ) { coinlogo = 'zcash' ; coinname = 'Zcash' ; }
if ( AllcoinsDataOutput [ value ] [ index ] == 'NMC' ) { coinlogo = 'namecoin' ; coinname = 'Namecoin' ; }
if ( AllcoinsDataOutput [ value ] [ index ] == 'DEX' ) { coinlogo = 'dex' ; coinname = 'DEX' ; }
if ( AllcoinsDataOutput [ value ] [ index ] == 'DOGE' ) { coinlogo = 'dogecoin' ; coinname = 'Dogecoin' ; }
if ( AllcoinsDataOutput [ value ] [ index ] == 'DGB' ) { coinlogo = 'digibyte' ; coinname = 'Digibyte' ; }
if ( AllcoinsDataOutput [ value ] [ index ] == 'MZC' ) { coinlogo = 'mazacoin' ; coinname = 'Mazacoin' ; }
if ( AllcoinsDataOutput [ value ] [ index ] == 'UNO' ) { coinlogo = 'unobtanium' ; coinname = 'Unobtanium' ; }
if ( AllcoinsDataOutput [ value ] [ index ] == 'ZET' ) { coinlogo = 'zetacoin' ; coinname = 'Zetacoin' ; }
if ( AllcoinsDataOutput [ value ] [ index ] == 'KMD' ) { coinlogo = 'komodo' ; coinname = 'Komodo' ; }
if ( AllcoinsDataOutput [ value ] [ index ] == 'BTM' ) { coinlogo = 'bitmark' ; coinname = 'Bitmark' ; }
if ( AllcoinsDataOutput [ value ] [ index ] == 'CARB' ) { coinlogo = 'carboncoin' ; coinname = 'Carboncoin' ; }
if ( AllcoinsDataOutput [ value ] [ index ] == 'ANC' ) { coinlogo = 'anoncoin' ; coinname = 'AnonCoin' ; }
if ( AllcoinsDataOutput [ value ] [ index ] == 'FRK' ) { coinlogo = 'franko' ; coinname = 'Franko' ; }
//console.log(AllcoinsDataOutput[value][index]);
walletDivContent += '<!-- Wallet Widget ' + AllcoinsDataOutput [ value ] [ index ] + ' -->' ;
walletDivContent += '<div class="list-group-item col-xlg-6 col-lg-12 wallet-widgets-info" data-edexcoincode="' + AllcoinsDataOutput [ value ] [ index ] + '">' ;
walletDivContent += '<div class="widget widget-shadow">' ;
walletDivContent += '<div class="widget-content text-center bg-white padding-20">' ;
//walletDivContent += '<a href="#" class="avatar margin-bottom-5">';
walletDivContent += '<a class="avatar margin-bottom-5 edexcoin-logo" href="javascript:void(0)" data-edexcoincode="' + AllcoinsDataOutput [ value ] [ index ] + '" data-edexcoinmodecode="' + modecode + '" data-edexcoinname="' + coinname + '" id="edexcoin-logo">' ;
walletDivContent += '<img class="img-responsive" src="assets/images/cryptologo/' + coinlogo + '.png" alt="' + coinname + '"/>' ;
walletDivContent += '<span class="badge up badge-' + modecolor + '" id="basfull" data-edexcoincode="' + AllcoinsDataOutput [ value ] [ index ] + '" data-toggle="tooltip" data-placement="top" data-original-title="' + modetip + '">' + modecode + '</span>' ;
walletDivContent += '</a>' ;
walletDivContent += '<div class="coin-name">' + coinname + '</div>' ;
walletDivContent += '<div class="coin-title margin-bottom-20 blue-grey-400"><span data-edexcoincode="' + AllcoinsDataOutput [ value ] [ index ] + '" id="edexcoin-balance">-</span> ' + AllcoinsDataOutput [ value ] [ index ] + '</div>' ;
walletDivContent += '</div>' ;
walletDivContent += '</div>' ;
walletDivContent += '</div>' ;
walletDivContent += '<!-- End Wallet Widget ' + AllcoinsDataOutput [ value ] [ index ] + ' -->' ;
$ ( '.wallet-widgets-row' ) . html ( walletDivContent ) ;
getCoinBalance_altfn ( AllcoinsDataOutput [ value ] [ index ] ) ;
//getCoinBalance_altfn('KMD');
//getCoinBalance('KMD');
/ * i f ( m o d e c o d e = = ' B a s i l i s k ' ) {
$ ( 'span[data-edexcoincode="' + AllcoinsDataOutput [ value ] [ index ] + '"][id="edexcoin-balance"]' ) . parent ( ) . hide ( ) ;
//getBasiliskCoinBalance(AllcoinsDataOutput[value][index])
} * /
$ ( '.scrollbar-dynamic' ) . scrollbar ( ) ; //Make sure widget-body has scrollbar for transactions history
$ ( '[data-toggle="tooltip"]' ) . tooltip ( ) ; //Make sure tooltips are working for wallet widgets and anywhere else in wallet.
//console.log(walletDivContent);
edexCoinBtnAction ( ) ;
} ) ;
} ,
error : function ( xhr , textStatus , error ) {
console . log ( 'failed starting BitcoinDark.' ) ;
console . log ( xhr . statusText ) ;
if ( xhr . readyState == 0 ) {
Iguana_ServiceUnavailable ( ) ;
}
console . log ( textStatus ) ;
console . log ( error ) ;
//swal("Oops...", "Something went wrong!", "error");
if ( xhr . readyState == '0' ) {
toastr . error ( "Unable to connect to Iguana" , "Account Notification" )
}
}
} ) ;
} ) ;
}
function SwitchBasicliskFull ( switch_data ) {
//console.log(switch_data.currency);
//console.log(switch_data.modecode);