przebudowa systemu
This commit is contained in:
38
static/js/zbiorka.js
Normal file
38
static/js/zbiorka.js
Normal file
@@ -0,0 +1,38 @@
|
||||
(function () {
|
||||
const ibanEl = document.getElementById('ibanDisplay');
|
||||
if (ibanEl) {
|
||||
const digits = (ibanEl.textContent || '').replace(/\s+/g, '').replace(/^PL/i, '').replace(/\D/g, '').slice(0, 26);
|
||||
if (digits) ibanEl.textContent = 'PL ' + digits.replace(/(.{4})/g, '$1 ').trim();
|
||||
}
|
||||
const blikEl = document.getElementById('blikDisplay');
|
||||
if (blikEl) {
|
||||
const d = (blikEl.textContent || '').replace(/\D/g, '').slice(0, 9);
|
||||
const parts = [d.slice(0, 3), d.slice(3, 6), d.slice(6, 9)].filter(Boolean).join(' ');
|
||||
if (parts) blikEl.textContent = parts;
|
||||
}
|
||||
|
||||
document.querySelectorAll('[data-copy-target]').forEach(btn => {
|
||||
btn.addEventListener('click', async () => {
|
||||
const sel = btn.getAttribute('data-copy-target');
|
||||
const el = sel ? document.querySelector(sel) : null;
|
||||
if (!el) return;
|
||||
const raw = el.textContent.replace(/\u00A0/g, ' ').trim();
|
||||
try {
|
||||
await navigator.clipboard.writeText(raw);
|
||||
const original = btn.textContent;
|
||||
btn.textContent = 'Skopiowano!';
|
||||
btn.disabled = true;
|
||||
setTimeout(() => { btn.textContent = original; btn.disabled = false; }, 1200);
|
||||
} catch {
|
||||
// fallback
|
||||
const r = document.createRange();
|
||||
r.selectNodeContents(el);
|
||||
const selObj = window.getSelection();
|
||||
selObj.removeAllRanges();
|
||||
selObj.addRange(r);
|
||||
try { document.execCommand('copy'); } catch { }
|
||||
selObj.removeAllRanges();
|
||||
}
|
||||
});
|
||||
});
|
||||
})();
|
Reference in New Issue
Block a user