PageSourceSearch

https://www.correios.com.br/++theme++tema-do-portal-correios/static/js/cod/carol.js

js correios.com.br collected 2026-09-24 07:27:58 UTC 3,785 bytes, 124 lines download raw bytes

1define(['bib/chatweb'], function (ChatWeb){
2
3    function chamarChatRostoCarol() {
4        window.renderBotWidget(
5            '68b9fe1c7bb09a0739e36621',
6            {
7                botOrigem: "WebSite",
8                layout: {
9                    // 'bot-name': 'Teste título',
10                    // 'bot-bg-color': '278222',
11                    // 'bot-text-color': 'fff',
12                }
13            }
14        );
15	}
16
17	function chamarChatCarolCorpoInteiro() {
18		window.renderBotWidget(
19			'68b9fe1c7bb09a0739e36621',
20			{
21			botOrigem: "WebSite",
22			layout: {
23				// 'bot-name': 'Teste título',
24				// 'bot-bg-color': '278222',
25				// 'bot-text-color': 'ffffff',
26				// 'user-bg-color': '6a5837',
27				// 'user-text-color': 'fff0f0'
28			}
29			},
30			false,
31			false
32		);
33     
34		//########################################
35		//ABRE O CHAT DIRETAMENTE SEM O ICON
36		//########################################
37		const observer = new MutationObserver(() => {
38		const openButton = document.querySelector('img.webchat_closed');
39			if (openButton) {
40				openButton.click();
41				observer.disconnect(); // para de observar depois do clique
42			}
43      	});
44 
45      	observer.observe(document.body, { childList: true, subtree: true });
46     
47      	//########################################
48    }
49    
50    const mostraElemento = (elemento) => {
51		elemento.classList.remove("oculta-chat-correios");
52	}
53
54    const fechaCarolRosto = () => {
55		ocultaElmento(document.getElementById("carol-inicio"));
56        document.removeEventListener('click', cliqueForaDaCarol, false);
57        chamarChatRostoCarol();
58	}
59
60	const fechaCarolCorpo = () => {
61		ocultaElmento(document.getElementById("carol-inicio"));
62        document.removeEventListener('click', cliqueForaDaCarol, false);
63        chamarChatCarolCorpoInteiro();
64	}
65
66    const ocultaElmento = (elemento) => {
67		elemento.classList.add("oculta-chat-correios");
68	}
69
70    const cliqueForaDaCarol = (event) => {
71		if (document.getElementsByClassName("section-homepage").length){
72			let carolCorpo = document.querySelector("#carol-corpo-img");
73			let carolbalao = document.querySelector(".carol-balao");
74			let carolIcone = document.querySelector("#carol-icone");
75			if ((!carolCorpo.contains(event.target)) && (!carolbalao.contains(event.target))){
76				document.removeEventListener('click', cliqueForaDaCarol, false);
77				fechaCarolRosto();
78			}
79		}
80	}
81
82	return {
83	 	prepararChat: () => {
84			let carolbalao = document.querySelector(".carol-balao");
85			let carolCorpo = document.querySelector("#carol-corpo-img");
86			let carolFecha = document.querySelector("#carol-fecha");
87			let carolIcone = document.querySelector("#carol-icone");
88
89			//Tratamento para abrir a Carol de corpo inteiro apenas na home
90			if (document.getElementsByClassName("section-homepage").length){
91				mostraElemento(document.getElementById("carol-inicio"));
92				
93				//Pega o evento de click fora do corpo e do balão da Carol para minimizar 
94				// a imagem chama a função cliqueForaDaCarol
95				if (!carolCorpo.classList.contains("oculta-chat-correios") && document.querySelector("#chatbot-correios").classList.contains("oculta-chat-correios")){
96					document.addEventListener('click', cliqueForaDaCarol, false);
97				}
98	
99				// Mapeia o clique no Corpo da Carol
100				carolCorpo.addEventListener('click', () => {
101                    fechaCarolCorpo();
102				});
103
104				// Mapeia o clique no Balão da Carol
105				carolbalao.addEventListener('click', () => {
106                    fechaCarolCorpo();
107				});
108
109				// Mapeia o clique no "X"
110				carolFecha.addEventListener('click', () => {
111					fechaCarolRosto();
112				});
113
114			} else {
115                // Abre a Carol em todos as páginas, exceto a home do Portal
116                chamarChatRostoCarol();
117			}
118
119        }
120
121        
122	}
123});
124

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.