From bcb27519bf2a1baad0f0529a025ec7509e701828 Mon Sep 17 00:00:00 2001 From: Arc <33088785+arcbtc@users.noreply.github.com> Date: Wed, 15 Jan 2020 15:18:14 +0000 Subject: [PATCH] Update app.js --- lnbits/static/app.js | 94 +++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 37 deletions(-) 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 = - "

" + - "
" + - "


' + 'Use camera to scan an invoice'+ + "" 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 = + "" + + "" + } else { - document.getElementById('sendfunds').innerHTML = - "
" + + document.getElementById('sendfunds2').innerHTML = + "
" + + "
' + '

' } } 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 = + "


" + "