PageSourceSearch

https://leiloesjudiciaisbahia.com.br/v3/js/vlance/leilao/container.js

js leiloesjudiciaisbahia.com.br collected 2026-09-27 05:29:10 UTC 4,819 bytes, 153 lines download raw bytes

1window.addEventListener('load', function () {
2    const path = window.location.pathname.toLowerCase();
3
4    if (isLoginRoute(path)) {
5        return;
6    }
7
8    const ultimaPagina = sessionStorage.getItem('pagina');
9    const urlParams = new URLSearchParams(window.location.search);
10    const paginaAtual = urlParams.get('pg') || 1;
11
12    if (ultimaPagina && !urlParams.has('pg') && !isLeilaoRoute(path)) {
13        window.location.href = ultimaPagina;
14    }
15
16    if (isLeilaoRoute(path)) {
17        sessionStorage.setItem('pagina', `?pg=${paginaAtual}`);
18    }
19});
20
21async function fetchLeiloes(tipo = 'proximos') {
22    const rota = window.location.origin;
23    const urlParams = new URLSearchParams(window.location.search);
24    const pagina = urlParams.get('pg') || 1;
25    const path = window.location.pathname.toLowerCase();
26
27    if (!(path === '/' || path === '/index' || path.includes('leilao/index'))) {
28        return {
29            success: false,
30            items: [],
31            currentPage: 1,
32            totalPages: 1,
33            error: 'Rota inválida'
34        };
35    }
36
37    let url = `${rota}/core/api/get-leiloes`;
38    if (tipo === 'encerrados') {
39        url = `${rota}/core/api/get-leiloes-encerrados`;
40    }
41
42    try {
43        $('#carregamento').removeClass('none');
44
45        const response = await fetch(`${url}?pg=${pagina}&itens_pagina=40`);
46        if (!response.ok) {
47            throw new Error('Erro ao obter os leilões');
48        }
49
50        const leiloes = await response.json();
51
52        if (!leiloes || !Array.isArray(leiloes.items)) {
53            throw new Error('Resposta inválida do servidor');
54        }
55
56        if (leiloes.items.length > 0) {
57            $('#leilao-lista').removeClass('none');
58            $('#leilao-lista span.nenhum-item').remove();
59            $('#carregamento').addClass('none');
60            $('.center_lotes').addClass('none');
61
62            if (leiloes.currentPage !== Number(pagina)) {
63                sessionStorage.setItem('pagina', `?pg=${leiloes.currentPage}`);
64            }
65
66            return leiloes;
67        } else {
68            $('#leilao-lista').addClass('none');
69            $('#carregamento').addClass('none');
70            $('#leilao-lista').append('<span class="nenhum-item">Nenhum item encontrado</span>');
71
72            return {
73                success: false,
74                items: [],
75                currentPage: 1,
76                totalPages: 1,
77                error: 'Nenhum leilão encontrado'
78            };
79        }
80    } catch (error) {
81        console.error(error);
82        $('#carregamento').addClass('none');
83        return {
84            success: false,
85            items: [],
86            currentPage: 1,
87            totalPages: 1,
88            error: 'Erro ao obter os leilões'
89        };
90    }
91}
92
93function destacarLeilaoAposCarregamento(tipo) {
94    if (tipo === 'encerrados') return;
95    const focoLeilaoId = sessionStorage.getItem('focoLeilaoId');
96    if (focoLeilaoId) {
97        setTimeout(() => {
98            const container = document.querySelector('#leilao-lista');
99            const elemento = container?.querySelector(`#leilao_${focoLeilaoId}`);
100            if (elemento) {
101                elemento.scrollIntoView({behavior: 'smooth', block: 'center'});
102                elemento.classList.add('destacar-leilao');
103                setTimeout(() => {
104                    elemento.classList.remove('destacar-leilao');
105                }, 4500);
106                sessionStorage.removeItem('focoLeilaoId');
107            }
108        }, 1500);
109    }
110}
111
112function isLeilaoRoute(path) {
113    const validRoutes = ['/', '/index', '/leilao/index'];
114    return validRoutes.includes(path) || path.startsWith('/leilao/index/');
115}
116
117function isLoginRoute(path) {
118    return path.includes('index/login');
119}
120
121document.addEventListener('click', function (e) {
122    const leilao = e.target.closest('[id^="leilao_"]');
123    if (leilao) {
124        const leilaoId = leilao.id.replace('leilao_', '');
125        sessionStorage.setItem('focoLeilaoId', leilaoId);
126    }
127});
128
129document.querySelectorAll('a[href^="?pg="]').forEach(link => {
130    link.addEventListener('click', function (event) {
131        event.preventDefault();
132        sessionStorage.setItem('pagina', this.getAttribute('href'));
133        window.location.href = this.getAttribute('href');
134    });
135});
136
137(function () {
138    const style = document.createElement('style');
139    style.innerHTML = `
140    @keyframes detacaLeilao {
141        0% { background-color: #ffe78155; }
142        25% { background-color: initial; }
143        50% { background-color: #ffe78155; }
144        75% { background-color: initial; }
145        100% { background-color: #ffe78155; }
146    }
147
148    .destacar-leilao {
149        animation: detacaLeilao 3s ease-in-out;
150        border-radius: 15px;
151    }`;
152    document.head.appendChild(style);
153})();

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.