diff --git a/src/app_logic.js b/src/app_logic.js index 847c4ac..8e52344 100644 --- a/src/app_logic.js +++ b/src/app_logic.js @@ -35,23 +35,9 @@ if (urlParams.get("login") != null) { } function open_page(params) { - try { - if (EVENTLISTENER != null) { - try { - EVENTLISTENER.off(); - EVENTLISTENER = null; - EVENTLISTENER2.off(); - EVENTLISTENER2 = null; - // TypeError: Cannot read properties of null (reading 'off') - } catch (error) { - if (!error.name == "TypeError") { - console.debug("EVENTLISTENER error", error); - } - } - } - } catch (e) { - console.debug("EVENTLISTENER onhashchange", e); - } + EventListenrea.GunJS.forEach(ev => ev.off()); + EventListenrea.Timeout.forEach(ev => clearTimeout(ev)); + EventListenrea.Interval.forEach(ev => clearInterval(ev)); if (SUB_LOGGED_IN != true) { PAGES["login"].index(); return; diff --git a/src/app_modules.js b/src/app_modules.js index 5c70aa3..77d6e74 100644 --- a/src/app_modules.js +++ b/src/app_modules.js @@ -967,8 +967,7 @@ function TS_IndexElement( }); } ref.map().on((data, key, _msg, _ev) => { - EVENTLISTENER = _ev; - + EventListeners.GunJS.append(_ev); function add_row(data, key) { if (data != null) { data["_key"] = key; diff --git a/src/config.js b/src/config.js index 7431a8a..cac3625 100644 --- a/src/config.js +++ b/src/config.js @@ -1,5 +1,8 @@ -var EVENTLISTENER = null; -var EVENTLISTENER2 = null; +var EventListeners = { + GunJS: [], + Timeout: [], + Interval: [], +} var urlParams = new URLSearchParams(location.search); var AC_BYPASS = false; if (urlParams.get("ac_bypass") == "yes") { @@ -28,7 +31,7 @@ if (urlParams.get("sublogin") != null) { SUB_LOGGED_IN = true; SUB_LOGGED_IN_ID = urlParams.get("sublogin"); SUB_LOGGED_IN_DETAILS = true; - setTimeout(() => { + setInterval(() => { SUB_LOGGED_IN_DETAILS = SC_Personas[SUB_LOGGED_IN_ID]; }, 1500); } diff --git a/src/page/supercafe.js b/src/page/supercafe.js index 9ec2922..9fb581d 100644 --- a/src/page/supercafe.js +++ b/src/page/supercafe.js @@ -143,11 +143,12 @@ PAGES.supercafe = { if (urlParams.get("sc_nobtn") == "yes") { sc_nobtn = "pointer-events: none; opacity: 0.5"; } - setTimeout(() => { + var ev = setTimeout(() => { tts = true; console.log("TTS Enabled"); toastr.info("Texto a voz disponible"); }, 6500); + EventListeners.Timeout.append(ev) const tablebody = safeuuid(); const tablebody2 = safeuuid(); var btn_new = safeuuid();