diff --git a/ui/media/js/main.js b/ui/media/js/main.js index 63683b65..57789cef 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -1703,34 +1703,3 @@ prettifyInputs(document); // set the textbox as focused on start promptField.focus() promptField.selectionStart = promptField.value.length - -/** - * - * @param {string} tag - * @param {object} attributes - * @param {string | Array} classes - * @param {string | HTMLElement | Array} - * @returns {HTMLElement} - */ - function createElement(tagName, attributes, classes, textOrElements) { - const element = document.createElement(tagName) - if (attributes) { - Object.entries(attributes).forEach(([key, value]) => { - element.setAttribute(key, value) - }); - } - if (classes) { - (Array.isArray(classes) ? classes : [classes]).forEach(className => element.classList.add(className)) - } - if (textOrElements) { - const children = Array.isArray(textOrElements) ? textOrElements : [textOrElements] - children.forEach(textOrElem => { - if (textOrElem instanceof HTMLElement) { - element.appendChild(textOrElem) - } else { - element.appendChild(document.createTextNode(textOrElem)) - } - }) - } - return element -} diff --git a/ui/media/js/utils.js b/ui/media/js/utils.js index 3f8d3fab..6eb0d643 100644 --- a/ui/media/js/utils.js +++ b/ui/media/js/utils.js @@ -677,3 +677,34 @@ class ServiceContainer { return typeof definition === 'function' } } + +/** + * + * @param {string} tag + * @param {object} attributes + * @param {string | Array} classes + * @param {string | HTMLElement | Array} + * @returns {HTMLElement} + */ +function createElement(tagName, attributes, classes, textOrElements) { + const element = document.createElement(tagName) + if (attributes) { + Object.entries(attributes).forEach(([key, value]) => { + element.setAttribute(key, value) + }); + } + if (classes) { + (Array.isArray(classes) ? classes : [classes]).forEach(className => element.classList.add(className)) + } + if (textOrElements) { + const children = Array.isArray(textOrElements) ? textOrElements : [textOrElements] + children.forEach(textOrElem => { + if (textOrElem instanceof HTMLElement) { + element.appendChild(textOrElem) + } else { + element.appendChild(document.createTextNode(textOrElem)) + } + }) + } + return element +}