PageSourceSearch

https://abordagemnoticias.com/componentes/js/busca.js

js abordagemnoticias.com collected 2026-10-02 17:13:37 UTC 1,241 bytes, 32 lines download raw bytes

1export function initSearch(root = document) {
2    root.querySelectorAll('[data-an-search]').forEach((form) => {
3        const input = form.querySelector('input[type="search"]');
4        const message = form.querySelector('[data-an-search-message]');
5
6        if (!input || !message) return;
7
8        form.addEventListener('submit', (event) => {
9            const term = input.value.trim();
10
11            if (term.length < 2) {
12                event.preventDefault();
13                message.textContent = 'Digite pelo menos dois caracteres.';
14                input.setAttribute('aria-invalid', 'true');
15                input.focus();
16                return;
17            }
18
19            input.value = term;
20            input.removeAttribute('aria-invalid');
21            message.textContent = '';
22            if (window.FormState && !window.FormState.start(form, { button: event.submitter || form.querySelector('button[type="submit"]'), text: 'Buscando...', timeout: 15000 })) event.preventDefault();
23        });
24
25        input.addEventListener('input', () => {
26            if (input.value.trim().length >= 2) {
27                input.removeAttribute('aria-invalid');
28                message.textContent = '';
29            }
30        });
31    });
32}

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.