zmiany w logice i endpoitach
This commit is contained in:
		@@ -1,37 +0,0 @@
 | 
			
		||||
(function () {
 | 
			
		||||
    const opis = document.getElementById('opis');
 | 
			
		||||
    const opisCount = document.getElementById('opisCount');
 | 
			
		||||
    if (opis && opisCount) {
 | 
			
		||||
        const updateCount = () => opisCount.textContent = opis.value.length.toString();
 | 
			
		||||
        opis.addEventListener('input', updateCount);
 | 
			
		||||
        updateCount();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const iban = document.getElementById('numer_konta');
 | 
			
		||||
    if (iban) {
 | 
			
		||||
        iban.addEventListener('input', () => {
 | 
			
		||||
            const digits = iban.value.replace(/\D/g, '').slice(0, 26);
 | 
			
		||||
            const chunked = digits.replace(/(.{4})/g, '$1 ').trim();
 | 
			
		||||
            iban.value = chunked;
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const tel = document.getElementById('numer_telefonu_blik');
 | 
			
		||||
    if (tel) {
 | 
			
		||||
        tel.addEventListener('input', () => {
 | 
			
		||||
            const digits = tel.value.replace(/\D/g, '').slice(0, 9);
 | 
			
		||||
            const parts = [];
 | 
			
		||||
            if (digits.length > 0) parts.push(digits.substring(0, 3));
 | 
			
		||||
            if (digits.length > 3) parts.push(digits.substring(3, 6));
 | 
			
		||||
            if (digits.length > 6) parts.push(digits.substring(6, 9));
 | 
			
		||||
            tel.value = parts.join(' ');
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const cel = document.getElementById('cel');
 | 
			
		||||
    if (cel) {
 | 
			
		||||
        cel.addEventListener('change', () => {
 | 
			
		||||
            if (cel.value && Number(cel.value) < 0.01) cel.value = '0.01';
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
})();
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
    const opis = document.getElementById('opis');
 | 
			
		||||
    const opisCount = document.getElementById('opisCount');
 | 
			
		||||
    if (opis && opisCount) {
 | 
			
		||||
        const updateCount = () => opisCount.textContent = opis.value.length.toString();
 | 
			
		||||
        const updateCount = () => (opisCount.textContent = String(opis.value.length));
 | 
			
		||||
        opis.addEventListener('input', updateCount);
 | 
			
		||||
        updateCount();
 | 
			
		||||
    }
 | 
			
		||||
@@ -12,7 +12,7 @@
 | 
			
		||||
    const iban = document.getElementById('numer_konta');
 | 
			
		||||
    if (iban) {
 | 
			
		||||
        iban.addEventListener('input', () => {
 | 
			
		||||
            const digits = iban.value.replace(/\D/g, '').slice(0, 26); // 26 cyfr po "PL"
 | 
			
		||||
            const digits = iban.value.replace(/\D/g, '').slice(0, 26); // 26 cyfr po PL
 | 
			
		||||
            const chunked = digits.replace(/(.{4})/g, '$1 ').trim();
 | 
			
		||||
            iban.value = chunked;
 | 
			
		||||
        });
 | 
			
		||||
@@ -31,22 +31,25 @@
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // „Ustaw globalne” z data-atrybutów (bez wstrzykiwania wartości w JS)
 | 
			
		||||
    // „Ustaw globalne” – jest tylko w trybie edycji; odpalamy warunkowo
 | 
			
		||||
    const setGlobalBtn = document.getElementById('ustaw-globalne');
 | 
			
		||||
    if (setGlobalBtn && iban && tel) {
 | 
			
		||||
        setGlobalBtn.addEventListener('click', () => {
 | 
			
		||||
            const gIban = setGlobalBtn.dataset.iban || '';
 | 
			
		||||
            const gBlik = setGlobalBtn.dataset.blik || '';
 | 
			
		||||
 | 
			
		||||
            if (gIban) {
 | 
			
		||||
                iban.value = gIban.replace(/\D/g, '').replace(/(.{4})/g, '$1 ').trim();
 | 
			
		||||
                iban.dispatchEvent(new Event('input'));
 | 
			
		||||
            }
 | 
			
		||||
            if (gBlik) {
 | 
			
		||||
                const d = gBlik.replace(/\D/g, '').slice(0, 9);
 | 
			
		||||
                const p = [d.slice(0, 3), d.slice(3, 6), d.slice(6, 9)].filter(Boolean).join(' ');
 | 
			
		||||
                const p = [d.slice(0, 3), d.slice(3, 6), d.slice(6, 9)]
 | 
			
		||||
                    .filter(Boolean)
 | 
			
		||||
                    .join(' ');
 | 
			
		||||
                tel.value = p;
 | 
			
		||||
                tel.dispatchEvent(new Event('input'));
 | 
			
		||||
            }
 | 
			
		||||
            iban.dispatchEvent(new Event('input'));
 | 
			
		||||
            tel.dispatchEvent(new Event('input'));
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -57,4 +60,4 @@
 | 
			
		||||
            if (cel.value && Number(cel.value) < 0.01) cel.value = '0.01';
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
})();
 | 
			
		||||
})();
 | 
			
		||||
		Reference in New Issue
	
	Block a user