You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
263 lines
8.3 KiB
263 lines
8.3 KiB
jQuery(document).ready(function() {
|
|
// KMDWalletDashboard.init();
|
|
// TODO: refactor
|
|
var RunNativeProgressBar = setInterval(function() {
|
|
if ( sessionStorage.getItem('IguanaActiveAccount') === null ||
|
|
sessionStorage.getItem('NativeWalletActions') === null ||
|
|
sessionStorage.getItem('NativeWalletActions') === 'stop' ) {
|
|
//clearInterval(RunNativeProgressBar);
|
|
//console.log('=> No wallet logged in, or Native Wallet not ative. No need to Run Progress Bar code.');
|
|
} else if ( sessionStorage.getItem('NativeWalletActions') !== null || sessionStorage.getItem('NativeWalletActions') === 'start') {
|
|
KMD_ProgressBar();
|
|
}
|
|
}, 5000);
|
|
|
|
var RefreshEdexWalletDashboard = setInterval(function() {
|
|
if ( sessionStorage.getItem('IguanaActiveAccount') === null ||
|
|
sessionStorage.getItem('NativeWalletActions') === null ||
|
|
sessionStorage.getItem('NativeWalletActions') === 'stop' ) {
|
|
clearInterval(RefreshEdexWalletDashboard);
|
|
//console.log('=> No wallet logged in, or Dashboard not ative. No need to Run History.');
|
|
} else if ( sessionStorage.getItem('NativeWalletActions') === null || sessionStorage.getItem('NativeWalletActions') === 'start') {
|
|
if ( $('[data-data-extcoin]').attr('data-data-extcoin') !== 'COIN' ) {
|
|
if ( sessionStorage.getItem('edexTmpMode') !== null || sessionStorage.getItem('edexTmpMode') === 'Native') {
|
|
if ( sessionStorage.getItem('edexTmpRefresh') === null || sessionStorage.getItem('edexTmpRefresh') === 'start') {
|
|
//console.log('it is not COIN. '+'It is: ' + $('[data-data-extcoin]').attr("data-data-extcoin"));
|
|
var action_btn_code = getHeaderActionMenuButtonCoinCode();
|
|
$( '#btn_' + action_btn_code + '_wallet_dashboard' ).trigger( 'click' );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}, 30000);
|
|
});
|
|
|
|
function getHeaderActionMenuButtonCoinCode() {
|
|
var extcoin = $('[data-extcoin]').attr('data-extcoin'),
|
|
action_menu_button_code = '';
|
|
|
|
if ( extcoin == 'KMD') { action_menu_button_code = 'kmd'; };
|
|
if ( extcoin == 'ZEC') { action_menu_button_code = 'zec'; };
|
|
|
|
if (checkAC(extcoin)) { action_menu_button_code = 'acpax'; };
|
|
|
|
return action_menu_button_code;
|
|
}
|
|
|
|
function getPassthruAgent() {
|
|
var extcoin = $('[data-extcoin]').attr('data-extcoin');
|
|
passthru_agent = '';
|
|
|
|
console.log(extcoin);
|
|
|
|
if ( extcoin == 'KMD') { passthru_agent = 'komodo'; };
|
|
if ( extcoin == 'ZEC') { passthru_agent = 'zcash'; };
|
|
|
|
if (checkAC(extcoin)) { passthru_agent = 'iguana'; };
|
|
|
|
return passthru_agent;
|
|
}
|
|
|
|
function CheckIfConnected() {
|
|
var result = [],
|
|
extcoin = $('[data-extcoin]').attr('data-extcoin'),
|
|
passthru_agent = getPassthruAgent(),
|
|
tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth');
|
|
|
|
if (passthru_agent == 'iguana') {
|
|
var ajax_data = {
|
|
'userpass': tmpIguanaRPCAuth,
|
|
'agent': passthru_agent,
|
|
'method': 'passthru',
|
|
'asset': $('[data-extcoin]').attr('data-extcoin'),
|
|
'function': 'getinfo',
|
|
'hex': ''
|
|
};
|
|
} else {
|
|
var ajax_data = {
|
|
'userpass': tmpIguanaRPCAuth,
|
|
'agent': passthru_agent,
|
|
'method': 'passthru',
|
|
'function': 'getinfo',
|
|
'hex': ''
|
|
};
|
|
}
|
|
|
|
console.log(ajax_data);
|
|
$.ajax({
|
|
async: false,
|
|
type: 'POST',
|
|
data: JSON.stringify(ajax_data),
|
|
url: 'http://127.0.0.1:' + config.iguanaPort,
|
|
success: function(data, textStatus, jqXHR) {
|
|
var AjaxOutputData = JSON.parse(data);
|
|
//console.log('== Data OutPut ==');
|
|
//console.log(AjaxOutputData);
|
|
//console.log(AjaxOutputData.error);
|
|
|
|
if ( AjaxOutputData.errors != undefined ) {
|
|
result.push('connected');
|
|
} else if ( AjaxOutputData['error'].message = 'Activating best chain...' ) {
|
|
result.push('activating');
|
|
} else if ( AjaxOutputData.errors == undefined) {
|
|
result.push('not active');
|
|
} else {
|
|
result.push(AjaxOutputData.errors);
|
|
}
|
|
},
|
|
error: function(xhr, textStatus, error) {
|
|
console.log('failed getting Coin History.');
|
|
console.log(xhr.statusText);
|
|
if ( xhr.readyState == 0 ) {
|
|
Iguana_ServiceUnavailable();
|
|
}
|
|
console.log(textStatus);
|
|
console.log(error);
|
|
}
|
|
});
|
|
|
|
return result;
|
|
}
|
|
|
|
function CheckIfWalletEncrypted() {
|
|
var result = [],
|
|
passthru_agent = getPassthruAgent(),
|
|
tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth');
|
|
|
|
if (passthru_agent == 'iguana') {
|
|
var ajax_data = {
|
|
'userpass': tmpIguanaRPCAuth,
|
|
'agent': passthru_agent,
|
|
'method': 'passthru',
|
|
'asset': $('[data-extcoin]').attr('data-extcoin'),
|
|
'function': 'walletlock',
|
|
'hex': ''
|
|
};
|
|
} else {
|
|
var ajax_data = {
|
|
'userpass': tmpIguanaRPCAuth,
|
|
'agent': passthru_agent,
|
|
'method': 'passthru',
|
|
'function': 'walletlock',
|
|
'hex': ''
|
|
};
|
|
}
|
|
|
|
console.log(ajax_data);
|
|
$.ajax({
|
|
async: false,
|
|
type: 'POST',
|
|
data: JSON.stringify(ajax_data),
|
|
url: 'http://127.0.0.1:' + config.iguanaPort,
|
|
success: function(data, textStatus, jqXHR) {
|
|
var AjaxOutputData = JSON.parse(data);
|
|
console.log('== Data OutPut ==');
|
|
console.log(AjaxOutputData.error);
|
|
|
|
if ( AjaxOutputData.errors != undefined ) {
|
|
result.push('encrypted');
|
|
} else {
|
|
result.push(AjaxOutputData.error);
|
|
}
|
|
},
|
|
error: function(xhr, textStatus, error) {
|
|
console.log('failed getting Coin History.');
|
|
console.log(xhr.statusText);
|
|
if ( xhr.readyState == 0 ) {
|
|
Iguana_ServiceUnavailable();
|
|
}
|
|
console.log(textStatus);
|
|
console.log(error);
|
|
}
|
|
});
|
|
|
|
return result;
|
|
}
|
|
|
|
function KMD_getInfo_rtrn() {
|
|
var result = [],
|
|
extcoin = $('[data-extcoin]').attr('data-extcoin'),
|
|
passthru_agent = getPassthruAgent(),
|
|
tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth');
|
|
|
|
if (passthru_agent == 'iguana') {
|
|
var ajax_data = {
|
|
'userpass': tmpIguanaRPCAuth,
|
|
'agent': passthru_agent,
|
|
'method': 'passthru',
|
|
'asset': $('[data-extcoin]').attr('data-extcoin'),
|
|
'function': 'getinfo',
|
|
'hex': ''
|
|
};
|
|
} else {
|
|
var ajax_data = {
|
|
'userpass': tmpIguanaRPCAuth,
|
|
'agent': passthru_agent,
|
|
'method': 'passthru',
|
|
'asset': $('[data-extcoin]').attr('data-extcoin'),
|
|
'function': 'getinfo',
|
|
'hex': ''
|
|
};
|
|
}
|
|
|
|
$.ajax({
|
|
async: false,
|
|
type: 'POST',
|
|
data: JSON.stringify(ajax_data),
|
|
url: 'http://127.0.0.1:' + config.iguanaPort,
|
|
success: function(data, textStatus, jqXHR) {
|
|
var AjaxOutputData = JSON.parse(data);
|
|
|
|
if ( AjaxOutputData.errors != undefined ) {
|
|
result.push(AjaxOutputData);
|
|
} else if ( AjaxOutputData['error'].message = 'Activating best chain...' ) {
|
|
result.push('activating');
|
|
} else if ( AjaxOutputData.errors == undefined) {
|
|
result.push('not active');
|
|
} else {
|
|
result.push(AjaxOutputData.errors);
|
|
}
|
|
},
|
|
error: function(xhr, textStatus, error) {
|
|
console.log('failed getting Coin History.');
|
|
console.log(xhr.statusText);
|
|
if ( xhr.readyState == 0 ) {
|
|
Iguana_ServiceUnavailable();
|
|
}
|
|
console.log(textStatus);
|
|
console.log(error);
|
|
}
|
|
});
|
|
|
|
return result[0];
|
|
}
|
|
|
|
function KMD_ProgressBar() {
|
|
var result = [],
|
|
extcoin = $('[data-extcoin]').attr('data-extcoin'),
|
|
getinfotmp = KMD_getInfo_rtrn();
|
|
|
|
if (extcoin !== 'ZEC') {
|
|
if ( getinfotmp == 'activating') {
|
|
$('span[data-extcoin="' + extcoin + '"][id="extcoin-sync-percent"]').text(_lang[defaultLang].INDEX.ACTIVATING + '...');
|
|
} else {
|
|
if (getinfotmp.blocks === 0) {
|
|
$('span[data-extcoin="' + extcoin + '"][id="extcoin-sync-percent"]').text('No blocks');
|
|
$('#extcoin-progressbars .progress-bar').css({ 'width': '100%' });
|
|
} else if (getinfotmp.blocks > 0 && getinfotmp.longestchain === 0) {
|
|
$('span[data-extcoin="' + extcoin + '"][id="extcoin-sync-percent"]').text('No longestchain');
|
|
$('#extcoin-progressbars .progress-bar').css({ 'width': '100%' });
|
|
} else {
|
|
var sync_percent = parseFloat(parseInt(getinfotmp.blocks, 10) * 100) / parseInt(getinfotmp.longestchain, 10);
|
|
//console.log(sync_percent);
|
|
console.log('getinfotmp', getinfotmp);
|
|
$('div[data-extcoin="' + extcoin + '"][id="extcoin-sync"]').width(parseFloat(sync_percent).toFixed(2) + '%');
|
|
$('span[data-extcoin="' + extcoin + '"][id="extcoin-sync-percent"]').text(parseFloat(sync_percent).toFixed(2) + '%');
|
|
$('span[data-extcoin="' + extcoin + '"][id="extcoin-synced-blocks"]').text(getinfotmp.blocks);
|
|
$('span[data-extcoin="' + extcoin + '"][id="extcoin-longestchain"]').text(getinfotmp.longestchain);
|
|
$('span[data-extcoin="' + extcoin + '"][id="extcoin-connections"]').text(getinfotmp.connections);
|
|
}
|
|
$('#extcoin-wallet-activating-alert').hide();
|
|
}
|
|
}
|
|
}
|