PageSourceSearch

https://capago.eu/assets/js/custom.js

js capago.eu collected 2026-10-04 20:35:40 UTC 2,220 bytes, 63 lines download raw bytes

1function initForm(reportMessage) {
2    const form = document.getElementById('reportForm');
3    const resultEl = document.querySelector('.form-result');
4    const statusEl = document.getElementById('status');
5
6    if (!form) return;
7
8    const setMsg = (text, cls = "") => {
9        if (resultEl) {
10            resultEl.textContent = text || '';
11            resultEl.className = 'form-result' + (cls ? ' ' + cls : '');
12        }
13        if (statusEl) statusEl.textContent = text || '';
14    };
15
16    form.addEventListener('submit', async (e) => {
17        e.preventDefault();
18
19        if (!form.checkValidity()) {
20            form.reportValidity();
21            return;
22        }
23
24        const submitBtn = form.querySelector('button[type="submit"]');
25        if (submitBtn) submitBtn.disabled = true;
26
27        setMsg(reportMessage.sending || 'Sending report…');
28
29        const payload = {
30            person_name: form.person_name.value || "",
31            person_mail: form.person_mail.value || "",
32            region: form.region?.value || "",
33            incident_date: form.incident_date?.value || "",
34            person_desc: form.person_desc?.value || "",
35            person_role: form.person_role?.value || "",
36            message: form.message?.value || "",
37            consent: !!form.consent?.checked,
38            hp: form.hp?.value || "",
39        };
40
41        try {
42            const res = await fetch('/.netlify/functions/anti-corruption', {
43                method: 'POST',
44                headers: { 'Content-Type': 'application/json' },
45                body: JSON.stringify(payload)
46            });
47
48            const text = await res.text();
49
50            if (res.ok && text.trim() === 'OK') {
51                setMsg(reportMessage.success || '✅ Report sent successfully!', 'success');
52                form.reset();
53            } else {
54                setMsg(reportMessage.failed || '❌ Failed to send the report. Please try again.', 'error');
55            }
56        } catch (err) {
57            console.error(err);
58            setMsg(reportMessage.networkError || '❌ Network error. Please try again.', 'error');
59        } finally {
60            if (submitBtn) submitBtn.disabled = false;
61        }
62    });
63}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.