Browse Source

updated activating best chain; code cleanup

master
Petr Balashov 8 years ago
parent
commit
0f19e3baf9
  1. 54
      assets/scripts/kmd_wallet_dashboard.js
  2. 20
      assets/scripts/sidebar.js
  3. 158
      assets/scripts/walletsettings.js
  4. 2
      assets/scripts/wordlist.js

54
assets/scripts/kmd_wallet_dashboard.js

@ -320,13 +320,42 @@ function RunKMDInitFunctions() {
$('#extcoin-wallet').show(); $('#extcoin-wallet').show();
$('#extcoin-wallet-connection-alert').hide(); $('#extcoin-wallet-connection-alert').hide();
function _getKMDInfo() {
var passthru_agent = getPassthruAgent();
var tmpIguanaRPCAuth = 'tmpIgRPCUser@'+sessionStorage.getItem('IguanaRPCAuth');
var ajax_data = {'userpass':tmpIguanaRPCAuth,"agent":passthru_agent,"method":"passthru","function":"getinfo","hex":""}
console.log(ajax_data);
$.ajax({
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);
if (AjaxOutputData && !AjaxOutputData.blocks) {
startBestBlockInterval();
} else {
clearInterval(currentBestBlockInterval);
}
},
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);
}
});
}
function getRemoteCurrentHeight() { function getRemoteCurrentHeight() {
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: 'http://localhost:7778/api/dex/getinfo?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth') + '&symbol=KMD', url: 'http://localhost:7778/api/dex/getinfo?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth') + '&symbol=KMD',
//dataType: 'text', //dataType: 'text',
success: function(data, textStatus, jqXHR) { success: function(data, textStatus, jqXHR) {
//$('#read_debug_log_textarea').text(JSON.parse(data));
data = JSON.parse(data); data = JSON.parse(data);
if (data && data.blocks) { if (data && data.blocks) {
totalBlocksInExplorer = data.blocks; totalBlocksInExplorer = data.blocks;
@ -340,14 +369,10 @@ function RunKMDInitFunctions() {
} }
}); });
} }
getRemoteCurrentHeight();
var totalBlocksInExplorer = 0; var currentBestBlockInterval;
var totalBlocksInExplorerInterval = setInterval(function() { function startBestBlockInterval() {
getRemoteCurrentHeight(); currentBestBlockInterval = setInterval(function() {
}, 60000);
var currentBestBlockInterval = setInterval(function() {
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
data: { 'herdname': 'komodo', 'lastLines': 1 }, data: { 'herdname': 'komodo', 'lastLines': 1 },
@ -364,7 +389,7 @@ function RunKMDInitFunctions() {
$('#activating-komodod-progress').html(': ' + Math.floor(currentBestChain * 100 / totalBlocksInExplorer) + '% (blocks ' + currentBestChain + ' / ' + totalBlocksInExplorer + ')'); $('#activating-komodod-progress').html(': ' + Math.floor(currentBestChain * 100 / totalBlocksInExplorer) + '% (blocks ' + currentBestChain + ' / ' + totalBlocksInExplorer + ')');
if (currentBestChain === totalBlocksInExplorer) { if (currentBestChain === totalBlocksInExplorer) {
clearInterval(totalBlocksInExplorerInterval); //clearInterval(totalBlocksInExplorerInterval);
clearInterval(currentBestBlockInterval); clearInterval(currentBestBlockInterval);
} }
} }
@ -378,7 +403,16 @@ function RunKMDInitFunctions() {
console.log(error); console.log(error);
} }
}); });
}, 1000); }, 5000);
}
getRemoteCurrentHeight();
var totalBlocksInExplorer = 0;
var totalBlocksInExplorerInterval = setInterval(function() {
getRemoteCurrentHeight();
_getKMDInfo();
}, 60000);
$('#kmd_wallet_dashoard_section').show(); $('#kmd_wallet_dashoard_section').show();
$('#kmd_wallet_dashboardinfo').show(); $('#kmd_wallet_dashboardinfo').show();

20
assets/scripts/sidebar.js

@ -1,27 +1,25 @@
// DOM Ready ============================================================= // DOM Ready =============================================================
$(document).ready(function() { $(document).ready(function() {
$('#section-dashboard').show(); $('#section-dashboard').show();
//$('#header-dashboard').show();
$('#section-easydex').hide(); $('#section-easydex').hide();
$('#section-extcoin').hide(); $('#section-extcoin').hide();
$('#section-zcash').hide(); $('#section-zcash').hide();
$('#section-iguana-atomic-explorer').hide(); $('#section-iguana-atomic-explorer').hide();
$('#section-iguana-wallet-settings').hide(); $('#section-iguana-wallet-settings').hide();
$('#section-about-iguana').hide(); $('#section-about-iguana').hide();
$('#nav-dashboard').removeClass( "" ).addClass( "active open" ); $('#nav-dashboard').removeClass( '' ).addClass( 'active open' );
$('#nav-easydex').removeClass( " active open" ).addClass( "" ); $('#nav-easydex').removeClass( 'active open' ).addClass( '' );
$('#nav-komodo-wallet').removeClass( " active open" ).addClass( "" ); $('#nav-komodo-wallet').removeClass( 'active open' ).addClass( '' );
$('#nav-zcash-wallet').removeClass( " active open" ).addClass( "" ); $('#nav-zcash-wallet').removeClass( 'active open' ).addClass( '' );
$('#nav-iguana-atomic-explorer').removeClass( " active open" ).addClass( "" ); $('#nav-iguana-atomic-explorer').removeClass( 'active open' ).addClass( '' );
$('#nav-iguana-wallet-settings').removeClass( " active open" ).addClass( "" ); $('#nav-iguana-wallet-settings').removeClass( 'active open' ).addClass( '' );
$('#nav-about-iguana').removeClass( " active open" ).addClass( "" ); $('#nav-about-iguana').removeClass( 'active open' ).addClass( '' );
$(".header-easydex-section").text("Dashboard"); $(".header-easydex-section").text('Dashboard');
removeKMDWalletStyle(); removeKMDWalletStyle();
removeZECWalletStyle(); removeZECWalletStyle();
CommonSidebarActionsSet01(); CommonSidebarActionsSet01();
applyDashboardStyle(); applyDashboardStyle();
}); });
$('#nav-dashboard').on('click', function() { $('#nav-dashboard').on('click', function() {

158
assets/scripts/walletsettings.js

@ -1,5 +1,4 @@
var WalletSettings = function() { var WalletSettings = function() {
var handleWalletExportKeys = function() { var handleWalletExportKeys = function() {
$('.wifkeys-form').validate({ $('.wifkeys-form').validate({
//errorElement: 'span', //default input error message container //errorElement: 'span', //default input error message container
@ -10,29 +9,33 @@ var WalletSettings = function() {
required: true required: true
} }
}, },
messages: { messages: {
wifkeys_passphrase: { wifkeys_passphrase: {
required: "Passphrase is required." required: 'Passphrase is required.'
} }
}, },
submitHandler: function(form) { submitHandler: function(form) {
console.log("wait till peer ip added to selected coin...") console.log('wait till peer ip added to selected coin...')
var Getwifkeys_passphrase = $("#wifkeys_passphrase").val(); var Getwifkeys_passphrase = $('#wifkeys_passphrase').val(),
WifKeyDivContent = '';
var WifKeyDivContent = '';
//First check which coins are active. Execute API for each mode of wallet //First check which coins are active. Execute API for each mode of wallet
$.each([ 'native','basilisk', 'full' ], function( index, value ) { $.each([
var tmpIguanaRPCAuth = 'tmpIgRPCUser@'+sessionStorage.getItem('IguanaRPCAuth'); 'native',
var allcoins_ajax_data = {'userpass':tmpIguanaRPCAuth,"agent":"InstantDEX","method":"allcoins"}; 'basilisk',
'full'], function( index, value ) {
var tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth');
allcoins_ajax_data = {
'userpass': tmpIguanaRPCAuth,
'agent': 'InstantDEX',
'method': 'allcoins'
};
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
data: JSON.stringify(allcoins_ajax_data), data: JSON.stringify(allcoins_ajax_data),
url: 'http://127.0.0.1:7778', url: 'http://127.0.0.1:7778',
//dataType: 'text',
success: function(data, textStatus, jqXHR) { success: function(data, textStatus, jqXHR) {
var AllcoinsDataOutput = JSON.parse(data); var AllcoinsDataOutput = JSON.parse(data);
//Only execute further code if that mode has any coins active it. if none, skill checking on them. //Only execute further code if that mode has any coins active it. if none, skill checking on them.
@ -76,13 +79,19 @@ var WalletSettings = function() {
}); });
//Second run walletpassphrase again to make sure wallet is unlocked as before login. //Second run walletpassphrase again to make sure wallet is unlocked as before login.
var tmpIguanaRPCAuth = 'tmpIgRPCUser@'+sessionStorage.getItem('IguanaRPCAuth'); var tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
var WalletPassphrase_ajax_data = {'userpass':tmpIguanaRPCAuth,"agent":"bitcoinrpc","method":"walletpassphrase","password":Getwifkeys_passphrase,'timeout': '2592000'} WalletPassphrase_ajax_data = {
'userpass': tmpIguanaRPCAuth,
'agent': 'bitcoinrpc',
'method': 'walletpassphrase',
'password': Getwifkeys_passphrase,
'timeout': '2592000'
};
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
data: JSON.stringify(WalletPassphrase_ajax_data), data: JSON.stringify(WalletPassphrase_ajax_data),
url: 'http://127.0.0.1:7778', url: 'http://127.0.0.1:7778',
//dataType: 'text',
success: function(data, textStatus, jqXHR) { success: function(data, textStatus, jqXHR) {
var WalletPassphraseDataOutput = JSON.parse(data); var WalletPassphraseDataOutput = JSON.parse(data);
console.log(WalletPassphraseDataOutput); console.log(WalletPassphraseDataOutput);
@ -118,11 +127,10 @@ var WalletSettings = function() {
if ($('.wifkeys-form').validate().form()) { if ($('.wifkeys-form').validate().form()) {
$('.wifkeys-form').submit(); //form validation success, call ajax form submit $('.wifkeys-form').submit(); //form validation success, call ajax form submit
} }
return false; return false;
} }
}); });
}; };
var handleWalletImportKeys = function() { var handleWalletImportKeys = function() {
@ -135,27 +143,25 @@ var WalletSettings = function() {
required: true required: true
} }
}, },
messages: { messages: {
import_wifkey: { import_wifkey: {
required: "Private Key is required." required: 'Private Key is required.'
} }
}, },
submitHandler: function(form) { submitHandler: function(form) {
var Getimport_wifkey = $("#import_wifkey").val(); var Getimport_wifkey = $('#import_wifkey').val();
//console.log(Getimport_wifkey); //console.log(Getimport_wifkey);
EDEXimportprivkey(Getimport_wifkey).then(function(result){ EDEXimportprivkey(Getimport_wifkey).then(function(result){
console.log(result) console.log(result)
if ( result.result !== undefined && result.result == 'success' ) { if ( result.result !== undefined && result.result == 'success' ) {
toastr.success("Private Key Imported Successfully!", "Settings Notification"); toastr.success('Private Key Imported Successfully!', 'Settings Notification');
$("#import_wifkey").val('') $('#import_wifkey').val('');
} }
if ( result.error !== undefined && result.error == 'null return from iguana_bitcoinRPC' ) { if ( result.error !== undefined && result.error == 'null return from iguana_bitcoinRPC' ) {
toastr.info("Private Key is not imported.", "Settings Notification"); toastr.info('Private Key is not imported.', 'Settings Notification');
toastr.error("null return from iguana_bitcoinRPC", "Settings Notification"); toastr.error('null return from iguana_bitcoinRPC', 'Settings Notification');
} }
}) });
} }
}); });
@ -164,57 +170,53 @@ var WalletSettings = function() {
if ($('.wifkeys-import-form').validate().form()) { if ($('.wifkeys-import-form').validate().form()) {
$('.wifkeys-import-form').submit(); //form validation success, call ajax form submit $('.wifkeys-import-form').submit(); //form validation success, call ajax form submit
} }
return false; return false;
} }
}); });
}; };
return { return {
//main function to initiate the module //main function to initiate the module
init: function() { init: function() {
handleWalletExportKeys(); handleWalletExportKeys();
handleWalletImportKeys(); handleWalletImportKeys();
} }
}; };
}(); }();
jQuery(document).ready(function() {
WalletSettings.init();
});
// DOM Ready ============================================================= // DOM Ready =============================================================
$(document).ready(function() { $(document).ready(function() {
WalletSettings.init();
}); });
// Functions ============================================================= // Functions =============================================================
function Settings_ShowWalletInfo() { function Settings_ShowWalletInfo() {
var CheckLoginData = JSON.parse(sessionStorage.getItem('IguanaActiveAccount')); var CheckLoginData = JSON.parse(sessionStorage.getItem('IguanaActiveAccount'));
console.log(JSON.parse(CheckLoginData)); console.log(JSON.parse(CheckLoginData));
$("#winfo_pubkey_value").text(JSON.parse(CheckLoginData).pubkey); $('#winfo_pubkey_value').text(JSON.parse(CheckLoginData).pubkey);
$("#winfo_btcpubkey_value").text(JSON.parse(CheckLoginData).btcpubkey); $('#winfo_btcpubkey_value').text(JSON.parse(CheckLoginData).btcpubkey);
$("#winfo_rmd160_value").text(JSON.parse(CheckLoginData).rmd160); $('#winfo_rmd160_value').text(JSON.parse(CheckLoginData).rmd160);
$("#winfo_NXT_value").text(JSON.parse(CheckLoginData).NXT); $('#winfo_NXT_value').text(JSON.parse(CheckLoginData).NXT);
$("#winfo_notary_value").text(JSON.parse(CheckLoginData).notary); $('#winfo_notary_value').text(JSON.parse(CheckLoginData).notary);
$("#winfo_status_value").text(JSON.parse(CheckLoginData).status); $('#winfo_status_value').text(JSON.parse(CheckLoginData).status);
//$("#winfo_duration_value").text(JSON.parse(CheckLoginData).duration);
} }
function Settings_ShowCoinPeers() { function Settings_ShowCoinPeers() {
console.log('waiting getpeers api to complete...'); console.log('waiting getpeers api to complete...');
$("#coin_supernetpeers_h").text(''); $('#coin_supernetpeers_h').text('');
$("#coin_supernetpeers").text(''); $('#coin_supernetpeers').text('');
$("#coin_rawpeers_h").text(''); $('#coin_rawpeers_h').text('');
$("#coin_rawpeers").text(''); $('#coin_rawpeers').text('');
var settings_selected_coinname_code_val = $("option:selected","#settings_select_coin_options").val(); var settings_selected_coinname_code_val = $('option:selected', '#settings_select_coin_options').val();
var tmpIguanaRPCAuth = 'tmpIgRPCUser@'+sessionStorage.getItem('IguanaRPCAuth'); tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth');
var ajax_data = {'userpass':tmpIguanaRPCAuth,"agent":"SuperNET","method":"getpeers","activecoin": settings_selected_coinname_code_val}; ajax_data = {
'userpass': tmpIguanaRPCAuth,
'agent': 'SuperNET',
'method': 'getpeers',
'activecoin': settings_selected_coinname_code_val
};
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
data: JSON.stringify(ajax_data), data: JSON.stringify(ajax_data),
@ -227,11 +229,15 @@ function Settings_ShowCoinPeers() {
if (getCoinPeers.supernet[0].peers !== undefined ) { if (getCoinPeers.supernet[0].peers !== undefined ) {
var supernet_peers_list = getCoinPeers.supernet[0].peers; var supernet_peers_list = getCoinPeers.supernet[0].peers;
if (supernet_peers_list != 0 ) { if (supernet_peers_list != 0 ) {
$("#coin_supernetpeers_h").text(getCoinPeers.supernet[0].coin); $('#coin_supernetpeers_h').text(getCoinPeers.supernet[0].coin);
$.each(supernet_peers_list, function( index, value ) { $.each(supernet_peers_list, function( index, value ) {
var br_val = ""; var br_val = '';
if ( index != 0 ) { br_val = "<br>" }
$("#coin_supernetpeers").append(br_val+value); if ( index != 0 ) {
br_val = '<br>';
}
$('#coin_supernetpeers').append(br_val + value);
}); });
} }
} }
@ -239,11 +245,15 @@ function Settings_ShowCoinPeers() {
if (getCoinPeers.rawpeers[0].peers !== undefined ) { if (getCoinPeers.rawpeers[0].peers !== undefined ) {
var raw_peers_list = getCoinPeers.rawpeers[0].peers; var raw_peers_list = getCoinPeers.rawpeers[0].peers;
if (raw_peers_list != 0 ) { if (raw_peers_list != 0 ) {
$("#coin_rawpeers_h").text(getCoinPeers.supernet[0].coin); $('#coin_rawpeers_h').text(getCoinPeers.supernet[0].coin);
$.each(raw_peers_list, function( index, value ) { $.each(raw_peers_list, function( index, value ) {
var br_val = ""; var br_val = '';
if ( index != 0 ) { br_val = "<br>" }
$("#coin_rawpeers").append(br_val+value); if ( index != 0 ) {
br_val = '<br>';
}
$('#coin_rawpeers').append(br_val + value);
}); });
} }
} }
@ -263,11 +273,18 @@ function Settings_ShowCoinPeers() {
function Settings_AddCoinPeers() { function Settings_AddCoinPeers() {
console.log("wait till peer ip added to selected coin...") console.log('wait till peer ip added to selected coin...')
var settings_selected_coinname_code_val = $("option:selected","#settings_select_coin_addpeer_options").val(); var settings_selected_coinname_code_val = $('option:selected', '#settings_select_coin_addpeer_options').val(),
var settings_add_peer_ip_val = $("#settings_add_peer_ip").val(); settings_add_peer_ip_val = $("#settings_add_peer_ip").val(),
var tmpIguanaRPCAuth = 'tmpIgRPCUser@'+sessionStorage.getItem('IguanaRPCAuth'); tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
var ajax_data = {'userpass':tmpIguanaRPCAuth,"agent":"iguana","method":"addnode","activecoin": settings_selected_coinname_code_val,"ipaddr": settings_add_peer_ip_val}; ajax_data = {
'userpass': tmpIguanaRPCAuth,
'agent': 'iguana',
'method': 'addnode',
'activecoin': settings_selected_coinname_code_val,
'ipaddr': settings_add_peer_ip_val
};
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
data: JSON.stringify(ajax_data), data: JSON.stringify(ajax_data),
@ -277,8 +294,8 @@ function Settings_AddCoinPeers() {
var getAddCoinPeers = JSON.parse(data); var getAddCoinPeers = JSON.parse(data);
console.log(getAddCoinPeers); console.log(getAddCoinPeers);
if ( getAddCoinPeers.result == 'addnode submitted' ) { if ( getAddCoinPeers.result == 'addnode submitted' ) {
toastr.success(settings_add_peer_ip_val + " added to " + settings_selected_coinname_code_val + " Successfully", "Coin Notification"); toastr.success(settings_add_peer_ip_val + ' added to ' + settings_selected_coinname_code_val + ' Successfully', 'Coin Notification');
$("#settings_add_peer_ip").val(''); $('#settings_add_peer_ip').val('');
} }
}, },
error: function(xhr, textStatus, error) { error: function(xhr, textStatus, error) {
@ -294,10 +311,13 @@ function Settings_AddCoinPeers() {
} }
function Settings_LoadDebugLog() { function Settings_LoadDebugLog() {
var settings_selected_targed_val = $('option:selected', '#settings_select_debuglog_options').val(),
numLinesToRead = $('#read_debug_log_lines').val(),
ajax_data = {
'herdname': settings_selected_targed_val,
'lastLines': numLinesToRead
};
var settings_selected_targed_val = $("option:selected","#settings_select_debuglog_options").val();
var numLinesToRead = $('#read_debug_log_lines').val();
var ajax_data = { 'herdname': settings_selected_targed_val, 'lastLines': numLinesToRead };
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
data: ajax_data, data: ajax_data,

2
assets/scripts/wordlist.js

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save