diff --git a/src/ninki-engine.js b/src/ninki-engine.js index d37b857..6148554 100644 --- a/src/ninki-engine.js +++ b/src/ninki-engine.js @@ -2732,7 +2732,10 @@ function Engine() { //if this is //logic ot reset if any issue with cache/decryption - if (pubcache == '') { + + + //only cache on android + if (pubcache == '' || !m_this.Device.isCordova()) { //derive the root node path and cache @@ -2750,11 +2753,13 @@ function Engine() { opubcache.coldKey = coldKey.toBase58(); opubcache.ninkiKey = ninkiKey.toBase58(); - - m_this.Device.setSecureStorageObject("pubcache" + cachepath, opubcache, m_this.m_deviceSecKey, m_this.encrypt); - pubcache = opubcache; + //only set this on mobile + if (m_this.Device.isCordova()) { + m_this.Device.setSecureStorageObject("pubcache" + cachepath, opubcache, m_this.m_deviceSecKey, m_this.encrypt); + } + } diff --git a/src/ninki-ui-mobile.js b/src/ninki-ui-mobile.js index 9f2c871..894baf3 100644 --- a/src/ninki-ui-mobile.js +++ b/src/ninki-ui-mobile.js @@ -2461,7 +2461,7 @@ function UI() { cordova.plugins.clipboard.paste(function (text) { - $('#toAddress').val(text); + $('#toAddress').val(text.trim()); $("#toAddress").trigger('change'); }, function () { @@ -3534,9 +3534,9 @@ function UI() { Engine.Device.getStorageItem("ok_disp", function (res) { - if (res == "1") { + if (!Engine.m_offlineKeyBackup || res == "1") { - bootbox.dialog({ title: '
 Security Warning
', message: 'Backup your keys in Settings > Security Checklist.

Currently, if you lose access to this device, you will lose access to any bitcoins you have stored in your wallet.', closeButton: false, buttons: { + bootbox.dialog({ title: '
 Security Warning
', message: 'Backup your keys in Settings > Security Checklist.

Currently, if you lose access to this application, you will lose access to any bitcoins you have stored in your wallet.', closeButton: false, buttons: { main: { label: "I Understand", className: "btn-warning", @@ -3697,7 +3697,8 @@ function UI() { cordova.plugins.clipboard.paste(function (text) { - $("#txtCode").val(text); + text = text.replace(/\r?\n|\r/g, ''); + $("#txtCode").val(text.trim()); $("#txtCode").trigger('change'); }, function () { @@ -3970,8 +3971,8 @@ function UI() { statusbox = ' Rejected'; } - s += "
" + _.escape(timeLabel) + "
" + - "
" + statusbox + "
"; + s += "
" + _.escape(timeLabel) + "
" + + "
" + statusbox + "
"; } cachedInvoices = invoices; @@ -4051,8 +4052,8 @@ function UI() { statusbox = ' Rejected'; } - s += "
" + _.escape(timeLabel) + "
" + - "
" + statusbox + "
"; + s += "
" + _.escape(timeLabel) + "
" + + "
" + statusbox + "
"; } cachedInvoicesByUser = invoices; @@ -7662,11 +7663,11 @@ function UI() { Engine.Device.getStorageItem("ok_disp", function (res) { - if (res == "1") { + if (!Engine.m_offlineKeyBackup || res == "1") { if (currentBalanceInSatoshis >= 2500000) { - bootbox.dialog({ title: '
 Security Warning
', message: 'Backup your keys in Settings > Security Checklist.

Currently, if you lose access to this device, you will lose access to any bitcoins you have stored in your wallet.', closeButton: false, buttons: { + bootbox.dialog({ title: '
 Security Warning
', message: 'Backup your keys in Settings > Security Checklist.

Currently, if you lose access to this application, you will lose access to any bitcoins you have stored in your wallet.', closeButton: false, buttons: { main: { label: "I Understand", className: "btn-warning", @@ -7825,11 +7826,11 @@ function UI() { Engine.Device.getStorageItem("ok_disp", function (res) { - if (res == "1") { + if (!Engine.m_offlineKeyBackup || res == "1") { if (currentBalanceInSatoshis >= 2500000) { - bootbox.dialog({ title: '
 Security Warning
', message: 'Backup your keys in Settings > Security Checklist.

Currently, if you lose access to this device, you will lose access to any bitcoins you have stored in your wallet.', closeButton: false, buttons: { + bootbox.dialog({ title: '
 Security Warning
', message: 'Backup your keys in Settings > Security Checklist.

Currently, if you lose access to this application, you will lose access to any bitcoins you have stored in your wallet.', closeButton: false, buttons: { main: { label: "I Understand", className: "btn-warning", diff --git a/src/ninki-ui.js b/src/ninki-ui.js index 60e8d3b..0bbe08a 100644 --- a/src/ninki-ui.js +++ b/src/ninki-ui.js @@ -189,36 +189,45 @@ function UI() { $("#txt2faForBackupError").hide(); - var twoFactorCode = $("#txt2faForBackup").val(); - var codes = Engine.createBackupCodes(twoFactorCode, function (err, codes) { + if ($("#txt2faForBackup").parsley().isValid()) { - if (!err) { + var twoFactorCode = $("#txt2faForBackup").val(); - for (var i = 0; i < codes.length; i++) { + var codes = Engine.createBackupCodes(twoFactorCode, function (err, codes) { - $("#bc" + (i + 1)).text(codes[i].Code.substring(0, 5) + ' ' + codes[i].Code.substring(5, 8)); - } + if (!err) { - Engine.m_settings.BackupIndex = 1; + for (var i = 0; i < codes.length; i++) { - $("#pnlBackupCodes").show(); - $("#btnPrintCodes").show(); - $("#btnBackupCodes").addClass('disabled'); + $("#bc" + (i + 1)).text(codes[i].Code.substring(0, 5) + ' ' + codes[i].Code.substring(5, 8)); + } - } else { + Engine.m_settings.BackupIndex = 1; - $("#txt2faForBackupError").show(); + $("#pnlBackupCodes").show(); + $("#btnPrintCodes").show(); + $("#btnBackupCodes").addClass('disabled'); - } - }); + } else { + + $("#txt2faForBackupError").show(); + + } + }); + + } else { + + $("#txt2faForBackup").parsley().validate(); + + } }); $("#btnPairUseBackups").click(function () { - + $("#pairerror").hide(); $("#pairqr2fa").hide(); $("#pairusebackup").show(); @@ -234,7 +243,7 @@ function UI() { }); - + @@ -256,7 +265,7 @@ function UI() { }); - + //file-input var tmpContent = {}; @@ -1009,14 +1018,21 @@ function UI() { //password //hotkey - var deviceName = $("#txtAddDevice").val(); + if ($("#txtAddDevice").parsley().isValid()) { - Engine.createDevice(deviceName, function (err, result) { + var deviceName = $("#txtAddDevice").val(); + Engine.createDevice(deviceName, function (err, result) { - updateDeviceList(); - }); + updateDeviceList(); + + }); + + } else { + + $("#txtAddDevice").parsley().validate(); + } }); @@ -1794,7 +1810,7 @@ function UI() { $("#loginuser").hide(); $("#loginimg").hide(); - + Engine.Device.deleteStorageItem("user"); Engine.Device.deleteStorageItem("userimg"); Engine.Device.setStorageItem('guid', Engine.m_oguid); @@ -2453,7 +2469,7 @@ function UI() { $("#btnPassphraseLogin").click(function () { - var isvalid = $('#phrase2fa').parsley('validate'); + var isvalid = $('#phrase2fa').parsley().isValid(); if (isvalid) { @@ -2505,6 +2521,11 @@ function UI() { }); + + } else { + + $('#phrase2fa').parsley().validate(); + } }); @@ -3386,7 +3407,7 @@ function UI() { $("#cpassword").on('change keyup', function () { - $("#password1").parsley("validate"); + $("#password1").parsley().validate(); ; }); @@ -3409,7 +3430,7 @@ function UI() { var oldpassword = $("#oldpwd").val(); var twoFactorCode = $("#txtTwoFactorCodeForChangePwd").val(); - if ($("#frmpwdchange").parsley('validate')) { + if ($("#frmpwdchange").parsley().isValid()) { $("#chngpwdprog").show(); $("#chngpwdprogmess").show(); @@ -3483,6 +3504,10 @@ function UI() { $("#chngpwdprog").hide(); } + } else { + + $("#frmpwdchange").parsley().validate(); + } }); @@ -3631,7 +3656,7 @@ function UI() { //switch on two factor on login //setting changes always require two factor - if ($("#frmSaveTwoFactor").parsley('validate')) { + if ($("#frmSaveTwoFactor").parsley().isValid()) { var twoFactorCode = $("#txtsettings2fa").val(); var verifyToken = $("#txt2faVerifyToken").val(); @@ -3664,6 +3689,10 @@ function UI() { } }); + } else { + + $("#frmSaveTwoFactor").parsley().validate(); + } }); @@ -3734,9 +3763,14 @@ function UI() { $("#savesettingsbutton").click(function () { - if ($("#frmsettings").parsley('validate')) { + if ($("#frmsettings").parsley().isValid()) { + saveAccountSettingsToServer(); + } else { + + $("#frmsettings").parsley().validate(); + } }); @@ -3877,6 +3911,7 @@ function UI() { if (allok) { + $('#btnSendInvoice').prop('disabled', true); $('#textMessageSendInv').removeClass('alert alert-danger'); $('#textMessageSendInv').text('Creating transaction...'); $('#textMessageSendInv').show(); @@ -3886,6 +3921,8 @@ function UI() { payInvoice(selectedInvoiceUserName, selectedInvoiceAmount, selectedInvoiceId, twoFactorCode, function (err, result) { + $('#btnSendInvoice').prop('disabled', false); + if (!err) { $("#sendinvs2").hide(); @@ -5395,37 +5432,45 @@ function UI() { $("#twoFactorCodeFor2faError").hide(); - var twoFactorCode = $("#twoFactorCodeFor2fa").val(); + if ($("#twoFactorCodeFor2fa").parsley().isValid()) { - if (twoFactorCode.length == 6) { + var twoFactorCode = $("#twoFactorCodeFor2fa").val(); - Engine.getNewTwoFactorImg(twoFactorCode, function (err, twoFASecret) { + if (twoFactorCode.length == 6) { - if (!err) { + Engine.getNewTwoFactorImg(twoFactorCode, function (err, twoFASecret) { - var data = "otpauth://totp/Ninki:" + Engine.m_nickname + "?secret=" + twoFASecret + "&issuer=Ninki"; - var options = { text: data, width: 172, height: 172 }; + if (!err) { - $('#imgsettings2fa').text(''); - $('#imgsettings2fa').qrcode(options); + var data = "otpauth://totp/Ninki:" + Engine.m_nickname + "?secret=" + twoFASecret + "&issuer=Ninki"; + var options = { text: data, width: 172, height: 172 }; - $("#setup2faqr").show(); - $("#twofactorsettings").show(); - $("#2famodal").modal('show'); + $('#imgsettings2fa').text(''); + $('#imgsettings2fa').qrcode(options); - $("#savetwofactorerror").hide(); - $("#setup2faemail").hide(); + $("#setup2faqr").show(); + $("#twofactorsettings").show(); + $("#2famodal").modal('show'); - } else { + $("#savetwofactorerror").hide(); + $("#setup2faemail").hide(); - $("#twoFactorCodeFor2faError").show(); + } else { - } - }); + $("#twoFactorCodeFor2faError").show(); + + } + }); + + } else { + + $("#twoFactorCodeFor2faError").show(); + + } } else { - $("#twoFactorCodeFor2faError").show(); + $("#twoFactorCodeFor2fa").parsley().validate(); } @@ -6856,6 +6901,9 @@ function UI() { function generateAddressClient() { + var target = document.getElementById('craddrspin'); + var spinner = new Spinner(spinneropts).spin(target); + $("#craddrspin").show(); Engine.createAddress('m/0/0', 1, function (err, newAddress, path) { @@ -6869,6 +6917,8 @@ function UI() { //$('#requestaddress').text(tempate); $('#requestaddress').show(); + $("#craddrspin").hide(); + }); @@ -6915,6 +6965,9 @@ function UI() { if (allok) { + + $('#btnSendToFriend').prop('disabled', true); + $('input#friendAmount').css("border-color", "#ccc"); $('#textMessageSend').text('Creating transaction...'); $('#textMessageSend').show(); @@ -6923,6 +6976,8 @@ function UI() { $('#sendfriendprogstatus').width('10%'); Engine.sendTransaction('friend', friend, '', amount, twoFactorCode, function (err, transactionid) { + $('#btnSendToFriend').prop('disabled', false); + if (!err) { updateBalance(); $('#textCompleteSendNet').text('You sent ' + convertFromSatoshis(amount, COINUNIT) + ' ' + COINUNIT + ' to ' + friend); @@ -7016,6 +7071,8 @@ function UI() { if (allok) { + $('#btnsendmoneystd').prop('disabled', true); + $('#textMessageSendStd').text('Creating transaction...'); $('#textMessageSendStd').show(); $('#sendstdprogstatus').width('3%'); @@ -7025,6 +7082,8 @@ function UI() { Engine.sendTransaction('standard', '', address, amount, twoFactorCode, function (err, transactionid) { + $('#btnsendmoneystd').prop('disabled', false); + if (!err) { var confmess = 'You sent ' + _.escape(convertFromSatoshis(amount, COINUNIT)) + ' ' + _.escape(COINUNIT) + ' to ' + _.escape(address) + '';