Browse Source

Zcash GUI Wallet in EasyDEX now using exact same Komodo GUI code

Both Komodo GUI and Zcash GUI uses the same set of common code to
display and do wallet actions.
will be coding different parts of each to handle differently as move
forward to GUI development.
master
Satinder Grewal 8 years ago
parent
commit
8b6bbd5e0f
  1. 76
      assets/scripts/kmd_wallet_dashboard.js
  2. 8
      assets/scripts/sidebar.js
  3. 21
      index.html

76
assets/scripts/kmd_wallet_dashboard.js

@ -2,7 +2,8 @@ var KMDWalletDashboard = function() {
var handle_KMD_Dashboard = function() {
$('#btn_kmd_wallet_dashboard').click(function() {
var action_btn_code = getHeaderActionMenuButtonCoinCode();
$('#btn_'+action_btn_code+'_wallet_dashboard').click(function() {
console.log('kmd wallet dashbaord button clicked...');
console.log($(this).data());
$('#kmd_wallet_dashoard_section').show();
@ -17,8 +18,8 @@ var KMDWalletDashboard = function() {
}
var handle_KMD_Send = function() {
$('#btn_kmd_wallet_send').click(function() {
var action_btn_code = getHeaderActionMenuButtonCoinCode();
$('#btn_'+action_btn_code+'_wallet_send').click(function() {
KMDListAllOPIDs();
//console.log('kmd wallet send button clicked...');
var tmpoptions = '';
@ -31,7 +32,7 @@ var KMDWalletDashboard = function() {
var kmd_addr_list_with_balance = KMDlistunspentT();
//console.log(kmd_addr_list_with_balance);
tmpoptions += '<option> - Select Transparent or Private KMD Address - </option>';
tmpoptions += '<option> - Select Transparent or Private Address - </option>';
$.each(kmd_addr_list_with_balance, function(index) {
tmpoptions += '<option value="' + kmd_addr_list_with_balance[index].addr + '" data-total="' + kmd_addr_list_with_balance[index].total.toFixed(8) + '">[ ' + kmd_addr_list_with_balance[index].total.toFixed(8) + ' KMD ] &emsp;' + kmd_addr_list_with_balance[index].addr + '</option>';
$('#kmd_wallet_send_from').html(tmpoptions);
@ -184,7 +185,8 @@ var KMDWalletDashboard = function() {
};
var KMDWalletSettings = function() {
$('#btn_kmd_wallet_settings').click(function() {
var action_btn_code = getHeaderActionMenuButtonCoinCode();
$('#btn_'+action_btn_code+'_wallet_settings').click(function() {
console.log('wallet settings button clicked...');
$('#kmd_wallet_dashboardinfo').hide();
$('#kmd_wallet_dashoard_section').hide();
@ -198,7 +200,8 @@ var KMDWalletDashboard = function() {
var KMDWalletRecieve = function() {
$('#btn_kmd_wallet_recieve').click(function() {
var action_btn_code = getHeaderActionMenuButtonCoinCode();
$('#btn_'+action_btn_code+'_wallet_recieve').click(function() {
//console.log('wallet recieve button clicked...');
$('#kmd_wallet_dashboardinfo').hide();
$('#kmd_wallet_dashoard_section').hide();
@ -255,6 +258,23 @@ function RunInitFunctions() {
NProgress.done();
}
function getHeaderActionMenuButtonCoinCode() {
var extcoin = $('#extcoin-wallet').data('extcoin');
var action_menu_button_code = '';
if ( extcoin == 'KMD') { action_menu_button_code = 'kmd'; };
if ( extcoin == 'ZEC') { action_menu_button_code = 'zec'; };
return action_menu_button_code;
}
function getPassthruAgent() {
var extcoin = $('#extcoin-wallet').data('extcoin');
var passthru_agent = '';
if ( extcoin == 'KMD') { passthru_agent = 'komodo'; };
if ( extcoin == 'ZEC') { passthru_agent = 'zcash'; };
return passthru_agent;
}
function getTotalKMDBalance() {
console.log($('#extcoin-wallet').data('extcoin'));
var extcoin = $('#extcoin-wallet').data('extcoin');
@ -290,7 +310,8 @@ function getTotalKMDBalance() {
}
function getKMDBalanceT() {
var ajax_data = {"agent":"komodo","method":"passthru","function":"getbalance","hex":""}
var passthru_agent = getPassthruAgent();
var ajax_data = {"agent":passthru_agent,"method":"passthru","function":"getbalance","hex":""}
console.log(ajax_data);
$.ajax({
type: 'POST',
@ -317,7 +338,8 @@ function getKMDBalanceT() {
function getKMDBalanceZ() {
var ajax_data = {"agent":"komodo","method":"passthru","function":"z_getbalance","hex":""}
var passthru_agent = getPassthruAgent();
var ajax_data = {"agent":passthru_agent,"method":"passthru","function":"z_getbalance","hex":""}
console.log(ajax_data);
$.ajax({
type: 'POST',
@ -344,7 +366,8 @@ function getKMDBalanceZ() {
function getKMDWalletInfo() {
var ajax_data = {"agent":"komodo","method":"passthru","function":"getwalletinfo","hex":""}
var passthru_agent = getPassthruAgent();
var ajax_data = {"agent":passthru_agent,"method":"passthru","function":"getwalletinfo","hex":""}
console.log(ajax_data);
$.ajax({
type: 'POST',
@ -375,7 +398,8 @@ function getKMDWalletInfo() {
function getKMDInfo() {
var ajax_data = {"agent":"komodo","method":"passthru","function":"getinfo","hex":""}
var passthru_agent = getPassthruAgent();
var ajax_data = {"agent":passthru_agent,"method":"passthru","function":"getinfo","hex":""}
console.log(ajax_data);
$.ajax({
type: 'POST',
@ -420,7 +444,8 @@ function KMDlistunspentT() {
NProgress.start();
var result = [];
var ajax_data = {"agent":"komodo","method":"passthru","function":"listunspent","hex":""}
var passthru_agent = getPassthruAgent();
var ajax_data = {"agent":passthru_agent,"method":"passthru","function":"listunspent","hex":""}
//console.log(ajax_data);
$.ajax({
async: false,
@ -471,7 +496,8 @@ function KMDlistunspentT() {
function KMDListaddrZ() {
var result = [];
var ajax_data = {"agent":"komodo","method":"passthru","function":"z_listaddresses","hex":""}
var passthru_agent = getPassthruAgent();
var ajax_data = {"agent":passthru_agent,"method":"passthru","function":"z_listaddresses","hex":""}
//console.log(ajax_data);
$.ajax({
async: false,
@ -547,7 +573,8 @@ function KMDGetPublicTransactions() {
NProgress.start();
var result = [];
var ajax_data = {"agent":"komodo","method":"passthru","function":"listtransactions","hex":""}
var passthru_agent = getPassthruAgent();
var ajax_data = {"agent":passthru_agent,"method":"passthru","function":"listtransactions","hex":""}
//console.log(ajax_data);
$.ajax({
async: false,
@ -621,7 +648,8 @@ function KMDGetProtectedTransactions() {
var tmpzaddr_hex_input = Iguana_HashHex(ajax_data_to_hex)
//console.log(tmpzaddr_hex_input);
var ajax_data = {"agent":"komodo","method":"passthru","function":"z_listreceivedbyaddress","hex":tmpzaddr_hex_input}
var passthru_agent = getPassthruAgent();
var ajax_data = {"agent":passthru_agent,"method":"passthru","function":"z_listreceivedbyaddress","hex":tmpzaddr_hex_input}
//console.log(ajax_data);
$.ajax({
async: false,
@ -723,7 +751,8 @@ function KMDListAddresses(pubpriv) {
//console.log(tmpzaddr_hex_input);
var ajax_data = {"agent":"komodo","method":"passthru","function":ajax_function_input,"hex":tmplistaddr_hex_input}
var passthru_agent = getPassthruAgent();
var ajax_data = {"agent":passthru_agent,"method":"passthru","function":ajax_function_input,"hex":tmplistaddr_hex_input}
//console.log(ajax_data);
$.ajax({
async: false,
@ -769,7 +798,8 @@ function KMDGetNewAddresses(pubpriv) {
ajax_function_input = 'z_getnewaddress';
}
var ajax_data = {"agent":"komodo","method":"passthru","function":ajax_function_input,"hex":""}
var passthru_agent = getPassthruAgent();
var ajax_data = {"agent":passthru_agent,"method":"passthru","function":ajax_function_input,"hex":""}
//console.log(ajax_data);
$.ajax({
async: false,
@ -809,11 +839,11 @@ function KMDListAllAddr() {
var listTaddr = KMDListAddresses('public');
var listZaddr = KMDListAddresses('private');
var listAlladdr = $.merge( listTaddr, listZaddr );
console.log(listAlladdr[5].slice(0, 2));
//console.log(listAlladdr[5].slice(0, 2));
$.each(listAlladdr, function(index, value) {
tmp_addr_label = '<span class="label label-default"><i class="icon fa-eye"></i> public</span>';
if ( listAlladdr[index].slice(0, 2) == 'zc' ) { tmp_addr_label = '<span class="label label-dark"><i class="icon fa-eye-slash"></i> private</span>'; }
if ( listAlladdr[index].slice(0, 2) == 'zc' || listAlladdr[index].slice(0, 2) == 'zt' ) { tmp_addr_label = '<span class="label label-dark"><i class="icon fa-eye-slash"></i> private</span>'; }
//var tmp_addr_action_button = '<button></button>';
only_reciving_addr_data.push([tmp_addr_label, listAlladdr[index]]);
});
@ -886,7 +916,8 @@ function KMDGetOPIDInfo(opid) {
//console.log(tmpopid_output);
}
var ajax_data_txid_input = {"agent":"komodo","method":"passthru","function":"z_getoperationstatus","hex":tmpopid_output}
var passthru_agent = getPassthruAgent();
var ajax_data_txid_input = {"agent":passthru_agent,"method":"passthru","function":"z_getoperationstatus","hex":tmpopid_output}
//console.log(ajax_data_txid_input);
$.ajax({
async: false,
@ -935,6 +966,10 @@ function KMDListAllOPIDs() {
tmp_id = listOPIDs[0][index].id;
tmp_creation_time = secondsToString(listOPIDs[0][index].creation_time);
if (listOPIDs[0][index].status === 'queued') {
tmp_status_label = '<span class="label label-warning"><i class="icon fa-eye"></i> Queued</span>';
tmp_results = '<i>Please press refresh button in a minute or so to see updated status...</i>';
}
if (listOPIDs[0][index].status === 'executing') {
tmp_status_label = '<span class="label label-info"><i class="icon fa-eye"></i> Executing</span>';
tmp_results = '<i>Please press refresh button in a minute or so to see updated status...</i>';
@ -994,7 +1029,8 @@ function KMDZSendManyTransaction() {
var zsendmoney_output = Iguana_HashHex(ajax_data_to_hex)
//console.log(zsendmoney_output);
var ajax_data_txid_input = {"agent":"komodo","method":"passthru","function":"z_sendmany","hex":zsendmoney_output}
var passthru_agent = getPassthruAgent();
var ajax_data_txid_input = {"agent":passthru_agent,"method":"passthru","function":"z_sendmany","hex":zsendmoney_output}
//console.log(ajax_data_txid_input);
$.ajax({
async: false,

8
assets/scripts/sidebar.js

@ -85,6 +85,8 @@ $('#nav-komodo-wallet').on('click', function() {
$('#nav-about-iguana').removeClass( " active open" ).addClass( "" );
//$.each($('[data-extcoin="KMD"]'), function(index, value) {console.log($('[data-extcoin="KMD"]').data()); $('[data-extcoin="KMD"]').attr("data-extcoin","ZEC"); });
$.each($('[data-extcoin]'), function(index, value) {$('[data-extcoin]').attr("data-extcoin","KMD"); $('[data-extcoin="KMD"]')});
$.each($('[data-extcoinname]'), function(index, value) {$('[data-extcoinname]').text("KMD"); $('[data-extcoinname="KMD"]')});
$.each($('[data-extcointitle]'), function(index, value) {$('[data-extcointitle]').text("Komodo"); $('[data-extcointitle="Komodo"]')});
KMDWalletDashboard.init(); //Initiate Komodo Dashbaord sript
applyKMDWalletStyle();
//removeZECWalletStyle();
@ -101,7 +103,8 @@ $('#nav-zcash-wallet').on('click', function() {
$('#header-dashboard').hide();
$('#section-easydex').hide();
$('#section-extcoin').hide();
$('#section-zcash').show();
//$('#section-zcash').show();
$('#section-extcoin').show();
$('#section-about-iguana').hide();
$('#section-iguana-atomic-explorer').hide();
$('#section-iguana-wallet-settings').hide();
@ -114,6 +117,9 @@ $('#nav-zcash-wallet').on('click', function() {
$('#nav-about-iguana').removeClass( " active open" ).addClass( "" );
$(".header-easydex-section").text("Zcash Wallet");
$.each($('[data-extcoin]'), function(index, value) {$('[data-extcoin]').attr("data-extcoin","ZEC"); $('[data-extcoin="ZEC"]')});
$.each($('[data-extcoinname]'), function(index, value) {$('[data-extcoinname]').text("ZEC"); $('[data-extcoinname="ZEC"]')});
$.each($('[data-extcointitle]'), function(index, value) {$('[data-extcointitle]').text("Zcash"); $('[data-extcointitle="Zcash"]')});
KMDWalletDashboard.init(); //Initiate Komodo Dashbaord sript
applyZECWalletStyle();
//removeKMDWalletStyle();
CommonSidebarActionsSet02();

21
index.html

@ -380,7 +380,6 @@
<li role="presentation"><a href="javascript:void(0)" role="menuitem" data-extcoin-menu="KMD" id="btn_kmd_wallet_send">Send</a></li>
<li role="presentation"><a href="javascript:void(0)" role="menuitem" data-extcoin-menu="KMD" id="btn_kmd_wallet_recieve">Recieve</a></li>
<li role="presentation"><a href="javascript:void(0)" role="menuitem" data-extcoin-menu="KMD" id="btn_kmd_wallet_transactions">Transactions</a></li>
<li role="presentation"><a href="javascript:void(0)" role="menuitem" data-extcoin-menu="KMD" id="btn_kmd_wallet_pax">PAX</a></li>
<li class="divider" role="presentation"></li>
<li role="presentation"><a href="javascript:void(0)" role="menuitem" data-extcoin-menu="KMD" id="btn_kmd_wallet_settings">Settings</a></li>
</ul>
@ -395,7 +394,7 @@
<li role="presentation"><a href="javascript:void(0)" role="menuitem" data-extcoin-menu="ZEC" id="btn_zec_wallet_recieve">Recieve</a></li>
<li role="presentation"><a href="javascript:void(0)" role="menuitem" data-extcoin-menu="ZEC" id="btn_zec_wallet_transactions">Transactions</a></li>
<li class="divider" role="presentation"></li>
<li role="presentation"><a href="javascript:void(0)" role="menuitem">Settings</a></li>
<li role="presentation"><a href="javascript:void(0)" role="menuitem" data-extcoin-menu="ZEC" id="btn_zec_wallet_settings">Settings</a></li>
</ul>
</div>
<!-- End ZEC Wallet Header button -->
@ -791,7 +790,7 @@
<!-- Panel getinfo -->
<div class="panel" id="projects">
<div class="panel-heading">
<h3 data-extcoin="COIN" class="panel-title">Send KMD</h3>
<h3 data-extcoin="COIN" class="panel-title">Send <span data-extcoinname="COIN"></span></h3>
<!--<div class="panel-actions">
<a class="panel-action icon md-refresh-alt" data-toggle="panel-refresh" data-load-type="blue-only"
data-load-callback="KMDSendScreenRefreshCallback" aria-hidden="true"></a>
@ -802,15 +801,15 @@
<div class="row">
<div class="col-xlg-12 form-group form-material">
<label class="control-label" data-extcoin="COIN" for="kmd_wallet_send_from">Send From</label>
<select class="form-control form-material showkmdwalletaddrs show-tick" data-extcoin="COIN" id="kmd_wallet_send_from" title="Select Transparent or Private KMD Address" data-size="5">
<select class="form-control form-material showkmdwalletaddrs show-tick" data-extcoin="COIN" id="kmd_wallet_send_from" title="Select Transparent or Private Address" data-size="5">
</select>
</div>
<div class="col-xlg-12 form-group form-material">
<label class="control-label" data-extcoin="COIN" for="kmd_wallet_sendto">Send To</label>
<input type="text" class="form-control" data-extcoin="COIN" id="kmd_wallet_sendto" name="kmd_wallet_sendto" placeholder="Enter Transparent or Private KMD address" autocomplete="off" required/>
<input type="text" class="form-control" data-extcoin="COIN" id="kmd_wallet_sendto" name="kmd_wallet_sendto" placeholder="Enter Transparent or Private address" autocomplete="off" required/>
</div>
<div class="col-lg-6 form-group form-material">
<label class="control-label" for="kmd_wallet_amount" data-extcoin="COIN" id="kmd_wallet_amount_label">KMD</label>
<label class="control-label" for="kmd_wallet_amount" data-extcoin="COIN" id="kmd_wallet_amount_label"><span data-extcoinname="COIN"></span></label>
<input type="text" class="form-control" data-extcoin="COIN" id="kmd_wallet_amount" name="kmd_wallet_amount" placeholder="0.000" autocomplete="off"/>
</div>
<div class="col-lg-6 form-group form-material">
@ -818,10 +817,10 @@
<input type="text" class="form-control" data-extcoin="COIN" id="kmd_wallet_fee" name="kmd_wallet_fee" placeholder="0.000" value="0.0001" autocomplete="off"/>
</div>
<div class="col-lg-12">
<span data-extcoin="KMD"><b>Total (KMD - txfee):</b> <span data-extcoin="COIN" id="kmd_wallet_total_value">0.000</span> <span data-extcoin="COIN" id="kmd_wallet_total_coinname">KMD</span></span>
<span data-extcoin="KMD"><b>Total (<span data-extcoinname="COIN"></span> - txfee):</b> <span data-extcoin="COIN" id="kmd_wallet_total_value">0.000</span> <span data-extcoin="COIN" id="kmd_wallet_total_coinname" data-extcoinname="COIN"></span></span>
</div>
<div class="col-lg-12">
<button type="submit" class="btn btn-primary waves-effect waves-light pull-right" data-toggle="modal" id="kmd_wallet_send_coins_btn">Send KMD</button>
<button type="submit" class="btn btn-primary waves-effect waves-light pull-right" data-toggle="modal" id="kmd_wallet_send_coins_btn">Send <span data-extcoinname="COIN"></span></button>
</div>
</div>
</div>
@ -858,7 +857,7 @@
<tr>
<th>Status</th>
<th>ID</th>
<th>creation_time</th>
<th>Time</th>
<th>Result</th>
</tr>
</thead>
@ -866,7 +865,7 @@
<tr>
<th>Status</th>
<th>ID</th>
<th>creation_time</th>
<th>Time</th>
<th>Result</th>
</tr>
</tfoot>
@ -914,7 +913,7 @@
<!-- Panel getinfo -->
<div class="panel" id="projects">
<div class="panel-heading">
<h3 class="panel-title">Komodo Info</h3>
<h3 class="panel-title"><span data-extcointitle="COIN">Komodo</span> Info</h3>
</div>
<div class="table-responsive">
<table class="table table-striped">

Loading…
Cancel
Save