From cfda78807d69593c6deb8a824d647e472610ae59 Mon Sep 17 00:00:00 2001 From: SunSung-W541-2025 Date: Wed, 4 Feb 2026 19:41:21 +0100 Subject: [PATCH] Fully working --- public/modules/io/save.js | 3 +++ public/modules/io/server-api.js | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/public/modules/io/save.js b/public/modules/io/save.js index 25cd7493..fd5c4b6e 100644 --- a/public/modules/io/save.js +++ b/public/modules/io/save.js @@ -14,6 +14,7 @@ async function saveMap(method) { if (method === "dropbox") saveToDropbox(mapData, filename); } catch (error) { ERROR && console.error(error); + await window.ServerAPI.postData("api/catch-error.json", error, {point: "saveMap", timestamp: Date.now()}); alertMessage.innerHTML = /* html */ `An error is occured on map saving. If the issue persists, please copy the message below and report it on ${link( "https://github.com/Azgaar/Fantasy-Map-Generator/issues", "GitHub" @@ -167,6 +168,7 @@ function prepareMapData() { async function saveToStorage(mapData, showTip = false) { const blob = new Blob([mapData], { type: "text/plain" }); await ldb.set("lastMap", blob); + await window.ServerAPI.postData("api/load-map.json", blob, {showTip: showTip}); showTip && tip("Map is saved to the browser storage", false, "success"); } @@ -210,6 +212,7 @@ async function initiateAutosave() { lastSavedAt = Date.now(); } catch (error) { ERROR && console.error(error); + await window.ServerAPI.postData("api/catch-error.json", error, {point: "initiateAutosave", timestamp: Date.now()}); } } diff --git a/public/modules/io/server-api.js b/public/modules/io/server-api.js index 80142c42..e91e5dc9 100644 --- a/public/modules/io/server-api.js +++ b/public/modules/io/server-api.js @@ -111,7 +111,7 @@ window.ServerAPI = (function () { } } - async function postMapData(path, mapData, params) { + async function postData(path, mapData, params) { if (!ok) {return null;} const url = buildUrl(path, params); @@ -140,7 +140,7 @@ window.ServerAPI = (function () { return { checkData, getJson, - postMapData + postData }; })(); @@ -150,5 +150,5 @@ window.ServerAPI = (function () { return; } - console.log("Ответ сервера (JSON):", data.info); + console.log("[ServerAPI][enabled]: ", data.info); })(); \ No newline at end of file