diff --git a/index.css b/index.css index 24f7f199..01b41f67 100644 --- a/index.css +++ b/index.css @@ -1731,7 +1731,7 @@ div.states > div.biomeArea { #emblemUploadControl, #emblemDownloadControl { margin-top: 0.3em; - text-align: center; + width: 100%; } div.editorLine { diff --git a/index.html b/index.html index ff7c5515..1291b870 100644 --- a/index.html +++ b/index.html @@ -128,7 +128,7 @@ } - + @@ -4902,7 +4902,10 @@ > Any image - - + diff --git a/modules/ui/emblems-editor.js b/modules/ui/emblems-editor.js index c718bbda..c02ee305 100644 --- a/modules/ui/emblems-editor.js +++ b/modules/ui/emblems-editor.js @@ -239,12 +239,9 @@ function editEmblem(type, id, el) { input.value = ""; if (file.size > 500000) { - tip( - `File is too big, please optimize file size up to 500kB and re-upload. Recommended size is 200x200 px and up to 100kB`, - true, - "error", - 5000 - ); + const message = + "File is too big, please optimize file size up to 500kB and re-upload. Recommended size is 200x200 px and up to 100kB"; + tip(message, true, "error", 5000); return; } @@ -253,40 +250,37 @@ function editEmblem(type, id, el) { reader.onload = function (readerEvent) { const result = readerEvent.target.result; const defs = document.getElementById("defs-emblems"); - const coa = document.getElementById(id); // old emblem + const oldEmblem = document.getElementById(id); - if (type === "image") { - const svg = ``; - defs.insertAdjacentHTML("beforeend", svg); - } else { + let href = result; // raster images + if (type === "svg") { const el = document.createElement("html"); el.innerHTML = result; - // remove sodipodi and inkscape attributes el.querySelectorAll("*").forEach(el => { - const attributes = el.getAttributeNames(); - attributes.forEach(attr => { + if (el.id === "adobe_illustrator_pgf") el.remove(); // remove Adobe Illustrator inner data + + el.getAttributeNames().forEach(attr => { + // remove sodipodi and inkscape attributes if (attr.includes("inkscape") || attr.includes("sodipodi")) el.removeAttribute(attr); }); }); const svg = el.querySelector("svg"); if (!svg) { - tip( - "The file should be prepated for load to FMG. Please use Armoria or other relevant tools", - false, - "error" - ); + const message = "The file is not a valid SVG. Please use Armoria or other relevant tools"; + tip(message, false, "error"); return; } - const newEmblem = defs.appendChild(svg); - newEmblem.id = id; - newEmblem.setAttribute("width", 200); - newEmblem.setAttribute("height", 200); + const serialized = new XMLSerializer().serializeToString(svg); + href = "data:image/svg+xml;base64," + window.btoa(serialized); } - if (coa) coa.remove(); // remove old emblem + const svg = ``; + defs.insertAdjacentHTML("beforeend", svg); + + if (oldEmblem) oldEmblem.remove(); el.coa = "custom"; emblemShapeSelector.disabled = true; }; diff --git a/versioning.js b/versioning.js index e8a1a06c..6bd7dce0 100644 --- a/versioning.js +++ b/versioning.js @@ -1,7 +1,7 @@ "use strict"; // version and caching control -const version = "1.89.20"; // generator version, update each time +const version = "1.89.21"; // generator version, update each time { document.title += " v" + version;