Arregalndo acceso a datos de base de datos (salmos)

This commit is contained in:
Tatiana Villa 2026-04-28 12:03:43 +02:00
parent 29ad98a8ac
commit 90e88b85eb
2 changed files with 16 additions and 5 deletions

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"java.compile.nullAnalysis.mode": "automatic"
}

View File

@ -24,9 +24,8 @@ if (document.readyState === 'loading') {
VARIABLES GLOBALES
============================================ */
let fechaHoyElem, indicadorLiturgicoElem, cabeceraHoy, menuPrincipalElem,
nombreCicloElem, cicloParImparElem, descripcionSantoDelDiaElem,
errorElem, salmoDelDiaElem;
// Las variables globales comunes (fechaHoyElem, etc.) se declaran en header.js
let salmoDelDiaElem;
@ -74,8 +73,17 @@ async function visualizarSalmo() {
}
} catch (e) {
console.error("Error cargando el salmo:", e);
salmoElem.textContent = "Bendice, alma mía, al Señor.";
console.warn("API no disponible, cargando salmo local:", e);
try {
const res2 = await fetch('data/salmos.json');
const salmos = await res2.json();
const hoy = new Date();
const diaAnyo = Math.floor((hoy - new Date(hoy.getFullYear(), 0, 0)) / 86400000);
const salmo = salmos[diaAnyo % salmos.length];
salmoElem.innerHTML = `${salmo.texto}<br><cite style="font-size:0.8em;opacity:0.7;">— Salmo ${salmo.numero}</cite>`;
} catch (e2) {
salmoElem.textContent = "Bendice, alma mía, al Señor.";
}
}
}