refactor(code): Cleaned-up the code base
This commit is contained in:
@@ -32,17 +32,26 @@ window.WarpBoxUI = (() => {
|
||||
parts.backdrop?.classList.add("is-visible");
|
||||
}
|
||||
|
||||
function closePopup(options = {}) {
|
||||
const parts = popupElements(options);
|
||||
parts.popup?.classList.remove("is-visible", "is-about-popup", "is-properties-popup", "is-preview-popup");
|
||||
parts.backdrop?.classList.remove("is-visible");
|
||||
}
|
||||
function closePopup(options = {}) {
|
||||
const parts = popupElements(options);
|
||||
parts.popup?.classList.remove("is-visible", "is-about-popup", "is-properties-popup", "is-preview-popup");
|
||||
parts.backdrop?.classList.remove("is-visible");
|
||||
}
|
||||
|
||||
function renderTemplate(template, data = {}) {
|
||||
return String(template).replace(/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g, (_, key) => {
|
||||
return Object.prototype.hasOwnProperty.call(data, key) ? String(data[key]) : "";
|
||||
});
|
||||
}
|
||||
function htmlEscape(value) {
|
||||
return String(value || "")
|
||||
.replaceAll("&", "&")
|
||||
.replaceAll("<", "<")
|
||||
.replaceAll(">", ">")
|
||||
.replaceAll('"', """)
|
||||
.replaceAll("'", "'");
|
||||
}
|
||||
|
||||
return { toast, openPopup, closePopup, renderTemplate };
|
||||
function renderTemplate(template, data = {}) {
|
||||
return String(template).replace(/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g, (_, key) => {
|
||||
return Object.prototype.hasOwnProperty.call(data, key) ? String(data[key]) : "";
|
||||
});
|
||||
}
|
||||
|
||||
return { toast, openPopup, closePopup, htmlEscape, renderTemplate };
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user