Arregalndo acceso a datos de base de datos (salmos)
This commit is contained in:
parent
29ad98a8ac
commit
90e88b85eb
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"java.compile.nullAnalysis.mode": "automatic"
|
||||
}
|
||||
|
|
@ -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.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue