Skip to content

Commit b6fbc66

Browse files
committed
fix: save to storage only for storage option
1 parent 51a1f3a commit b6fbc66

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

public/modules/io/save.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22

3-
// functions to save the project to a file
3+
// functions to save the whole .map project
44
async function saveMap(method) {
55
if (customization) return tip("Map cannot be saved in EDIT mode, please complete the edit and retry", false, "error");
66
closeDialogs("#alert");
@@ -9,7 +9,7 @@ async function saveMap(method) {
99
const mapData = prepareMapData();
1010
const filename = getFileName() + ".map";
1111

12-
saveToStorage(mapData, method === "storage"); // any method saves to indexedDB
12+
if (method === "storage") saveToStorage(mapData, true);
1313
if (method === "machine") saveToMachine(mapData, filename);
1414
if (method === "dropbox") saveToDropbox(mapData, filename);
1515
} catch (error) {
@@ -32,13 +32,12 @@ async function saveMap(method) {
3232
$(this).dialog("close");
3333
}
3434
},
35-
position: { my: "center", at: "center", of: "svg" }
35+
position: {my: "center", at: "center", of: "svg"}
3636
});
3737
}
3838
}
3939

4040
function prepareMapData() {
41-
4241
const date = new Date();
4342
const dateString = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
4443
const license = "File can be loaded in azgaar.github.io/Fantasy-Map-Generator";
@@ -90,8 +89,8 @@ function prepareMapData() {
9089

9190
const serializedSVG = new XMLSerializer().serializeToString(cloneEl);
9291

93-
const { spacing, cellsX, cellsY, boundary, points, features, cellsDesired } = grid;
94-
const gridGeneral = JSON.stringify({ spacing, cellsX, cellsY, boundary, points, features, cellsDesired });
92+
const {spacing, cellsX, cellsY, boundary, points, features, cellsDesired} = grid;
93+
const gridGeneral = JSON.stringify({spacing, cellsX, cellsY, boundary, points, features, cellsDesired});
9594
const packFeatures = JSON.stringify(pack.features);
9695
const cultures = JSON.stringify(pack.cultures);
9796
const states = JSON.stringify(pack.states);
@@ -165,14 +164,14 @@ function prepareMapData() {
165164

166165
// save map file to indexedDB
167166
async function saveToStorage(mapData, showTip = false) {
168-
const blob = new Blob([mapData], { type: "text/plain" });
167+
const blob = new Blob([mapData], {type: "text/plain"});
169168
await ldb.set("lastMap", blob);
170169
showTip && tip("Map is saved to the browser storage", false, "success");
171170
}
172171

173172
// download map file
174173
function saveToMachine(mapData, filename) {
175-
const blob = new Blob([mapData], { type: "text/plain" });
174+
const blob = new Blob([mapData], {type: "text/plain"});
176175
const URL = window.URL.createObjectURL(blob);
177176

178177
const link = document.createElement("a");

public/versioning.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* For the changes that may be interesting to end users, update the `latestPublicChanges` array below (new changes on top).
1717
*/
1818

19-
const VERSION = "1.113.7";
19+
const VERSION = "1.113.8";
2020
if (parseMapVersion(VERSION) !== VERSION) alert("versioning.js: Invalid format or parsing function");
2121

2222
{

src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8592,7 +8592,7 @@
85928592
<script defer src="modules/ui/hotkeys.js?v=1.104.0"></script>
85938593
<script defer src="libs/rgbquant.min.js"></script>
85948594
<script defer src="libs/jquery.ui.touch-punch.min.js"></script>
8595-
<script defer src="modules/io/save.js?v=1.111.0"></script>
8595+
<script defer src="modules/io/save.js?v=1.113.8"></script>
85968596
<script defer src="modules/io/load.js?v=1.113.0"></script>
85978597
<script defer src="modules/io/cloud.js?v=1.106.0"></script>
85988598
<script defer src="modules/io/export.js?v=1.112.2"></script>

0 commit comments

Comments
 (0)