feat: count down in realtime
This commit is contained in:
parent
ad798d0bbf
commit
3a3499cd8b
|
|
@ -216,7 +216,7 @@
|
||||||
<span class="w-1.5 h-1.5 rounded-full <%= inv.status === 'underpaid' ? 'bg-yellow-500' : 'bg-blue-500' %> animate-pulse"></span>
|
<span class="w-1.5 h-1.5 rounded-full <%= inv.status === 'underpaid' ? 'bg-yellow-500' : 'bg-blue-500' %> animate-pulse"></span>
|
||||||
<span class="text-xs <%= inv.status === 'underpaid' ? 'text-yellow-400' : 'text-gray-400' %>"><%= inv.status === 'underpaid' ? 'Underpaid, send the rest' : 'Waiting for payment' %></span>
|
<span class="text-xs <%= inv.status === 'underpaid' ? 'text-yellow-400' : 'text-gray-400' %>"><%= inv.status === 'underpaid' ? 'Underpaid, send the rest' : 'Waiting for payment' %></span>
|
||||||
</div>
|
</div>
|
||||||
<span class="text-xs text-gray-500 font-mono"><%= mins %>:<%= String(secs).padStart(2, '0') %></span>
|
<span id="timer" class="text-xs text-gray-500 font-mono" data-expires="<%= expiresAt.toISOString() %>"><%= mins %>:<%= String(secs).padStart(2, '0') %></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% } else if (inv.status === 'confirming') { %>
|
<% } else if (inv.status === 'confirming') { %>
|
||||||
|
|
@ -265,6 +265,17 @@
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
// Countdown timer
|
||||||
|
const timerEl = document.getElementById('timer');
|
||||||
|
if (timerEl) {
|
||||||
|
const expires = new Date(timerEl.dataset.expires).getTime();
|
||||||
|
setInterval(() => {
|
||||||
|
const left = Math.max(0, Math.floor((expires - Date.now()) / 1000));
|
||||||
|
timerEl.textContent = Math.floor(left / 60) + ':' + String(left % 60).padStart(2, '0');
|
||||||
|
if (left <= 0) location.reload();
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
// Copy address
|
// Copy address
|
||||||
function copyAddr() {
|
function copyAddr() {
|
||||||
const addr = document.getElementById('pay-address');
|
const addr = document.getElementById('pay-address');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue