reset invoice fields on submit, show error outside invoice, show invoice only on success
This commit is contained in:
18
index.html
18
index.html
@@ -279,8 +279,9 @@ footer a{color:var(--accent);text-decoration:none}
|
||||
<button class="btn" id="submit">Add server</button>
|
||||
</div>
|
||||
|
||||
<div class="invoice" id="invoice">
|
||||
<div class="ok-line" id="iv-status">✓ Server added. Pay the invoice to complete.</div>
|
||||
|
||||
<div class="invoice" id="invoice">
|
||||
<div class="row"><span>Minimum amount</span><span id="iv-min">—</span></div>
|
||||
<div class="row"><span>Chain</span><span id="iv-chain">—</span></div>
|
||||
<div class="row"><span>Address</span><span id="iv-addr">—</span></div>
|
||||
@@ -458,6 +459,16 @@ document.getElementById('submit').addEventListener('click', async () => {
|
||||
url = 'https://' + url;
|
||||
urlInput.value = url;
|
||||
}
|
||||
const inv = document.getElementById('invoice');
|
||||
inv.classList.remove('show');
|
||||
document.getElementById('iv-status').className = '';
|
||||
document.getElementById('iv-status').textContent = '';
|
||||
document.getElementById('iv-min').textContent = '—';
|
||||
document.getElementById('iv-chain').textContent = '—';
|
||||
document.getElementById('iv-addr').textContent = '—';
|
||||
document.getElementById('iv-balance').textContent = '—';
|
||||
document.getElementById('iv-status2').textContent = '—';
|
||||
document.getElementById('qrcode').innerHTML = '';
|
||||
const chain = getChain();
|
||||
try {
|
||||
const response = await fetch('/data', {
|
||||
@@ -466,12 +477,9 @@ document.getElementById('submit').addEventListener('click', async () => {
|
||||
body: JSON.stringify({ url, chain })
|
||||
});
|
||||
const result = await response.json();
|
||||
const inv = document.getElementById('invoice');
|
||||
if (!response.ok) {
|
||||
document.getElementById('iv-status').className = 'err-line';
|
||||
document.getElementById('iv-status').textContent = 'Error: ' + (result.message || result.error || JSON.stringify(result));
|
||||
inv.classList.add('show');
|
||||
document.getElementById('qrcode').innerHTML = '';
|
||||
return;
|
||||
}
|
||||
document.getElementById('iv-status').className = 'ok-line';
|
||||
@@ -490,8 +498,6 @@ document.getElementById('submit').addEventListener('click', async () => {
|
||||
} catch (err) {
|
||||
document.getElementById('iv-status').className = 'err-line';
|
||||
document.getElementById('iv-status').textContent = 'Network error. Please try again.';
|
||||
document.getElementById('invoice').classList.add('show');
|
||||
document.getElementById('qrcode').innerHTML = '';
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user