File manager - Edit - /var/www/html/portal/public/pmar/js/functions.js
Back
/* COMPORTAMENTOS DE INICIALIZAÇÃO*/ document.addEventListener('DOMContentLoaded', function () { // Configurar busca CEP if (document.getElementById('cep') != null) { const cepInput = document.getElementById('cep'); if (cepInput) { cepInput.addEventListener('blur', function () { const cep = cepInput.value.replace(/\D/g, ''); if (cep.length === 8) { fetch(`https://opencep.com/v1/${cep}.json`) .then(response => response.json()) .then(data => { if (data.erro) { Utils.showAlert('CEP não encontrado.', 'warning'); return; } document.getElementById('logradouro').value = data.logradouro || ''; document.getElementById('bairro').value = data.bairro || ''; document.getElementById('cidade').value = data.localidade || ''; document.getElementById('uf').value = data.uf || ''; }) .catch(() => { Utils.showAlert('Erro ao buscar o endereço. Tente novamente.', 'error'); }); } }); } } // Configurar menu lateral if (document.getElementById('secretarias') !== null) { document.getElementById('secretarias').onclick = function () { document.getElementById('menu').style.display = 'none'; document.getElementById('subSecretarias').style.display = 'block'; }; document.getElementById('voltarSecretarias').onclick = function () { document.getElementById('subSecretarias').style.display = 'none'; document.getElementById('menu').style.display = 'block'; }; document.getElementById('autarquias').onclick = function () { document.getElementById('menu').style.display = 'none'; document.getElementById('subAutarquias').style.display = 'block'; }; document.getElementById('voltarAutarquias').onclick = function () { document.getElementById('subAutarquias').style.display = 'none'; document.getElementById('menu').style.display = 'block'; }; } // Configurar interessados dinâmicos const interessadosWrapper = document.getElementById('interessados-wrapper'); if (interessadosWrapper) { const addBtn = document.getElementById('add-interessado'); if (addBtn) { addBtn.addEventListener('click', () => { const field = document.createElement('div'); field.classList.add('input-group', 'mb-2'); field.innerHTML = ` <input type="text" class="form-control" name="interessados[]" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9]/g, '')" /> <span class="input-group-text text-danger remove-interessado" style="cursor: pointer;"> <i class="fa-solid fa-square-minus"></i> </span> `; interessadosWrapper.appendChild(field); }); } interessadosWrapper.addEventListener('click', function (e) { if (e.target.closest('.remove-interessado')) { const allFields = interessadosWrapper.querySelectorAll('.input-group'); if (allFields.length > 1) { e.target.closest('.input-group').remove(); } else { Utils.showAlert("Pelo menos um interessado é obrigatório.", 'warning'); } } }); } // Configurar portal da transparência const searchInput = document.getElementById('pesquisaInput'); if (searchInput) { searchInput.addEventListener('input', function () { const searchTerm = this.value.toLowerCase().trim(); const mainInfo = document.getElementById('mainInfo'); mainInfo.style.display = searchTerm === '' ? 'block' : 'none'; document.querySelectorAll('.sectionTitle').forEach(section => { section.style.display = searchTerm === '' ? 'block' : 'none'; }); document.querySelectorAll('.card-item').forEach(card => { const cardText = card.textContent.toLowerCase(); card.style.display = searchTerm === '' || cardText.includes(searchTerm) ? 'block' : 'none'; }); document.querySelectorAll('.col-12.pt-5').forEach(section => { const nextRow = section.nextElementSibling; if (nextRow && nextRow.classList.contains('row')) { const visibleCards = nextRow.querySelectorAll('.card-item[style="display: block"]'); section.style.display = visibleCards.length > 0 || searchTerm === '' ? 'block' : 'none'; nextRow.style.display = visibleCards.length > 0 || searchTerm === '' ? 'flex' : 'none'; } }); }); } // Inicializar funções do boletim new BoletimFunctions(); });
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings