PageSourceSearch

https://www.poder360.com.br/wp-content/themes/poder/assets/js/widg…ia-editoria-sem-video.js?ver=1.0.1-26082026

js poder360.com.br collected 2026-10-02 02:14:30 UTC 3,190 bytes, 80 lines download raw bytes

1(function () {
2    function uniq(arr) {
3        return Array.from(new Set(arr.filter(Boolean)));
4    }
5
6    document.addEventListener("click", async function (e) {
7        const btn = e.target.closest(".poder-load-more-cat-sem-video");
8        if (!btn) return;
9
10        if (btn.disabled) return;
11
12        const ajaxUrl = btn.getAttribute("data-ajax");
13        const action = btn.getAttribute("data-action");
14        const perPage = btn.getAttribute("data-per-page") || "8";
15        const notIn = btn.getAttribute("data-not-in") || "";
16        const catSlugs = btn.getAttribute("data-cat-slugs") || "";
17        const nonce = btn.getAttribute("data-nonce") || "";
18        const ocultarCategoria = btn.getAttribute("data-ocultar-categoria") || "0";
19        const alterarCategoria = btn.getAttribute("data-alterar-categoria") || "0";
20
21        const containerSel = btn.getAttribute("data-target") || "#poder-cat-sem-video-list";
22        const container = document.querySelector(containerSel);
23        if (!ajaxUrl || !action || !container) return;
24
25        const label = btn.querySelector(".poder-loadmore__label");
26        const spinner = btn.querySelector(".poder-loadmore__spinner");
27
28        btn.disabled = true;
29        btn.setAttribute("aria-busy", "true");
30        if (label) label.style.display = "none";
31        if (spinner) spinner.style.display = "inline-flex";
32
33        try {
34            const body = new URLSearchParams();
35            body.set("action", action);
36            body.set("per_page", perPage);
37            body.set("not_in", notIn);
38            body.set("cat_slugs", catSlugs);
39            body.set("nonce", nonce);
40            body.set("ocultar_categoria", ocultarCategoria);
41            body.set("alterar_categoria", alterarCategoria);
42
43            const res = await fetch(ajaxUrl, {
44                method: "POST",
45                headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" },
46                body: body.toString(),
47                credentials: "same-origin",
48            });
49
50            const json = await res.json();
51
52            if (!json || !json.success || !json.data) {
53                throw new Error("Resposta inválida do AJAX");
54            }
55
56            if (json.data.html) {
57                container.insertAdjacentHTML("beforeend", json.data.html);
58            }
59
60            // Atualiza not_in acumulado
61            const currentNotIn = notIn.split(",").map((x) => x.trim());
62            const returned = Array.isArray(json.data.ids) ? json.data.ids.map(String) : [];
63            const merged = uniq(currentNotIn.concat(returned));
64            btn.setAttribute("data-not-in", merged.join(","));
65
66            if (!json.data.has_more) {
67                const pagination = btn.closest(".pagination");
68                if (pagination) pagination.remove();
69            }
70        } catch (err) {
71            console.error(err);
72            // se quiser, pode re-habilitar para tentar de novo
73        } finally {
74            btn.disabled = false;
75            btn.removeAttribute("aria-busy");
76            if (label) label.style.display = "";
77            if (spinner) spinner.style.display = "none";
78        }
79    });
80})();

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.