elementsManager fix

This commit is contained in:
GGodPL 2023-08-01 22:46:07 +02:00 committed by GitHub
parent 7256aab393
commit 93c902cc78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions

View File

@ -397,6 +397,7 @@ if (enabledMods.includes(mod)) {
}
const parseColor = (colorString) => {
if (typeof colorString != "string") return "#ffffff";
if (colorString.startsWith("rgb(")) {
const color = colorString.replace("rgb(", "").replace(")", "");
return `#${color.split(",").map(a => parseInt(a).toString(16)).join("")}`;
@ -603,7 +604,7 @@ if (enabledMods.includes(mod)) {
el.onchange = (ev) => {
const elementData = Storage.get("newElement", {});
if (prop.type == "number") elementData[prop.name] = parseFloat(ev.target.value);
else if (prop.type == "color" || prop.type[0] == "color") elementData[prop.name] = hexToRGB(ev.target.value);
else if (prop.type == "color" || prop.type[0] == "color") elementData[prop.name] = parseColor(ev.target.value);
else if (prop.type == "string") elementData[prop.name] = ev.target.value;
Storage.set("newElement", elementData);
}
@ -984,11 +985,9 @@ if (enabledMods.includes(mod)) {
elementData[prop.name] = "POWDER_OLD";
} else {
el.setAttribute("value", default_[prop.type]);
elementData[prop.name] = default_[prop.type];
}
if (prop.type == "boolean") {
el.setAttribute("state", "0")
elementData[prop.name] = false;
}
}
}