Fix Error: Solvento el error de carga de una segunda tabla y añado un log para ver posibles errores con el audio

This commit is contained in:
2025-09-17 08:34:33 +02:00
parent 400e0c19ff
commit e1f64ee861
3 changed files with 19 additions and 22 deletions
+14 -17
View File
@@ -1,13 +1,17 @@
const sonido = new Audio("/static/media/0457.wav");
const estadoAnterior = {};
sonido.preload = "auto";
const estadoAnterior = {};
let ultimoFooter = "";
function cargarTabla(endpoint, tablaId, esQuiro) {
const tbody = document.getElementById(tablaId);
if (!tbody) return;
fetch(endpoint)
.then(res => res.json())
.then(filas => {
const tbody = document.getElementById(tablaId);
tbody.innerHTML = "";
let sizeClass = "";
@@ -19,21 +23,16 @@ function cargarTabla(endpoint, tablaId, esQuiro) {
filas.forEach(fila => {
const id = fila[0];
const tr = document.createElement("tr");
// Crear celda 1
const td1 = document.createElement("td");
td1.textContent = fila[0];
td1.className = `border align-middle ${sizeClass} m`;
if (esQuiro === "1") {
td1.style.backgroundColor = "#008968";
} else {
td1.style.backgroundColor = window.themeColors.bg1;
}
td1.style.backgroundColor = esQuiro === "1" ? "#008968" : window.themeColors.bg1;
tr.appendChild(td1);
const td2 = document.createElement("td");
const estadoConsulta = fila[1];
const estadoTurno = fila[3];
@@ -42,16 +41,13 @@ function cargarTabla(endpoint, tablaId, esQuiro) {
td2.className = `border bg-[#a9a9a9] align-middle ${sizeClass}`;
} else if (estadoConsulta == 1) {
td2.textContent = fila[2];
if (esQuiro === "1") {
td2.style.backgroundColor = "#00aa7a";
} else {
td2.style.backgroundColor = window.themeColors.bg2;
}
td2.style.backgroundColor = esQuiro === "1" ? "#008968" : window.themeColors.bg1;
const originalText = fila[2];
const blinkText = `<span class="text-[2.25rem]">PASE A<br>CONSULTA</span>`;
let blink = false;
if (estadoTurno == 1) {
//Activar parapdeo
td2.className = `border align-middle ${sizeClass}`;
td2.innerHTML = originalText;
td2.style.backgroundColor = '#ffff00';
@@ -105,15 +101,16 @@ function cargarTabla(endpoint, tablaId, esQuiro) {
}
if (estadoAnterior[id] === 2 && estadoTurno === 1) {
sonido.play();
sonido.currentTime = 0;
sonido.play().catch(err => console.warn("No se pudo reproducir el sonido: ", err));
}
estadoAnterior[id] = estadoTurno;
tr.appendChild(td2);
tbody.appendChild(tr);
});
});
})
.catch(err => console.error("Error cargando tabla: ", err));
}
function cargarFooter() {