mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-12 19:02:01 +01:00
scan card error
This commit is contained in:
parent
563ef3cab4
commit
19c25412e4
1 changed files with 91 additions and 66 deletions
|
@ -20,6 +20,10 @@
|
|||
</header>
|
||||
|
||||
<div id="body" class="my-4">
|
||||
<div id="error" class="d-flex align-items-center justify-content-center d-none">
|
||||
|
||||
<p class="text-danger"></p>
|
||||
</div>
|
||||
<div id="actions" class="d-flex align-items-center justify-content-center d-none">
|
||||
<div class="d-flex gap-3 mt-3 mt-sm-0">
|
||||
<a id="start-scan-btn" class="btn btn-primary" href="#">Ask permission...</a>
|
||||
|
@ -48,10 +52,17 @@
|
|||
var permissionGranted = false;
|
||||
var ndef = null;
|
||||
var abortController = null;
|
||||
|
||||
function handleError(e){
|
||||
document.querySelector("#error p").innerHTML = e.message;
|
||||
document.getElementById("error").classList.remove("d-none");
|
||||
}
|
||||
|
||||
function delay(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
async function showBalance(lnurlw) {
|
||||
try {
|
||||
setState("Submitting");
|
||||
await delay(1000);
|
||||
var url = window.location.href.replace("#", "");
|
||||
|
@ -86,9 +97,13 @@
|
|||
};
|
||||
xhttp.open('GET', url, true);
|
||||
xhttp.send(new FormData());
|
||||
}catch (e) {
|
||||
handleError(e);
|
||||
}
|
||||
}
|
||||
|
||||
async function startScan() {
|
||||
try {
|
||||
if (!('NDEFReader' in window)) {
|
||||
return;
|
||||
}
|
||||
|
@ -105,9 +120,15 @@
|
|||
await showBalance(decoded);
|
||||
};
|
||||
}
|
||||
catch (e) {
|
||||
handleError(e);
|
||||
}
|
||||
}
|
||||
|
||||
function setState(state)
|
||||
{
|
||||
document.querySelector("#error p").innerHTML = "";
|
||||
document.getElementById("error").classList.add("d-none");
|
||||
document.getElementById("actions").classList.add("d-none");
|
||||
document.getElementById("qr").classList.add("d-none");
|
||||
document.getElementById("scanning-btn").classList.add("d-none");
|
||||
|
@ -139,6 +160,8 @@
|
|||
}
|
||||
}
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
try {
|
||||
|
||||
var nfcSupported = 'NDEFReader' in window;
|
||||
if (!nfcSupported) {
|
||||
setState("NFCNotSupported");
|
||||
|
@ -153,9 +176,11 @@
|
|||
}
|
||||
}
|
||||
delegate('click', "#start-scan-btn", startScan);
|
||||
}
|
||||
catch (e) {
|
||||
handleError(e);
|
||||
}
|
||||
//showBalance("lnurl://ewfw?p=test&c=test");
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue