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
|
VARIABLES GLOBALES
|
||||||
============================================ */
|
============================================ */
|
||||||
|
|
||||||
let fechaHoyElem, indicadorLiturgicoElem, cabeceraHoy, menuPrincipalElem,
|
// Las variables globales comunes (fechaHoyElem, etc.) se declaran en header.js
|
||||||
nombreCicloElem, cicloParImparElem, descripcionSantoDelDiaElem,
|
let salmoDelDiaElem;
|
||||||
errorElem, salmoDelDiaElem;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -74,9 +73,18 @@ async function visualizarSalmo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Error cargando el salmo:", e);
|
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.";
|
salmoElem.textContent = "Bendice, alma mía, al Señor.";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue