Última modificação: Quinta-feira, 26 de junho de 2025
Arquivos Públicos do DEE-CV
Lista de arquivos compartilhados.
Arquivo |
Modificado em |
Link |
(function() {
// Garante que o script não execute múltiplas vezes se for colado acidentalmente mais de uma vez.
if (window.gdriveViewerInitialized) {
return;
}
window.gdriveViewerInitialized = true;
const statusDiv = document.getElementById(‘gdrive-viewer-status’);
const fileListBody = document.getElementById(‘gdrive-viewer-file-list’);
const loadingDiv = document.getElementById(‘gdrive-viewer-loading’);
const scriptUrl = “https://script.google.com/macros/s/AKfycbxy_9yHBxPMNgpsOPX–pM36cq7b7y3n8YR_hISrgLpq-khUJTTMZmzHhLIuTC24Wuc/exec”;
const POLLING_INTERVAL_MS = 300000; // 5 minutos
async function listFiles() {
statusDiv.textContent = ‘Verificando atualizações…’;
loadingDiv.style.display = ‘block’;
try {
const response = await fetch(scriptUrl);
if (!response.ok) throw new Error(‘A requisição falhou: ‘ + response.status);
const data = await response.json();
if (data.error) throw new Error(‘Erro no script: ‘ + data.error);
const files = data.files;
fileListBody.innerHTML = ”;
if (files && files.length > 0) {
const now = new Date();
const NEW_FILE_THRESHOLD_MS = 48 * 60 * 60 * 1000;
files.forEach(file => {
const fileDate = new Date(file.lastUpdated);
const isNew = (now.getTime() – fileDate.getTime()) < NEW_FILE_THRESHOLD_MS;
const tr = document.createElement('tr');
tr.style.borderBottom = "1px solid #eee";
// Célula do Nome do Arquivo e Badge
const nameCell = document.createElement('td');
nameCell.style.padding = "0.8rem 0.5rem";
nameCell.innerHTML = `
${file.name}`;
if (isNew) {
nameCell.innerHTML += `
NOVO`;
}
// Célula da Data
const dateCell = document.createElement(‘td’);
dateCell.style.padding = “0.8rem 0.5rem”;
dateCell.textContent = fileDate.toLocaleDateString(‘pt-BR’);
// Célula do Link
const linkCell = document.createElement(‘td’);
linkCell.style.padding = “0.8rem 0.5rem”;
linkCell.style.textAlign = “center”;
linkCell.innerHTML = `
Abrir`;
tr.appendChild(nameCell);
tr.appendChild(dateCell);
tr.appendChild(linkCell);
fileListBody.appendChild(tr);
});
} else {
const tr = document.createElement(‘tr’);
const td = document.createElement(‘td’);
td.colSpan = 3;
td.textContent = ‘Nenhum arquivo encontrado na pasta.’;
td.style.padding = ‘1.5rem’;
td.style.textAlign = ‘center’;
tr.appendChild(td);
fileListBody.appendChild(tr);
}
statusDiv.textContent = ‘Lista atualizada em ‘ + new Date().toLocaleTimeString(‘pt-BR’);
} catch (err) {
console.error(‘Erro ao buscar arquivos:’, err);
statusDiv.textContent = ‘Não foi possível carregar os arquivos.’;
fileListBody.innerHTML = `
Ocorreu um erro. Verifique o console para mais detalhes. |
`;
} finally {
loadingDiv.style.display = ‘none’;
}
}
// Inicia o processo assim que o script é carregado.
listFiles();
setInterval(listFiles, POLLING_INTERVAL_MS);
})();