Download de Certificado
Digite seu nome (ou primeiro nome) para buscar.
Caso não localize o seu certificado, envie e-mail para robsonsantos@unipacuberlandia.com.br
Digite seu nome:
Por favor, digite seu nome.
Buscar Certificado
// ========================================================================
// CONFIGURAÇÃO PRINCIPAL
// ========================================================================
const WEB_APP_URL = 'https://script.google.com/macros/s/AKfycbybM-LM56P6WpvJzaILHEUlx1zs0piCW0TKSfQ2Q01SwDJsMXtvtE0gCNQgNRqc2OGPnw/exec';
// Elementos Globais
let resultsDiv;
let searchButton;
let searchButtonText;
let searchIcon;
function handleApiResponse(data) {
const script = document.getElementById('jsonp-script');
if (script) {
script.remove();
}
setLoading(false);
handleResponse(data);
}
document.addEventListener('DOMContentLoaded', () => {
const searchForm = document.getElementById('search-form');
const nameInput = document.getElementById('name-input');
const nameError = document.getElementById('name-error');
resultsDiv = document.getElementById('results');
searchButton = document.getElementById('search-button');
searchButtonText = document.getElementById('search-button-text');
searchIcon = document.getElementById('search-icon');
searchForm.addEventListener('submit', (e) => {
e.preventDefault();
resultsDiv.innerHTML = '';
nameError.style.display = 'none';
const name = nameInput.value.trim();
if (name === '') {
nameError.style.display = 'block';
return;
}
setLoading(true);
const oldScript = document.getElementById('jsonp-script');
if (oldScript) {
oldScript.remove();
}
const url = new URL(WEB_APP_URL);
url.searchParams.append('name', name);
url.searchParams.append('callback', 'handleApiResponse');
const script = document.createElement('script');
script.id = 'jsonp-script';
script.src = url.href;
script.onerror = () => {
setLoading(false);
showError('Ocorreu um erro ao se conectar com o servidor. (Script Error)');
script.remove();
};
document.body.appendChild(script);
});
});
function handleResponse(data) {
if (data.error) {
console.error('Erro retornado pela API:', data.error);
showError('Ocorreu um erro interno ao processar sua busca.');
return;
}
if (data.found && data.matches.length > 0) {
let html = `
Resultados Encontrados (${data.matches.length}):
Seu nome está na lista? Clique para baixar.
`;
data.matches.forEach(match => {
html += `
${match.nameFound}
Baixar
`;
});
html += ` `;
resultsDiv.innerHTML = html;
} else {
showError('Nenhum certificado encontrado com este nome. Verifique se seu nome está escrito corretamente.');
}
}
function showError(message) {
resultsDiv.innerHTML = `
`;
}
function setLoading(isLoading) {
if (isLoading) {
searchButton.disabled = true;
searchButton.style.opacity = '0.75';
searchButton.style.cursor = 'not-allowed';
searchButtonText.textContent = 'Buscando...';
const spinner = document.createElement('div');
spinner.className = 'loader';
spinner.style.cssText = 'width: 1.25rem; height: 1.25rem; border: 2px solid white; border-top-color: #3498db; border-radius: 50%; margin-right: 0.5rem;';
searchIcon.replaceWith(spinner);
resultsDiv.innerHTML = `
Procurando seu certificado...
`;
} else {
searchButton.disabled = false;
searchButton.style.opacity = '1';
searchButton.style.cursor = 'pointer';
searchButtonText.textContent = 'Buscar Certificado';
const loader = searchButton.querySelector('.loader');
if (loader) {
const originalIcon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
originalIcon.setAttribute('id', 'search-icon');
originalIcon.setAttribute('fill', 'none');
originalIcon.setAttribute('viewBox', '0 0 24 24');
originalIcon.setAttribute('stroke', 'currentColor');
originalIcon.setAttribute('stroke-width', '2');
originalIcon.style.cssText = 'width: 20px; height: 20px; margin-right: 8px;';
originalIcon.innerHTML = ``;
loader.replaceWith(originalIcon);
searchIcon = document.getElementById('search-icon');
}
}
}