From b6fbc66ec3586523b5debbc608eec93e68e0675d Mon Sep 17 00:00:00 2001 From: Azgaar Date: Thu, 26 Mar 2026 18:03:46 +0100 Subject: [PATCH] fix: save to storage only for storage option --- public/modules/io/save.js | 15 +++++++-------- public/versioning.js | 2 +- src/index.html | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/public/modules/io/save.js b/public/modules/io/save.js index 25cd7493..85601bfb 100644 --- a/public/modules/io/save.js +++ b/public/modules/io/save.js @@ -1,6 +1,6 @@ "use strict"; -// functions to save the project to a file +// functions to save the whole .map project async function saveMap(method) { if (customization) return tip("Map cannot be saved in EDIT mode, please complete the edit and retry", false, "error"); closeDialogs("#alert"); @@ -9,7 +9,7 @@ async function saveMap(method) { const mapData = prepareMapData(); const filename = getFileName() + ".map"; - saveToStorage(mapData, method === "storage"); // any method saves to indexedDB + if (method === "storage") saveToStorage(mapData, true); if (method === "machine") saveToMachine(mapData, filename); if (method === "dropbox") saveToDropbox(mapData, filename); } catch (error) { @@ -32,13 +32,12 @@ async function saveMap(method) { $(this).dialog("close"); } }, - position: { my: "center", at: "center", of: "svg" } + position: {my: "center", at: "center", of: "svg"} }); } } function prepareMapData() { - const date = new Date(); const dateString = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate(); const license = "File can be loaded in azgaar.github.io/Fantasy-Map-Generator"; @@ -90,8 +89,8 @@ function prepareMapData() { const serializedSVG = new XMLSerializer().serializeToString(cloneEl); - const { spacing, cellsX, cellsY, boundary, points, features, cellsDesired } = grid; - const gridGeneral = JSON.stringify({ spacing, cellsX, cellsY, boundary, points, features, cellsDesired }); + const {spacing, cellsX, cellsY, boundary, points, features, cellsDesired} = grid; + const gridGeneral = JSON.stringify({spacing, cellsX, cellsY, boundary, points, features, cellsDesired}); const packFeatures = JSON.stringify(pack.features); const cultures = JSON.stringify(pack.cultures); const states = JSON.stringify(pack.states); @@ -165,14 +164,14 @@ function prepareMapData() { // save map file to indexedDB async function saveToStorage(mapData, showTip = false) { - const blob = new Blob([mapData], { type: "text/plain" }); + const blob = new Blob([mapData], {type: "text/plain"}); await ldb.set("lastMap", blob); showTip && tip("Map is saved to the browser storage", false, "success"); } // download map file function saveToMachine(mapData, filename) { - const blob = new Blob([mapData], { type: "text/plain" }); + const blob = new Blob([mapData], {type: "text/plain"}); const URL = window.URL.createObjectURL(blob); const link = document.createElement("a"); diff --git a/public/versioning.js b/public/versioning.js index 6774739a..f546ee8c 100644 --- a/public/versioning.js +++ b/public/versioning.js @@ -16,7 +16,7 @@ * For the changes that may be interesting to end users, update the `latestPublicChanges` array below (new changes on top). */ -const VERSION = "1.113.7"; +const VERSION = "1.113.8"; if (parseMapVersion(VERSION) !== VERSION) alert("versioning.js: Invalid format or parsing function"); { diff --git a/src/index.html b/src/index.html index dffaa816..d32e413a 100644 --- a/src/index.html +++ b/src/index.html @@ -8592,7 +8592,7 @@ - +