/*============================================================================================ * Historico das alterações * -------------------------------------------------------------------------------------------- * Data : 23/11/2026 - Bruno B. S. Lima * Descrição : Tarefa 17603 - Reentrada automática por sessão SSO (tentaReentrar / DATA_SERVIDOR) e supressão da apresentação em top.isEmbedded. * -------------------------------------------------------------------------------------------- * Data : 13/05/2026 - Marcus Oliveira * Descrição : Tarefa - 16767 - [MELHORIAS] - Avisar no login que o Capslock está ativo quando for digitar a senha. * -------------------------------------------------------------------------------------------- * Data : 13/10/2025 - Lucas Cruz * Descrição : Tarefa 15077 - Card para feedback - Troca de layout do novo p/ antigo. * * =============================================================================================*/ //Task 12164 ShellCore top.isShellCore = true; top.isPlus = true; top.isPlusD = true; (function (global) { const ShellCore = { login: { emp: '', loja: '', usuario: '', senha: '', efUsuario: '', efSenha: '', pessoal: false, }, timeoutId: null, // Adicionando uma propriedade para armazenar o ID do timeout updateMensagens: function (mensagens) { fillMensagens(mensagens); }, showNotificacao: function (title, content, timeHide) { const notificacao = document.getElementById('notificacaoBox'); const messageTitle = document.getElementById('messageTitle'); const messageContent = document.getElementById('messageContent'); messageTitle.textContent = title; messageContent.textContent = content; notificacao.style.display = 'block'; notificacao.style.animation = 'fadeInDown 0.3s forwards'; if (this.timeoutId !== null) { clearTimeout(this.timeoutId); // Limpar o timeout anterior, se existir } if (timeHide !== undefined) { this.timeoutId = setTimeout(() => { ShellCore.hideNotificacao(); this.timeoutId = null; // Resetar o ID do timeout após esconder a mensagem }, timeHide); } }, hideNotificacao: function () { if (this.timeoutId !== null) { clearTimeout(this.timeoutId); // Limpar o timeout anterior, se existir } const messageBox = document.getElementById('notificacaoBox'); notificacaoBox.style.animation = 'fadeOutUp 0.3s forwards'; setTimeout(() => { notificacaoBox.style.display = 'none'; }, 500); }, showLauncher: function () { //Task 13829 - Componentes mobile if (document.getElementById("dialogBackground")){ document.getElementById("dialogBackground").style.display = "none"; } BuildShell(false); hideLoginPrincipal(); LoadDataInformativo(); const overlay = document.getElementById("overlayTrocaEmpresa"); if (overlay) overlay.classList.add("hidden"); //Task 14687 - Apresentacao layout //task 16951 - correcao App if (!top.isAppMobile) { if (!top.isEmbedded) { setTimeout("window.ShowApresentacao(true)", 2000); } //Achado ao vivo 24/08 (H5): popup de "novo layout" nao faz sentido dentro do app } // Remove o elemento do DOM após a animação de fade // setTimeout(() => { // overlay.remove(); // Remove o elemento completamente do DOM // }, 500); // Tempo para coincidir com o transition de 0.5s }, prepareReloadLauncher: function () { var splash = document.getElementById("splash"); splash.innerHTML = splashConteudo; splash.style.opacity = "1"; splash.style.zIndex = "999999"; splash.style.visibility = "visible"; var splashTitulo = document.getElementById("splash-titulo"); splashTitulo.innerText = "eFinance" splashTitulo.style.fontSize = "25px"; var splashSubTitulo = document.getElementById("splash-subtitulo"); splashSubTitulo.style.fontSize = "16px"; splashSubTitulo.style.setProperty("color", "#a53e32", "important"); splashSubTitulo.innerText = "Aguarde, alternando entre lojas..."; limpaShell(); //// Aplica o efeito de fade-in //setTimeout(() => { // // overlay.style.opacity = '1'; // var splash = document.getElementById("splash"); // splash.style.opacity = "0"; // splash.style.visibility = "hidden"; //}, 10); // Timeout para garantir a transição }, //reloadLauncher: function () { // BuildShell(); // hideLoginPrincipal(); // LoadDataInformativo(); //} }; global.ShellCore = ShellCore; })(top); function validateForm() { const empresa = document.getElementById('lgEmp'); const loja = document.getElementById('lgLoja'); const usuario = document.getElementById('lgUsuario'); const senha = document.getElementById('lgSenha'); const fields = [empresa, loja, usuario, senha]; ShellCore.hideNotificacao(); fields.forEach(field => { if (field.value.trim() === '' || field.value.length > 100) { field.style.borderColor = 'red'; } else { field.style.borderColor = '#ccc'; } }); } document.getElementById('lgEmp').addEventListener('keydown', OnKeyDown); document.getElementById('lgLoja').addEventListener('keydown', OnKeyDown); document.getElementById('lgUsuario').addEventListener('keydown', OnKeyDown); document.getElementById('lgSenha').addEventListener('keydown', OnKeyDown); document.getElementById('efUsuario').addEventListener('keydown', OnKeyDown); document.getElementById('efSenha').addEventListener('keydown', OnKeyDown); document.getElementById('lgEmp').addEventListener('input', OnKeyPress); document.getElementById('lgLoja').addEventListener('input', OnKeyPress); document.getElementById('lgUsuario').addEventListener('input', OnKeyPress); document.getElementById('lgSenha').addEventListener('input', OnKeyPress); document.getElementById('efUsuario').addEventListener('input', OnKeyPress); document.getElementById('efSenha').addEventListener('input', OnKeyPress); setupPasswordToggles(); /*Tarefa - 16610 – [MELHORIAS] Incluir botão - Visualizar Senha*/ setupCapsLockToggles(); //Tarefa - 16767 - [MELHORIAS] - Avisar no login que o Capslock está ativo quando for digitar a senha/--%> ShowEFCredenciais(false); function setupPasswordToggles() { document.querySelectorAll('[data-password-target]').forEach(function (toggle) { const input = document.getElementById(toggle.getAttribute('data-password-target')); const icon = toggle.querySelector('i'); if (!input) return; toggle.addEventListener('click', function () { const mostrarSenha = input.type === 'password'; input.type = mostrarSenha ? 'text' : 'password'; const label = mostrarSenha ? 'Ocultar senha' : 'Mostrar senha'; toggle.setAttribute('aria-label', label); toggle.setAttribute('title', label); if (icon) { icon.classList.toggle('fa-eye', !mostrarSenha); icon.classList.toggle('fa-eye-slash', mostrarSenha); } input.focus(); }); }); } var splashConteudo = ""; function hideSplash() { ShowEFCredenciais(false); setTimeout('document.getElementById("splash").style.opacity = "0";', 3000); setTimeout(function () { //deve ocultar o splash e remover a animacao pois ela fica executando mesmo depois de oculta var s = document.getElementById("splash"); s.style.visibility = "hidden"; splashConteudo = s.innerHTML; s.innerHTML = ""; }, 3000); //task 12164 shellcore setTimeout(function () { if (document.getElementById('lgEmp').value=="") { document.getElementById('lgEmp').focus(); document.getElementById('lgEmp').select(); } else if (document.getElementById('lgEmp').value == "") { document.getElementById('lgEmp').focus(); document.getElementById('lgEmp').select(); } else if (document.getElementById('lgUsuario').value == "") { document.getElementById('lgUsuario').focus(); document.getElementById('lgUsuario').select(); } } , 4000); //eFinanceMobileLegado H5 (24/08): dentro do app (top.isEmbedded), tenta reentrar pela //sessao ja autenticada (SSO servidor-a-servidor feito antes de a WebView abrir) em vez de //sempre mostrar o formulario de login - Default.aspx nunca reconhecia essa sessao sozinho, //so via este AJAX. Sessao invalida/expirada cai pro formulario normal. if (top.isEmbedded) { tentaReentrar(); } else { showLoginPrincipal(); } movideskChatWidgetChangeWindowState('minimized'); } function tentaReentrar() { //XMLHttpRequest puro, de proposito - nao usa Ext.data.Connection pra nao depender de //nenhum estado de inicializacao do ExtJS/RESPSHELL nesse momento do boot. Por isso o //timeout abaixo e explicito - o Ext.data.Connection que o Logar() normal usa ja vem com //30s por padrao (ext-all.js), um XHR cru nao tem timeout nenhum sozinho. var xhr = new XMLHttpRequest(); xhr.open('POST', 'diversos/acesso.aspx', true); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.timeout = 30000; xhr.onreadystatechange = function () { if (xhr.readyState !== 4) return; if (xhr.status === 200 && xhr.responseText && xhr.responseText.indexOf('<') === 0) { //Tarefa 17603: o Reentrar() do site anexa "DATA_SERVIDOR:aaaa/mm/dd" depois do XML //do menu (mesma marca do Logar). Sem gravar top.DATA_SERVIDOR aqui, os combos Ano/Mês //das telas nascem NaN (new Date(undefined)) e o grid manda ano=NaN -> erro de SQL. var partesReentrar = xhr.responseText.split('DATA_SERVIDOR:'); if (partesReentrar.length > 1) { top.DATA_SERVIDOR = partesReentrar[1].split('|')[0]; } //Achado do /code-review xhigh (03/09/2026): sem o try/catch, uma resposta que passa //no indexOf('<')===0 mas nao e o XML esperado (pagina de erro do IIS, por exemplo) //derrubava montaAbas() sem cair no showLoginPrincipal() - usuario preso sem tela //nenhuma. Mesmo risco de qualquer AJAX cru desta pagina; aqui e onde foi achado. try { montaAbas(partesReentrar[0]); } catch (e) { showLoginPrincipal(); } } else { showLoginPrincipal(); } }; xhr.onerror = function () { showLoginPrincipal(); }; //Achado do /code-review xhigh (03/09/2026): sem isto, uma conexao que trava (aceita o //socket e nunca responde) nunca chega em readyState 4 nem dispara onerror - o app ficava //preso na tela de boot pra sempre, pior que sempre mostrar o login (comportamento de antes //desta task). xhr.timeout so funciona setado ANTES do send(). xhr.ontimeout = function () { showLoginPrincipal(); }; xhr.send('Acao=reentrar'); } function showLoginPrincipal() { const loginDiv = document.getElementById('telaLoginPrincipal'); loginDiv.style.display = 'block'; // Garantir que o display seja configurado para block antes de aplicar a classe setTimeout(() => { loginDiv.classList.add('tela-login-principal-show'); }, 10); // Pequeño delay para garantir que o navegador processe a mudança de display } function hideLoginPrincipal() { document.getElementById("shellPrincipal").style.display = "block"; const loginDiv = document.getElementById('telaLoginPrincipal'); loginDiv.classList.remove('tela-login-principal-show'); // Após a transição, garantir que a div esteja oculta setTimeout(() => { loginDiv.style.display = 'none'; }, 500); // Tempo deve ser igual ao definido na transição de opacidade } function OnKeyPress() { validateForm(); } //Task 13801 correcao layout function OnKeyDown(event) { if ((event.target.id == "lgEmp") || (event.target.id == "lgLoja")) ShowEFCredenciais(false); if (event.key === 'Enter') { if (event.target.id == "lgEmp") { document.getElementById('lgLoja').focus(); document.getElementById('lgLoja').select(); } else if (event.target.id == "lgLoja") { document.getElementById('lgUsuario').focus(); document.getElementById('lgUsuario').select(); } else if (event.target.id == "lgUsuario") { document.getElementById('lgSenha').value=""; document.getElementById('lgSenha').focus(); document.getElementById('lgSenha').select(); } else if (event.target.id == "lgSenha") { efetuaLogin(); } else if (event.target.id == "efUsuario") { document.getElementById('efSenha').focus(); document.getElementById('efSenha').select(); } else if (event.target.id == "efSenha") { //aqui vai logar efetuaLogin(); } } } function efetuaLogin() { //Task 13801 correcao layout ShellCore.login.emp = document.getElementById('lgEmp').value; ShellCore.login.loja = document.getElementById('lgLoja').value; ShellCore.login.usuario = document.getElementById('lgUsuario').value; ShellCore.login.senha = document.getElementById('lgSenha').value; // ShellCore.login.senha = document.getElementById('lgSenha').value; ShellCore.login.efUsuario = document.getElementById('efUsuario').value; ShellCore.login.efSenha = document.getElementById('efSenha').value; if (ShellCore.login.emp == "") { document.getElementById('lgEmp').focus(); top.ShellCore.showNotificacao('Login', TEXTO_LOGIN_DIGITE_CODIGO_EMPRESA, 3000); return; } if (ShellCore.login.loja == "") { document.getElementById('lgLoja').focus(); top.ShellCore.showNotificacao('Login', TEXTO_LOGIN_DIGITE_CODIGO_LOJA, 3000); return; } if (ShellCore.login.usuario == "") { document.getElementById('lgUsuario').focus(); top.ShellCore.showNotificacao('Login', TEXTO_LOGIN_DIGITE_NOME_USUARIO, 3000); return; } if (ShellCore.login.senha == "") { document.getElementById('lgSenha').focus(); top.ShellCore.showNotificacao('Login', TEXTO_LOGIN_DIGITE_SENHA, 3000); return; } showProgressLogin(TEXTO_LOGIN_AGUARDE_EFETUADO_LOGON); // top.ShellCore.login.logando = true; if (top.ShellCore.login.pessoal) { valida(); } else { ef.acesso.loga(top.ShellCore.login.emp, top.ShellCore.login.loja, top.ShellCore.login.usuario, top.ShellCore.login.senha); } } function retornoLoginShell(res) { if (res != undefined) { ShellCore.showNotificacao("Efinance",res,4000); } if (res == "OK") { } hideProgressLogin(); } function retornoLoginTrocaShell(res) { BuildShell(true); LoadDataInformativo(); //deixar no final setTimeout('document.getElementById("splash").style.opacity = "0";', 3000); setTimeout(function () { var s = document.getElementById("splash"); s.style.visibility = "hidden"; s.innerHTML = ""; }, 3000); // alert("trocou"); } function showProgressLogin(text) { document.getElementById("botaoLogin").style.display="none" document.getElementById("progressLogin").style.display = "block"; document.getElementById("progressLoginText").textContent = text; } function hideProgressLogin() { document.getElementById("botaoLogin").style.display = "block" document.getElementById("progressLogin").style.display = "none"; } function ShowEFCredenciais(show) { top.ShellCore.login.pessoal = show; ShellCore.hideNotificacao(); document.getElementById("progressLogin").style.display = "none"; var div = document.getElementById('efCrendenciais'); if (show) { //Task 14727 ajustes novo layout div.style.height = '180px'; setTimeout(function () { document.getElementById('efUsuario').focus(); document.getElementById('efUsuario').select(); }, 400); } else div.style.height = '0px'; hideProgressLogin(); } //Message Box document.addEventListener('DOMContentLoaded', function () { const messageBox = document.getElementById('messageBox'); const closeBtn = document.getElementById('closeBtn'); closeBtn.addEventListener('click', function () { ShellCore.hideNotificacao(); }); window.addEventListener('click', function (event) { if (event.target === messageBox) { ShellCore.hideNotificacao(); } }); }); //fim message box //deve ficar no final hideSplash(); //task 12164 shellcore document.getElementById('lgEmp').value = top.ef.lerCookie('logon_UltimaEmpresa'); document.getElementById('lgLoja').value = top.ef.lerCookie('logon_UltimaLoja'); /////////////NOTIFICACAO DE MELHORIAS//////////////////////////// //Task 11750 - Notificacoes News var InformativoJsonData = []; var InformativoTotal = 0; var InformativoContainer = null; var InformativoImage = null; function AddNotificacaoNews() { if (InformativoTotal == 0) return; // Criar a tag