PageSourceSearch

https://buscacepinter.correios.com.br/core/templates/bunker/js/tabs.js

js correios.com.br collected 2026-09-24 07:27:44 UTC 2,341 bytes, 74 lines download raw bytes

1const registra = () => {
2  document.querySelectorAll('.tabs').forEach(tab => {
3    if (tab.tabsRegistrada) {
4      return;
5    }
6    tab.tabsRegistrada = true;
7    const menus = tab.querySelectorAll(':scope > nav > a');
8    const conteudos = tab.querySelectorAll(':scope > section > div');
9    if (menus.length != conteudos.length) {
10      throw 'tabs: número de tabs e conteúdos devem ser iguais';
11    }
12    const n = menus.length;
13    if (n == 0) {
14      return;
15    }
16    for (let i = 0; i < n; i++) {
17      menus[i].tabsConteudo = conteudos[i];
18      menus[i].tabsIndice = i;
19      menus[i].addEventListener('click', sel);
20    }
21    mostra(tab.id, 0);
22  });
23};
24const sel = ev => {
25  const menu = ev.currentTarget;
26  const nav = menu.parentNode;
27  const menuAnterior = nav.querySelector('.sel');
28  const tabs = nav.parentNode;
29  const desabilitado = menu.classList.contains('disabled');
30  if (desabilitado) {
31    // alerta.abre('Acesso bloqueado: ' + menu.text, 3, 'OK');
32    return;
33  }
34  if (menuAnterior) {
35    menuAnterior.classList.remove('sel');
36  }
37  menu.classList.add('sel');
38  const conteudoAnterior = nav.parentNode.querySelector(':scope > section > div.sel');
39  if (conteudoAnterior) {
40    conteudoAnterior.classList.remove('sel');
41  }
42  menu.tabsConteudo.classList.add('sel');
43  menu.scrollIntoView({ block: 'center' });
44  if (tabs.tabsOnShow) {
45    tabs.tabsOnShow(menu.tabsIndice, menu);
46  }
47};
48const mostra = (tabId, indice) => {
49  const menu = document.getElementById(tabId).querySelector(`:scope > nav > a:nth-child(${indice + 1})`);
50  if (!menu) {
51    throw 'tabs mostra: menu não encontrado';
52  }
53  setTimeout(() => {
54    menu.click();
55  }, 0);
56
57};
58const onMostra = (tabId, cb) => {
59  document.getElementById(tabId).tabsOnShow = cb;
60};
61const habilita = (tabId, indice) => {
62  const menu = document.getElementById(tabId).querySelector(`nav > a:nth-child(${indice + 1})`);
63  menu.classList.remove('disabled');
64};
65const desabilita = (tabId, indice) => {
66  const menu = document.getElementById(tabId).querySelector(`nav > a:nth-child(${indice + 1})`);
67  menu.classList.add('disabled');
68};
69const observer = new MutationObserver(() => {
70  registra();
71});
72observer.observe(document.querySelector('main'), { attributes: true, childList: true, subtree: true });
73registra();
74export { mostra, onMostra, habilita, desabilita };

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.