From b7bbbeb48674d16538c89c1ea97dc028236d3d7a Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Tue, 7 May 2024 09:28:35 +0800 Subject: [PATCH] collect text and icon elements --- scripts/GUI/builder/windowman.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/scripts/GUI/builder/windowman.js b/scripts/GUI/builder/windowman.js index 5027f5c..8d40138 100644 --- a/scripts/GUI/builder/windowman.js +++ b/scripts/GUI/builder/windowman.js @@ -86,9 +86,9 @@ export default class windowman { } function icons() { - let target_elements = document.querySelectorAll(`[data-icon]`); - - target_elements.forEach((element) => { + let TARGET_ELEMENTS = document.querySelectorAll(`[data-icon]`); + + (TARGET_ELEMENTS).forEach((element) => { // Get the content before removing it. let element_data = {}; @@ -122,6 +122,8 @@ export default class windowman { iconify(); clean(); }); + + return TARGET_ELEMENTS; } function text() { @@ -151,9 +153,8 @@ export default class windowman { } }); - delete text_elements[`content`]; Object.keys(text_elements).forEach((key) => { - if (text_elements[key]) { + if (text_elements[key] && !key.includes(`content`)) { text_elements[key].forEach((text_element) => { let text_inserted = texts.localized( text_element.getAttribute(key.concat(`-for`)), @@ -175,11 +176,16 @@ export default class windowman { }); } }); - } + return text_elements; + }; + + let ELEMENTS = {}; elements(); - text(); - icons(); + ELEMENTS[`text`] = text(); + ELEMENTS[`icons`] = icons(); + + return (ELEMENTS); } // Adds events to the window.