From b3a6a19f95d91d2019e686d2eee5d3bf2d0285e1 Mon Sep 17 00:00:00 2001 From: Naiel <109038805+naielv@users.noreply.github.com> Date: Thu, 11 Sep 2025 12:09:28 +0200 Subject: [PATCH] =?UTF-8?q?ol=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/page/materiales.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/page/materiales.js b/src/page/materiales.js index 186a021..16d78c7 100644 --- a/src/page/materiales.js +++ b/src/page/materiales.js @@ -150,15 +150,25 @@ PAGES.materiales = { gun.get(TABLE).get("materiales").once().map().once((data, key) => { try { if (!data) return; + function addUbicacion(d) { - let ubicacion = d.Ubicacion || "-"; - let select = document.getElementById(select_ubicacion); - if ([...select.options].some(opt => opt.value === ubicacion)) return; - let option = document.createElement("option"); + const ubicacion = d.Ubicacion || "-"; + const select = document.getElementById(select_ubicacion); + + if (!select) { + console.warn(`Element with ID "${select_ubicacion}" not found.`); + return; + } + + const optionExists = Array.from(select.options).some(opt => opt.value === ubicacion); + if (optionExists) return; + + const option = document.createElement("option"); option.value = ubicacion; option.textContent = ubicacion; select.appendChild(option); } + if (typeof data === "string") { TS_decrypt(data, SECRET, (dec) => { if (dec) addUbicacion(dec); @@ -167,7 +177,7 @@ PAGES.materiales = { addUbicacion(data); } } catch (error) { - console.warn(error) + console.warn("Error processing ubicacion:", error); } });