diff --git a/lnbits/static/app.js b/lnbits/static/app.js
index 7fa2d28cd..540852dff 100644
--- a/lnbits/static/app.js
+++ b/lnbits/static/app.js
@@ -48,17 +48,23 @@ function getAjax(url, thekey, success) {
}
xhr.setRequestHeader('Grpc-Metadata-macaroon', thekey)
xhr.setRequestHeader('Content-Type', 'application/json')
+
xhr.send()
return xhr
}
function sendfundsinput() {
document.getElementById('sendfunds').innerHTML =
- "
" +
- "
"
document.getElementById('receive').innerHTML = ''
}
@@ -68,14 +74,15 @@ function sendfundspaste() {
outmemo = theinvoice.data.tags[1].value
outamount = Number(theinvoice.human_readable_part.amount) / 1000
if (outamount > Number(wallet.balance)) {
- document.getElementById('sendfunds').innerHTML =
- "
" +
- "
Not enough funds!
" +
- "" +
- ''
+ document.getElementById('sendfunds2').innerHTML =
+ "
"+
+ "
Not enough funds!
" +
+ ""
+
} else {
- document.getElementById('sendfunds').innerHTML =
- "
" +
+ document.getElementById('sendfunds2').innerHTML =
+ "
"+
'
Invoice detailsAmount: ' +
outamount +
'
Memo: ' +
@@ -83,22 +90,27 @@ function sendfundspaste() {
'
' +
"
" +
+ "'>
" +
+ "
'
+ '
'
}
}
function receive() {
document.getElementById('receive').innerHTML =
- "
'
+ ""
+
document.getElementById('sendfunds').innerHTML = ''
}
@@ -113,13 +125,13 @@ function received() {
theinvoice = JSON.parse(data).pay_req
thehash = JSON.parse(data).payment_hash
document.getElementById('QRCODE').innerHTML =
- "'
+ ''
new QRCode(document.getElementById('qrcode'), {
text: theinvoice,
@@ -129,14 +141,17 @@ function received() {
colorLight: '#ffffff',
correctLevel: QRCode.CorrectLevel.M
})
- setInterval(function(){
+
+
+ setInterval(function(){
getAjax('/v1/invoice/' + thehash, wallet.inkey, function(datab) {
console.log(JSON.parse(datab).PAID)
if (JSON.parse(datab).PAID == 'TRUE') {
window.location.href = 'wallet?wal=' + wallet.id + '&usr=' + user
}
- })}, 3000);
- })
+ })}, 3000);
+
+
}
)
}
@@ -146,29 +161,34 @@ function cancelsend() {
}
function sendfunds(invoice) {
- var url = '/v1/channels/transactions'
postAjax(
- url,
+ '/v1/channels/transactions',
JSON.stringify({payment_request: invoice}),
wallet.adminkey,
+
function(data) {
- setInterval(function(){
thehash = JSON.parse(data).payment_hash
- console.log(JSON.parse(data))
- if (JSON.parse(data).PAID == 'TRUE') {
- window.location.href = 'wallet?wal=' + wallet.id + '&usr=' + user
- }
- })}, 3000);
+
+ setInterval(function(){
+ getAjax('/v1/payment/' + thehash, wallet.adminkey, function(datab) {
+ console.log(JSON.parse(datab).PAID)
+ if (JSON.parse(datab).PAID == 'TRUE') {
+ window.location.href = 'wallet?wal=' + wallet.id + '&usr=' + user
+ }
+ })}, 3000);
+
}
)
+
}
function scanQRsend() {
- document.getElementById('sendfunds').innerHTML =
- "
" +
- "
🎥 Unable to access video stream (please make sure you have a webcam enabled)
" +
+ document.getElementById('sendfunds2').innerHTML =
+ "
"+
+ "
🎥 Unable to access video stream (please make sure you have a webcam enabled)
" +
"
"
+ "