From 60742817e774aca452de2f181999e6c3889723d1 Mon Sep 17 00:00:00 2001 From: Satinder Grewal Date: Sat, 21 Jan 2017 07:59:29 +1300 Subject: [PATCH] Native coin Progress Bar code added --- assets/scripts/dashboard.js | 2 +- assets/scripts/kmd_wallet_dashboard.js | 71 ++++++++++++++++++++++++++ assets/scripts/sidebar.js | 6 +++ index.html | 8 +++ 4 files changed, 86 insertions(+), 1 deletion(-) diff --git a/assets/scripts/dashboard.js b/assets/scripts/dashboard.js index d5937d1..22e48d0 100644 --- a/assets/scripts/dashboard.js +++ b/assets/scripts/dashboard.js @@ -338,7 +338,7 @@ var Dashboard = function() { if ( active_edexcoinmodecode == 'Basilisk' || active_edexcoinmodecode == 'Native' ) { //console.log(active_edexcoinmodecode) - console.log('No need to show Progress bar for Native or Basilisk mode.') + //console.log('No need to show Progress bar for Native or Basilisk mode.') } else { ShowCoinProgressBar(active_edexcoin); } diff --git a/assets/scripts/kmd_wallet_dashboard.js b/assets/scripts/kmd_wallet_dashboard.js index 810adb9..0aef5d9 100644 --- a/assets/scripts/kmd_wallet_dashboard.js +++ b/assets/scripts/kmd_wallet_dashboard.js @@ -256,6 +256,15 @@ var KMDWalletDashboard = function() { jQuery(document).ready(function() { //KMDWalletDashboard.init(); + 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(); + } + }, 1000); + }); @@ -1220,3 +1229,65 @@ function CheckIfWalletEncrypted() { }); return result; } + +function KMD_getInfo_rtrn() { + var result = []; + var extcoin = $('[data-extcoin]').attr("data-extcoin"); + + 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({ + 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); + //console.log('== Data OutPut =='); + //console.log(AjaxOutputData); + if ( AjaxOutputData.errors != undefined ) { + //console.log('connected'); + result.push(AjaxOutputData); + } 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 = []; + var extcoin = $('[data-extcoin]').attr("data-extcoin"); + + var getinfotmp = KMD_getInfo_rtrn() + //console.log(getinfotmp.blocks); + //console.log(getinfotmp.connections); + //console.log(getinfotmp.longestchain); + + var sync_percent = parseFloat(parseInt(getinfotmp.blocks, 10) * 100)/ parseInt(getinfotmp.longestchain, 10); + console.log(parseFloat(sync_percent).toFixed(2)+'%') + $('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); + +} + diff --git a/assets/scripts/sidebar.js b/assets/scripts/sidebar.js index b3aef4e..2efac0c 100644 --- a/assets/scripts/sidebar.js +++ b/assets/scripts/sidebar.js @@ -206,6 +206,7 @@ $('#nav-about-iguana').on('click', function() { function CommonSidebarActionsSet01() { sessionStorage.setItem('DashboardActions', "start"); + sessionStorage.setItem('NativeWalletActions', "stop"); $(document).ready(function() { Dashboard.init(); }); $("#wifkeys_passphrase").val(''); $('#wif-priv-keys').html(''); @@ -213,6 +214,7 @@ function CommonSidebarActionsSet01() { function CommonSidebarActionsSet011() { sessionStorage.setItem('DashboardActions', "start"); + sessionStorage.setItem('NativeWalletActions', "stop"); location.reload(); $("#wifkeys_passphrase").val(''); $('#wif-priv-keys').html(''); @@ -234,6 +236,7 @@ function applyKMDWalletStyle() { $('#easydex_kmd_wallet_actions_header').show(); $('#easydex_zec_wallet_actions_header').hide(); $('#easydex_btc_btcd_balances_header').hide(); + sessionStorage.setItem('NativeWalletActions', "start"); } function removeKMDWalletStyle() { @@ -242,6 +245,7 @@ function removeKMDWalletStyle() { $('#easydex_kmd_wallet_actions_header').hide(); $('#easydex_zec_wallet_actions_header').hide(); $('#easydex_btc_btcd_balances_header').show(); + sessionStorage.setItem('NativeWalletActions', "stop"); } @@ -254,6 +258,7 @@ function applyZECWalletStyle() { $('#easydex_kmd_wallet_actions_header').hide(); $('#easydex_zec_wallet_actions_header').show(); $('#easydex_btc_btcd_balances_header').hide(); + sessionStorage.setItem('NativeWalletActions', "start"); } function removeZECWalletStyle() { @@ -262,6 +267,7 @@ function removeZECWalletStyle() { $('#easydex_kmd_wallet_actions_header').hide(); $('#easydex_zec_wallet_actions_header').hide(); $('#easydex_btc_btcd_balances_header').show(); + sessionStorage.setItem('NativeWalletActions', "stop"); } diff --git a/index.html b/index.html index 2876044..1679451 100755 --- a/index.html +++ b/index.html @@ -942,6 +942,14 @@ +
+
+
+
- | - / - | Connections: -
+
+
+
+