From 8cc2ba4770dd67db396677fabe8a5a2339643c14 Mon Sep 17 00:00:00 2001 From: Phil Bolduc Date: Sun, 3 Oct 2021 15:41:50 -0700 Subject: [PATCH] use classList add/remove instead of edit className with string functions --- wled00/data/index.js | 8 +- wled00/data/settings_sec.htm | 4 +- wled00/data/settings_ui.htm | 4 +- wled00/data/simple.js | 2 +- wled00/html_settings.h | 4 +- wled00/html_simple.h | 784 ++++++++--------- wled00/html_ui.h | 1569 +++++++++++++++++----------------- 7 files changed, 1187 insertions(+), 1188 deletions(-) diff --git a/wled00/data/index.js b/wled00/data/index.js index fc8fdf4d..dc000051 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -270,9 +270,9 @@ function onLoad() function updateTablinks(tabI) { var tablinks = gEBCN("tablinks"); - for (var i of tablinks) i.className = i.className.replace(" active", ""); + for (var i of tablinks) i.classList.remove("active"); if (pcMode) return; - tablinks[tabI].className += " active"; + tablinks[tabI].classList.add("active"); } function openTab(tabI, force = false) @@ -290,10 +290,10 @@ function showToast(text, error = false) if (error) gId('connind').style.backgroundColor = "var(--c-r)"; var x = gId("toast"); x.innerHTML = text; - x.className = error ? "error":"show"; + x.classList.add(error ? "error":"show"); clearTimeout(timeout); x.style.animation = 'none'; - timeout = setTimeout(function(){ x.className = x.className.replace("show", ""); }, 2900); + timeout = setTimeout(function(){ x.classList.remove("show"); }, 2900); if (error) console.log(text); } diff --git a/wled00/data/settings_sec.htm b/wled00/data/settings_sec.htm index d14a8ba3..a94a028a 100644 --- a/wled00/data/settings_sec.htm +++ b/wled00/data/settings_sec.htm @@ -30,10 +30,10 @@ { var x = gId("toast"); x.innerHTML = text; - x.className = error ? "error":"show"; + x.classList.add(error ? "error":"show"); clearTimeout(timeout); x.style.animation = 'none'; - timeout = setTimeout(function(){ x.className = x.className.replace("show", ""); }, 2900); + timeout = setTimeout(function(){ x.classList.remove("show"); }, 2900); } function uploadFile(fO,name) { var req = new XMLHttpRequest(); diff --git a/wled00/data/settings_ui.htm b/wled00/data/settings_ui.htm index eb4ea9a1..364307d1 100644 --- a/wled00/data/settings_ui.htm +++ b/wled00/data/settings_ui.htm @@ -61,10 +61,10 @@ { var x = gId("toast"); x.innerHTML = text; - x.className = error ? "error":"show"; + x.classList.add(error ? "error":"show"); clearTimeout(timeout); x.style.animation = 'none'; - timeout = setTimeout(function(){ x.className = x.className.replace("show", ""); }, 2900); + timeout = setTimeout(function(){ x.classList.remove("show"); }, 2900); } function addRec(s, path = "", label = null) { diff --git a/wled00/data/simple.js b/wled00/data/simple.js index 89320b4e..b3ae81e0 100644 --- a/wled00/data/simple.js +++ b/wled00/data/simple.js @@ -260,7 +260,7 @@ function showToast(text, error = false) x.className = error ? "error":"show"; clearTimeout(timeout); x.style.animation = 'none'; - timeout = setTimeout(function(){ x.className = x.className.replace("show", ""); }, 2900); + timeout = setTimeout(function(){ x.classList.remove("show"); }, 2900); } function showErrorToast() diff --git a/wled00/html_settings.h b/wled00/html_settings.h index 77f3230c..de0086ce 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -193,7 +193,7 @@ const char PAGE_settings_dmx[] PROGMEM = R"=====()====="; // Autogenerated from wled00/data/settings_ui.htm, do not edit!! const char PAGE_settings_ui[] PROGMEM = R"=====(UI Settings