|
|
@ -1,68 +1,66 @@ |
|
|
|
var KMDWalletDashboard = function() { |
|
|
|
|
|
|
|
var handle_KMD_Dashboard = 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()); |
|
|
|
if ( sessionStorage.getItem('edexTmpMode') === "Native") { |
|
|
|
sessionStorage.setItem('edexTmpRefresh', "start"); |
|
|
|
} |
|
|
|
if ( sessionStorage.getItem('edexTmpMode') === "Basilisk" || sessionStorage.getItem('edexTmpMode') === "Full" ) { |
|
|
|
sessionStorage.setItem('edexTmpRefresh', "stop"); |
|
|
|
} |
|
|
|
$('#kmd_wallet_dashoard_section').show(); |
|
|
|
$('#kmd_wallet_dashboardinfo').show(); |
|
|
|
$('#btn_' + action_btn_code + '_wallet_dashboard').click(function() { |
|
|
|
console.log('kmd wallet dashbaord button clicked...'); |
|
|
|
console.log($(this).data()); |
|
|
|
if ( sessionStorage.getItem('edexTmpMode') === 'Native') { |
|
|
|
sessionStorage.setItem('edexTmpRefresh', 'start'); |
|
|
|
} |
|
|
|
if ( sessionStorage.getItem('edexTmpMode') === 'Basilisk' || sessionStorage.getItem('edexTmpMode') === 'Full' ) { |
|
|
|
sessionStorage.setItem('edexTmpRefresh', 'stop'); |
|
|
|
} |
|
|
|
$('#kmd_wallet_dashoard_section').show(); |
|
|
|
$('#kmd_wallet_dashboardinfo').show(); |
|
|
|
$('#kmd_wallet_send').hide(); |
|
|
|
$('#kmd_wallet_recieve_section').hide(); |
|
|
|
$('#kmd_wallet_recieve_section').hide(); |
|
|
|
$('#kmd_wallet_settings').hide(); |
|
|
|
getTotalKMDBalance(); |
|
|
|
KMDfillTxHistoryT(); |
|
|
|
clearSendManyFieldData(); |
|
|
|
|
|
|
|
}); |
|
|
|
getTotalKMDBalance(); |
|
|
|
KMDfillTxHistoryT(); |
|
|
|
clearSendManyFieldData(); |
|
|
|
}); |
|
|
|
|
|
|
|
$('.btn-kmdtxid').click(function() { |
|
|
|
console.log('kmd-txid-details-btn button clicked!..'); |
|
|
|
console.log($(this).data('txid-type')); |
|
|
|
console.log($(this).data('txid')); |
|
|
|
|
|
|
|
var kmd_addr_txid_info = KMDGetTransactionIDInfo($(this).data('txid')); |
|
|
|
console.log(kmd_addr_txid_info); |
|
|
|
$('#kmd_txid_info_amount').text(kmd_addr_txid_info[0].amount); |
|
|
|
$('#kmd_txid_info_fee').text(kmd_addr_txid_info[0].fee); |
|
|
|
$('#kmd_txid_info_confirmations').text(kmd_addr_txid_info[0].confirmations); |
|
|
|
$('#kmd_txid_info_blockhash').text(kmd_addr_txid_info[0].blockhash); |
|
|
|
$('#kmd_txid_info_blockindex').text(kmd_addr_txid_info[0].blockindex); |
|
|
|
$('#kmd_txid_info_blocktime').text(kmd_addr_txid_info[0].blocktime); |
|
|
|
$('#kmd_txid_info_txid').text(kmd_addr_txid_info[0].txid); |
|
|
|
$('#kmd_txid_info_walletconflicts').text(kmd_addr_txid_info[0].walletconflicts); |
|
|
|
$('#kmd_txid_info_time').text(kmd_addr_txid_info[0].time); |
|
|
|
$('#kmd_txid_info_timereceived').text(kmd_addr_txid_info[0].timereceived); |
|
|
|
$('#kmd_txid_info_vjoinsplit').text(kmd_addr_txid_info[0].vjoinsplit); |
|
|
|
$('#kmd_txid_info_details').text(kmd_addr_txid_info[0].details); |
|
|
|
$('#kmd_txid_info_hex').val(kmd_addr_txid_info[0].hex); |
|
|
|
clearSendManyFieldData(); |
|
|
|
}); |
|
|
|
$('.btn-kmdtxid').click(function() { |
|
|
|
console.log('kmd-txid-details-btn button clicked!..'); |
|
|
|
console.log($(this).data('txid-type')); |
|
|
|
console.log($(this).data('txid')); |
|
|
|
|
|
|
|
var kmd_addr_txid_info = KMDGetTransactionIDInfo($(this).data('txid')); |
|
|
|
console.log(kmd_addr_txid_info); |
|
|
|
$('#kmd_txid_info_amount').text(kmd_addr_txid_info[0].amount); |
|
|
|
$('#kmd_txid_info_fee').text(kmd_addr_txid_info[0].fee); |
|
|
|
$('#kmd_txid_info_confirmations').text(kmd_addr_txid_info[0].confirmations); |
|
|
|
$('#kmd_txid_info_blockhash').text(kmd_addr_txid_info[0].blockhash); |
|
|
|
$('#kmd_txid_info_blockindex').text(kmd_addr_txid_info[0].blockindex); |
|
|
|
$('#kmd_txid_info_blocktime').text(kmd_addr_txid_info[0].blocktime); |
|
|
|
$('#kmd_txid_info_txid').text(kmd_addr_txid_info[0].txid); |
|
|
|
$('#kmd_txid_info_walletconflicts').text(kmd_addr_txid_info[0].walletconflicts); |
|
|
|
$('#kmd_txid_info_time').text(kmd_addr_txid_info[0].time); |
|
|
|
$('#kmd_txid_info_timereceived').text(kmd_addr_txid_info[0].timereceived); |
|
|
|
$('#kmd_txid_info_vjoinsplit').text(kmd_addr_txid_info[0].vjoinsplit); |
|
|
|
$('#kmd_txid_info_details').text(kmd_addr_txid_info[0].details); |
|
|
|
$('#kmd_txid_info_hex').val(kmd_addr_txid_info[0].hex); |
|
|
|
clearSendManyFieldData(); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var handle_KMD_Send = function() { |
|
|
|
var action_btn_code = getHeaderActionMenuButtonCoinCode(); |
|
|
|
$('#btn_'+action_btn_code+'_wallet_send').click(function() { |
|
|
|
KMDListAllOPIDs(); |
|
|
|
//console.log('kmd wallet send button clicked...');
|
|
|
|
sessionStorage.setItem('edexTmpRefresh', "stop"); |
|
|
|
var action_btn_code = getHeaderActionMenuButtonCoinCode(); |
|
|
|
|
|
|
|
$('#btn_' + action_btn_code + '_wallet_send').click(function() { |
|
|
|
var tmpoptions = ''; |
|
|
|
|
|
|
|
KMDListAllOPIDs(); |
|
|
|
sessionStorage.setItem('edexTmpRefresh', 'stop'); |
|
|
|
|
|
|
|
$('#kmd_wallet_dashboardinfo').hide(); |
|
|
|
$('#kmd_wallet_send').show(); |
|
|
|
$('#kmd_wallet_recieve_section').hide(); |
|
|
|
$('#kmd_wallet_recieve_section').hide(); |
|
|
|
$('#kmd_wallet_settings').hide(); |
|
|
|
|
|
|
|
var kmd_addr_list_with_balance = KMDlistunspentT(); |
|
|
|
//console.log(kmd_addr_list_with_balance);
|
|
|
|
|
|
|
|
tmpoptions += '<option> - Select Transparent or Private Address - </option>'; |
|
|
|
$.each(kmd_addr_list_with_balance, function(index) { |
|
|
@ -71,35 +69,34 @@ var KMDWalletDashboard = function() { |
|
|
|
}); |
|
|
|
|
|
|
|
var kmd_z_addr_list_with_balance = KMDListaddrZ(); |
|
|
|
//console.log(kmd_z_addr_list_with_balance);
|
|
|
|
$.each(kmd_z_addr_list_with_balance, function(index) { |
|
|
|
if (kmd_z_addr_list_with_balance[index].total !== 0) { |
|
|
|
tmpoptions += '<option value="' + kmd_z_addr_list_with_balance[index].addr + '" data-total="' + kmd_z_addr_list_with_balance[index].total.toFixed(8) + '">[ ' + kmd_z_addr_list_with_balance[index].total.toFixed(8) + ' KMD ]  ' + kmd_z_addr_list_with_balance[index].addr + '</option>'; |
|
|
|
$('#kmd_wallet_send_from').html(tmpoptions); |
|
|
|
} |
|
|
|
if (kmd_z_addr_list_with_balance[index].total !== 0) { |
|
|
|
tmpoptions += '<option value="' + kmd_z_addr_list_with_balance[index].addr + '" data-total="' + kmd_z_addr_list_with_balance[index].total.toFixed(8) + '">[ ' + kmd_z_addr_list_with_balance[index].total.toFixed(8) + ' KMD ]  ' + kmd_z_addr_list_with_balance[index].addr + '</option>'; |
|
|
|
$('#kmd_wallet_send_from').html(tmpoptions); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
$('.showkmdwalletaddrs').selectpicker({ style: 'btn-info' }); |
|
|
|
$('.showkmdwalletaddrs').selectpicker('refresh'); |
|
|
|
clearSendManyFieldData(); |
|
|
|
$('.showkmdwalletaddrs').selectpicker('refresh'); |
|
|
|
clearSendManyFieldData(); |
|
|
|
}); |
|
|
|
|
|
|
|
$('.showkmdwalletaddrs').on('change', function(){ |
|
|
|
var selected = $(this).find("option:selected").val(); |
|
|
|
//console.log(selected);
|
|
|
|
//console.log($(this).find("option:selected").data('total'));
|
|
|
|
}); |
|
|
|
|
|
|
|
$('#kmd_wallet_amount').keyup(function() { |
|
|
|
var sum_val1 = parseFloat($('#kmd_wallet_amount').val()) |
|
|
|
var sum_val2 = parseFloat($('#kmd_wallet_fee').val()) |
|
|
|
var total_minus_currency_fee = sum_val1 - sum_val2; |
|
|
|
var mdl_send_btn = $('#kmd_wallet_send_coins_btn'); |
|
|
|
var sum_val1 = parseFloat($('#kmd_wallet_amount').val()), |
|
|
|
sum_val2 = parseFloat($('#kmd_wallet_fee').val()), |
|
|
|
total_minus_currency_fee = sum_val1 - sum_val2, |
|
|
|
mdl_send_btn = $('#kmd_wallet_send_coins_btn'); |
|
|
|
|
|
|
|
//console.log($('#kmd_wallet_amount').val());
|
|
|
|
$('#kmd_wallet_total_value').text(total_minus_currency_fee.toFixed(8)); |
|
|
|
|
|
|
|
if ($('#kmd_wallet_send_from').val() != '- Select Transparent or Private KMD Address -' && $('#kmd_wallet_amount').val() != '' && $('#kmd_wallet_sendto') != '' && $('#kmd_wallet_fee') != '' ) { |
|
|
|
if ($('#kmd_wallet_send_from').val() != '- Select Transparent or Private KMD Address -' && |
|
|
|
$('#kmd_wallet_amount').val() != '' && |
|
|
|
$('#kmd_wallet_sendto') != '' && |
|
|
|
$('#kmd_wallet_fee') != '' ) { |
|
|
|
mdl_send_btn.removeClass('disabled'); |
|
|
|
//mdl_send_btn.attr('data-dismiss','modal');
|
|
|
|
//mdl_send_btn.attr('data-target','#SendCoinModelStep2');
|
|
|
@ -110,356 +107,376 @@ var KMDWalletDashboard = function() { |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
$('#kmd_wallet_fee').keyup(function() { |
|
|
|
var sum_val1 = parseFloat($('#kmd_wallet_amount').val()) |
|
|
|
var sum_val2 = parseFloat($('#kmd_wallet_fee').val()) |
|
|
|
var total_minus_currency_fee = sum_val1 - sum_val2; |
|
|
|
var mdl_send_btn = $('#kmd_wallet_send_coins_btn'); |
|
|
|
$('#kmd_wallet_fee').keyup(function() { |
|
|
|
var sum_val1 = parseFloat($('#kmd_wallet_amount').val()), |
|
|
|
sum_val2 = parseFloat($('#kmd_wallet_fee').val()), |
|
|
|
total_minus_currency_fee = sum_val1 - sum_val2, |
|
|
|
mdl_send_btn = $('#kmd_wallet_send_coins_btn'); |
|
|
|
|
|
|
|
//console.log($('#kmd_wallet_amount').val());
|
|
|
|
$('#kmd_wallet_total_value').text(total_minus_currency_fee.toFixed(8)); |
|
|
|
$('#kmd_wallet_total_value').text(total_minus_currency_fee.toFixed(8)); |
|
|
|
|
|
|
|
if ($('#kmd_wallet_send_from').val() != '- Select Transparent or Private KMD Address -' && $('#kmd_wallet_amount').val() != '' && $('#kmd_wallet_sendto') != '' && $('#kmd_wallet_fee') != '' ) { |
|
|
|
mdl_send_btn.removeClass('disabled'); |
|
|
|
//mdl_send_btn.attr('data-dismiss','modal');
|
|
|
|
//mdl_send_btn.attr('data-target','#SendCoinModelStep2');
|
|
|
|
} else { |
|
|
|
mdl_send_btn.addClass('disabled'); |
|
|
|
mdl_send_btn.removeAttr('data-dismiss'); |
|
|
|
mdl_send_btn.removeAttr('data-target'); |
|
|
|
} |
|
|
|
}); |
|
|
|
if ($('#kmd_wallet_send_from').val() != '- Select Transparent or Private KMD Address -' && |
|
|
|
$('#kmd_wallet_amount').val() != '' && |
|
|
|
$('#kmd_wallet_sendto') != '' && |
|
|
|
$('#kmd_wallet_fee') != '' ) { |
|
|
|
mdl_send_btn.removeClass('disabled'); |
|
|
|
//mdl_send_btn.attr('data-dismiss','modal');
|
|
|
|
//mdl_send_btn.attr('data-target','#SendCoinModelStep2');
|
|
|
|
} else { |
|
|
|
mdl_send_btn.addClass('disabled'); |
|
|
|
mdl_send_btn.removeAttr('data-dismiss'); |
|
|
|
mdl_send_btn.removeAttr('data-target'); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
/*$('#kmd_wallet_send_coins_btn').click(function() { |
|
|
|
console.log('send button clicked in form...') |
|
|
|
});*/ |
|
|
|
|
|
|
|
$('.extcoin-send-form').validate({ |
|
|
|
//errorElement: 'span', //default input error message container
|
|
|
|
//errorClass: 'help-block', // default input error message class
|
|
|
|
//focusInvalid: false, // do not focus the last invalid input
|
|
|
|
rules: { |
|
|
|
kmd_wallet_send_from: { |
|
|
|
required: true |
|
|
|
}, |
|
|
|
kmd_wallet_sendto: { |
|
|
|
required: true |
|
|
|
}, |
|
|
|
kmd_wallet_amount: { |
|
|
|
required: true |
|
|
|
}, |
|
|
|
kmd_wallet_fee: { |
|
|
|
required: true |
|
|
|
}, |
|
|
|
kmd_wallet_total_value: { |
|
|
|
required: true |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
messages: { |
|
|
|
kmd_wallet_send_from: { |
|
|
|
required: "From Address is required." |
|
|
|
}, |
|
|
|
kmd_wallet_sendto: { |
|
|
|
required: "To Address is required." |
|
|
|
}, |
|
|
|
kmd_wallet_amount: { |
|
|
|
required: "Please enter KMD amount to send." |
|
|
|
}, |
|
|
|
kmd_wallet_fee: { |
|
|
|
required: "Make sure you have fee entered. Default value is 0.0001 KMD." |
|
|
|
}, |
|
|
|
kmd_wallet_total_value: { |
|
|
|
required: "Make sure you have both amount and fee entered to calculate final total." |
|
|
|
} |
|
|
|
}, |
|
|
|
$('.extcoin-send-form').validate({ |
|
|
|
// errorElement: 'span', //default input error message container
|
|
|
|
// errorClass: 'help-block', // default input error message class
|
|
|
|
// focusInvalid: false, // do not focus the last invalid input
|
|
|
|
rules: { |
|
|
|
kmd_wallet_send_from: { |
|
|
|
required: true |
|
|
|
}, |
|
|
|
kmd_wallet_sendto: { |
|
|
|
required: true |
|
|
|
}, |
|
|
|
kmd_wallet_amount: { |
|
|
|
required: true |
|
|
|
}, |
|
|
|
kmd_wallet_fee: { |
|
|
|
required: true |
|
|
|
}, |
|
|
|
kmd_wallet_total_value: { |
|
|
|
required: true |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
submitHandler: function(form) { |
|
|
|
console.log('Sent control here after clicked in form...'); |
|
|
|
KMDZSendManyTransaction(); |
|
|
|
clearSendManyFieldData(); |
|
|
|
} |
|
|
|
}); |
|
|
|
messages: { |
|
|
|
kmd_wallet_send_from: { |
|
|
|
required: 'From Address is required.' |
|
|
|
}, |
|
|
|
kmd_wallet_sendto: { |
|
|
|
required: 'To Address is required.' |
|
|
|
}, |
|
|
|
kmd_wallet_amount: { |
|
|
|
required: 'Please enter KMD amount to send.' |
|
|
|
}, |
|
|
|
kmd_wallet_fee: { |
|
|
|
required: 'Make sure you have fee entered. Default value is 0.0001 KMD.' |
|
|
|
}, |
|
|
|
kmd_wallet_total_value: { |
|
|
|
required: 'Make sure you have both amount and fee entered to calculate final total.' |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
$('.extcoin-send-form #kmd_wallet_send_coins_btn').keypress(function(e) { |
|
|
|
//console.log('send button clicked in form...');
|
|
|
|
if (e.which == 13) { |
|
|
|
if ($('.extcoin-send-form').validate().form()) { |
|
|
|
$('.extcoin-send-form').submit(); //form validation success, call ajax form submit
|
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
}); |
|
|
|
submitHandler: function(form) { |
|
|
|
console.log('Sent control here after clicked in form...'); |
|
|
|
KMDZSendManyTransaction(); |
|
|
|
clearSendManyFieldData(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
$('#kmd_opids_status_btn').click(function(){ |
|
|
|
KMDListAllOPIDs(); |
|
|
|
}); |
|
|
|
$('.extcoin-send-form #kmd_wallet_send_coins_btn').keypress(function(e) { |
|
|
|
if (e.which == 13) { |
|
|
|
if ($('.extcoin-send-form').validate().form()) { |
|
|
|
$('.extcoin-send-form').submit(); // form validation success, call ajax form submit
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
$('#kmd_opids_status_btn').click(function(){ |
|
|
|
KMDListAllOPIDs(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
var KMDWalletSettings = function() { |
|
|
|
var action_btn_code = getHeaderActionMenuButtonCoinCode(); |
|
|
|
$('#btn_'+action_btn_code+'_wallet_settings').click(function() { |
|
|
|
var action_btn_code = getHeaderActionMenuButtonCoinCode(); |
|
|
|
|
|
|
|
$('#btn_' + action_btn_code + '_wallet_settings').click(function() { |
|
|
|
console.log('wallet settings button clicked...'); |
|
|
|
sessionStorage.setItem('edexTmpRefresh', "stop"); |
|
|
|
sessionStorage.setItem('edexTmpRefresh', 'stop'); |
|
|
|
$('#kmd_wallet_dashboardinfo').hide(); |
|
|
|
$('#kmd_wallet_dashoard_section').hide(); |
|
|
|
$('#kmd_wallet_send').hide(); |
|
|
|
$('#kmd_wallet_recieve_section').hide(); |
|
|
|
$('#kmd_wallet_recieve_section').hide(); |
|
|
|
$('#kmd_wallet_settings').show(); |
|
|
|
getKMDWalletInfo(); |
|
|
|
getKMDInfo(); |
|
|
|
clearSendManyFieldData(); |
|
|
|
getKMDInfo(); |
|
|
|
clearSendManyFieldData(); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
var KMDWalletRecieve = function() { |
|
|
|
var action_btn_code = getHeaderActionMenuButtonCoinCode(); |
|
|
|
|
|
|
|
var KMDWalletRecieve = function() { |
|
|
|
var action_btn_code = getHeaderActionMenuButtonCoinCode(); |
|
|
|
$('#btn_'+action_btn_code+'_wallet_recieve').click(function() { |
|
|
|
//console.log('wallet recieve button clicked...');
|
|
|
|
sessionStorage.setItem('edexTmpRefresh', "stop"); |
|
|
|
$('#kmd_wallet_dashboardinfo').hide(); |
|
|
|
$('#kmd_wallet_dashoard_section').hide(); |
|
|
|
$('#kmd_wallet_send').hide(); |
|
|
|
$('#kmd_wallet_recieve_section').show(); |
|
|
|
$('#kmd_wallet_settings').hide(); |
|
|
|
KMDListAllAddr(); |
|
|
|
clearSendManyFieldData(); |
|
|
|
}); |
|
|
|
$('#btn_' + action_btn_code + '_wallet_recieve').click(function() { |
|
|
|
sessionStorage.setItem('edexTmpRefresh', 'stop'); |
|
|
|
$('#kmd_wallet_dashboardinfo').hide(); |
|
|
|
$('#kmd_wallet_dashoard_section').hide(); |
|
|
|
$('#kmd_wallet_send').hide(); |
|
|
|
$('#kmd_wallet_recieve_section').show(); |
|
|
|
$('#kmd_wallet_settings').hide(); |
|
|
|
KMDListAllAddr(); |
|
|
|
clearSendManyFieldData(); |
|
|
|
}); |
|
|
|
|
|
|
|
$('#kmd_get_new_taddr').click(function() { |
|
|
|
console.log('get new T address button clicked...'); |
|
|
|
KMDGetNewAddresses('public'); |
|
|
|
KMDListAllAddr(); |
|
|
|
toastr.info("Receiving Address list updated", "Wallet Notification"); |
|
|
|
}); |
|
|
|
$('#kmd_get_new_taddr').click(function() { |
|
|
|
console.log('get new T address button clicked...'); |
|
|
|
KMDGetNewAddresses('public'); |
|
|
|
KMDListAllAddr(); |
|
|
|
toastr.info('Receiving Address list updated', 'Wallet Notification'); |
|
|
|
}); |
|
|
|
|
|
|
|
$('#kmd_get_new_zaddr').click(function() { |
|
|
|
console.log('get new Z address button clicked...'); |
|
|
|
KMDGetNewAddresses('private'); |
|
|
|
KMDListAllAddr(); |
|
|
|
toastr.info("Receiving Address list updated", "Wallet Notification"); |
|
|
|
}); |
|
|
|
}; |
|
|
|
$('#kmd_get_new_zaddr').click(function() { |
|
|
|
console.log('get new Z address button clicked...'); |
|
|
|
KMDGetNewAddresses('private'); |
|
|
|
KMDListAllAddr(); |
|
|
|
toastr.info('Receiving Address list updated', 'Wallet Notification'); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
var handleWalletDashboardAlet = function() { |
|
|
|
$('#extcoin-wallet-connection-alert-btn').click(function(){ |
|
|
|
RunKMDInitFunctions(); |
|
|
|
}); |
|
|
|
} |
|
|
|
var handleWalletDashboardAlet = function() { |
|
|
|
$('#extcoin-wallet-connection-alert-btn').click(function() { |
|
|
|
RunKMDInitFunctions(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
return { |
|
|
|
//main function to initiate the module
|
|
|
|
init: function() { |
|
|
|
handle_KMD_Dashboard(); |
|
|
|
//KMDfillTxHistoryT();
|
|
|
|
handle_KMD_Send(); |
|
|
|
KMDWalletRecieve(); |
|
|
|
KMDWalletSettings(); |
|
|
|
//RunKMDInitFunctions();
|
|
|
|
handleWalletDashboardAlet(); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// main function to initiate the module
|
|
|
|
init: function() { |
|
|
|
handle_KMD_Dashboard(); |
|
|
|
//KMDfillTxHistoryT();
|
|
|
|
handle_KMD_Send(); |
|
|
|
KMDWalletRecieve(); |
|
|
|
KMDWalletSettings(); |
|
|
|
//RunKMDInitFunctions();
|
|
|
|
handleWalletDashboardAlet(); |
|
|
|
} |
|
|
|
}; |
|
|
|
}(); |
|
|
|
|
|
|
|
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(); |
|
|
|
} |
|
|
|
}, 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" ); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 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); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, 30000); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
function RunKMDInitFunctions() { |
|
|
|
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(); |
|
|
|
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 check1 = CheckIfConnected(); |
|
|
|
console.log(check1[0]); |
|
|
|
if ( check1[0] == 'not active' ) { |
|
|
|
console.log('Could not connect to external wallet. Is external wallet running?'); |
|
|
|
toastr.error("Connection Error. Is external wallet running?", "Wallet Notification"); |
|
|
|
$('#extcoin-wallet').hide(); |
|
|
|
$('#extcoin-wallet-connection-alert').show(); |
|
|
|
} |
|
|
|
if ( check1[0] == 'null return' ) { |
|
|
|
console.log('Could not connect to external wallet. Is iguana connected to external wallet?'); |
|
|
|
toastr.error("Connection Error. Is iguana connected to external wallet?", "Wallet Notification"); |
|
|
|
$('#extcoin-wallet').hide(); |
|
|
|
$('#extcoin-wallet-connection-alert').show(); |
|
|
|
} |
|
|
|
if ( check1[0] == 'activating' ) { |
|
|
|
$('#extcoin-wallet-activating-alert').show(); |
|
|
|
$('#extcoin-wallet').show(); |
|
|
|
$('#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); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
var check1 = CheckIfConnected(); |
|
|
|
console.log(check1[0]); |
|
|
|
if ( check1[0] == 'not active' ) { |
|
|
|
console.log('Could not connect to external wallet. Is external wallet running?'); |
|
|
|
toastr.error('Connection Error. Is external wallet running?', 'Wallet Notification'); |
|
|
|
$('#extcoin-wallet').hide(); |
|
|
|
$('#extcoin-wallet-connection-alert').show(); |
|
|
|
} |
|
|
|
if ( check1[0] == 'null return' ) { |
|
|
|
console.log('Could not connect to external wallet. Is iguana connected to external wallet?'); |
|
|
|
toastr.error('Connection Error. Is iguana connected to external wallet?', 'Wallet Notification'); |
|
|
|
$('#extcoin-wallet').hide(); |
|
|
|
$('#extcoin-wallet-connection-alert').show(); |
|
|
|
} |
|
|
|
if ( check1[0] == 'activating' ) { |
|
|
|
$('#extcoin-wallet-activating-alert').show(); |
|
|
|
$('#extcoin-wallet').show(); |
|
|
|
$('#extcoin-wallet-connection-alert').hide(); |
|
|
|
|
|
|
|
function _getKMDInfo() { |
|
|
|
var passthru_agent = getPassthruAgent(), |
|
|
|
tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), |
|
|
|
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', |
|
|
|
success: function(data, textStatus, jqXHR) { |
|
|
|
var AjaxOutputData = JSON.parse(data); |
|
|
|
|
|
|
|
function getRemoteCurrentHeight() { |
|
|
|
$.ajax({ |
|
|
|
type: 'GET', |
|
|
|
url: 'http://localhost:7778/api/dex/getinfo?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth') + '&symbol=KMD', |
|
|
|
//dataType: 'text',
|
|
|
|
success: function(data, textStatus, jqXHR) { |
|
|
|
data = JSON.parse(data); |
|
|
|
if (data && data.blocks) { |
|
|
|
totalBlocksInExplorer = data.blocks; |
|
|
|
} |
|
|
|
}, |
|
|
|
error: function(xhr, textStatus, error) { |
|
|
|
console.log('failed getinfo from dex api'); |
|
|
|
console.log(xhr.statusText); |
|
|
|
console.log(textStatus); |
|
|
|
console.log(error); |
|
|
|
} |
|
|
|
}); |
|
|
|
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); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
var currentBestBlockInterval; |
|
|
|
function startBestBlockInterval() { |
|
|
|
currentBestBlockInterval = setInterval(function() { |
|
|
|
$.ajax({ |
|
|
|
type: 'POST', |
|
|
|
data: { 'herdname': 'komodo', 'lastLines': 1 }, |
|
|
|
url: 'http://127.0.0.1:17777/shepherd/debuglog', |
|
|
|
//dataType: 'text',
|
|
|
|
success: function(data, textStatus, jqXHR) { |
|
|
|
//$('#read_debug_log_textarea').text(JSON.parse(data));
|
|
|
|
if (data.indexOf('UpdateTip') > -1) { |
|
|
|
var temp = data.split(' '); |
|
|
|
for (var i = 0; i < temp.length; i++) { |
|
|
|
if (temp[i].indexOf('height=') > -1) { |
|
|
|
var currentBestChain = temp[i].replace('height=', ''); |
|
|
|
$('#activating-komodod-tridot').hide(); |
|
|
|
$('#activating-komodod-progress').html(': ' + Math.floor(currentBestChain * 100 / totalBlocksInExplorer) + '% (blocks ' + currentBestChain + ' / ' + totalBlocksInExplorer + ')'); |
|
|
|
|
|
|
|
if (currentBestChain === totalBlocksInExplorer) { |
|
|
|
//clearInterval(totalBlocksInExplorerInterval);
|
|
|
|
clearInterval(currentBestBlockInterval); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
error: function(xhr, textStatus, error) { |
|
|
|
console.log('failed getting debug.log'); |
|
|
|
console.log(xhr.statusText); |
|
|
|
console.log(textStatus); |
|
|
|
console.log(error); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, 5000); |
|
|
|
function getRemoteCurrentHeight() { |
|
|
|
$.ajax({ |
|
|
|
type: 'GET', |
|
|
|
url: 'http://localhost:7778/api/dex/getinfo?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth') + '&symbol=KMD', |
|
|
|
success: function(data, textStatus, jqXHR) { |
|
|
|
data = JSON.parse(data); |
|
|
|
|
|
|
|
if (data && data.blocks) { |
|
|
|
totalBlocksInExplorer = data.blocks; |
|
|
|
} |
|
|
|
}, |
|
|
|
error: function(xhr, textStatus, error) { |
|
|
|
console.log('failed getinfo from dex api'); |
|
|
|
console.log(xhr.statusText); |
|
|
|
console.log(textStatus); |
|
|
|
console.log(error); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
getRemoteCurrentHeight(); |
|
|
|
var currentBestBlockInterval; |
|
|
|
function startBestBlockInterval() { |
|
|
|
currentBestBlockInterval = setInterval(function() { |
|
|
|
$.ajax({ |
|
|
|
type: 'POST', |
|
|
|
data: { |
|
|
|
'herdname': 'komodo', |
|
|
|
'lastLines': 1 |
|
|
|
}, |
|
|
|
url: 'http://127.0.0.1:17777/shepherd/debuglog', |
|
|
|
success: function(data, textStatus, jqXHR) { |
|
|
|
if (data.indexOf('UpdateTip') > -1) { |
|
|
|
var temp = data.split(' '); |
|
|
|
|
|
|
|
var totalBlocksInExplorer = 0; |
|
|
|
var totalBlocksInExplorerInterval = setInterval(function() { |
|
|
|
getRemoteCurrentHeight(); |
|
|
|
_getKMDInfo(); |
|
|
|
}, 60000); |
|
|
|
for (var i = 0; i < temp.length; i++) { |
|
|
|
if (temp[i].indexOf('height=') > -1) { |
|
|
|
var currentBestChain = temp[i].replace('height=', ''); |
|
|
|
$('#activating-komodod-tridot').hide(); |
|
|
|
$('#activating-komodod-progress').html(': ' + Math.floor(currentBestChain * 100 / totalBlocksInExplorer) + '% (blocks ' + currentBestChain + ' / ' + totalBlocksInExplorer + ')'); |
|
|
|
|
|
|
|
$('#kmd_wallet_dashoard_section').show(); |
|
|
|
$('#kmd_wallet_dashboardinfo').show(); |
|
|
|
$('#kmd_wallet_send').hide(); |
|
|
|
$('#kmd_wallet_recieve_section').hide(); |
|
|
|
$('#kmd_wallet_settings').hide(); |
|
|
|
} |
|
|
|
if ( check1[0] == 'connected') { |
|
|
|
getTotalKMDBalance(); |
|
|
|
KMDfillTxHistoryT(); |
|
|
|
$('#extcoin-wallet').show(); |
|
|
|
$('#extcoin-wallet-connection-alert').hide(); |
|
|
|
|
|
|
|
$('#kmd_wallet_dashoard_section').show(); |
|
|
|
$('#kmd_wallet_dashboardinfo').show(); |
|
|
|
$('#kmd_wallet_send').hide(); |
|
|
|
$('#kmd_wallet_recieve_section').hide(); |
|
|
|
$('#kmd_wallet_settings').hide(); |
|
|
|
if (currentBestChain === totalBlocksInExplorer) { |
|
|
|
//clearInterval(totalBlocksInExplorerInterval);
|
|
|
|
clearInterval(currentBestBlockInterval); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
error: function(xhr, textStatus, error) { |
|
|
|
console.log('failed getting debug.log'); |
|
|
|
console.log(xhr.statusText); |
|
|
|
console.log(textStatus); |
|
|
|
console.log(error); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, 5000); |
|
|
|
} |
|
|
|
//KMDWalletDashboard.init()
|
|
|
|
|
|
|
|
getRemoteCurrentHeight(); |
|
|
|
|
|
|
|
var totalBlocksInExplorer = 0, |
|
|
|
totalBlocksInExplorerInterval = setInterval(function() { |
|
|
|
getRemoteCurrentHeight(); |
|
|
|
_getKMDInfo(); |
|
|
|
}, 60000); |
|
|
|
|
|
|
|
$('#kmd_wallet_dashoard_section').show(); |
|
|
|
$('#kmd_wallet_dashboardinfo').show(); |
|
|
|
$('#kmd_wallet_send').hide(); |
|
|
|
$('#kmd_wallet_recieve_section').hide(); |
|
|
|
NProgress.done(); |
|
|
|
} |
|
|
|
$('#kmd_wallet_settings').hide(); |
|
|
|
} |
|
|
|
if ( check1[0] == 'connected') { |
|
|
|
getTotalKMDBalance(); |
|
|
|
KMDfillTxHistoryT(); |
|
|
|
$('#extcoin-wallet').show(); |
|
|
|
$('#extcoin-wallet-connection-alert').hide(); |
|
|
|
|
|
|
|
$('#kmd_wallet_dashoard_section').show(); |
|
|
|
$('#kmd_wallet_dashboardinfo').show(); |
|
|
|
$('#kmd_wallet_send').hide(); |
|
|
|
$('#kmd_wallet_recieve_section').hide(); |
|
|
|
$('#kmd_wallet_settings').hide(); |
|
|
|
} |
|
|
|
|
|
|
|
// KMDWalletDashboard.init()
|
|
|
|
$('#kmd_wallet_recieve_section').hide(); |
|
|
|
NProgress.done(); |
|
|
|
} |
|
|
|
|
|
|
|
function getHeaderActionMenuButtonCoinCode() { |
|
|
|
var extcoin = $('[data-extcoin]').attr("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; |
|
|
|
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'; }; |
|
|
|
|
|
|
|
return action_menu_button_code; |
|
|
|
} |
|
|
|
|
|
|
|
function getPassthruAgent() { |
|
|
|
var extcoin = $('[data-extcoin]').attr("data-extcoin"); |
|
|
|
var passthru_agent = ''; |
|
|
|
if ( extcoin == 'KMD') { passthru_agent = 'komodo'; }; |
|
|
|
if ( extcoin == 'ZEC') { passthru_agent = 'zcash'; }; |
|
|
|
return passthru_agent; |
|
|
|
var extcoin = $('[data-extcoin]').attr('data-extcoin'); |
|
|
|
passthru_agent = ''; |
|
|
|
|
|
|
|
if ( extcoin == 'KMD') { passthru_agent = 'komodo'; }; |
|
|
|
if ( extcoin == 'ZEC') { passthru_agent = 'zcash'; }; |
|
|
|
|
|
|
|
return passthru_agent; |
|
|
|
} |
|
|
|
|
|
|
|
function getTotalKMDBalance() { |
|
|
|
console.log($('[data-extcoin]').attr("data-extcoin")); |
|
|
|
var extcoin = $('[data-extcoin]').attr("data-extcoin"); |
|
|
|
var passthru_agent = ''; |
|
|
|
if ( extcoin == 'KMD') { passthru_agent = 'komodo'; }; |
|
|
|
if ( extcoin == 'ZEC') { passthru_agent = 'zcash'; }; |
|
|
|
console.log($('[data-extcoin]').attr('data-extcoin')); |
|
|
|
var extcoin = $('[data-extcoin]').attr('data-extcoin'); |
|
|
|
var passthru_agent = ''; |
|
|
|
if ( extcoin == 'KMD') { passthru_agent = 'komodo'; }; |
|
|
|
if ( extcoin == 'ZEC') { passthru_agent = 'zcash'; }; |
|
|
|
|
|
|
|
var tmpIguanaRPCAuth = 'tmpIgRPCUser@'+sessionStorage.getItem('IguanaRPCAuth'); |
|
|
|
var ajax_data = {'userpass':tmpIguanaRPCAuth,"agent":passthru_agent,"method":"passthru","function":"z_gettotalbalance","hex":"3000"} |
|
|
|