mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-02-05 18:11:23 +01:00
Fully working
This commit is contained in:
parent
0b7da6d008
commit
cfda78807d
2 changed files with 6 additions and 3 deletions
|
|
@ -14,6 +14,7 @@ async function saveMap(method) {
|
||||||
if (method === "dropbox") saveToDropbox(mapData, filename);
|
if (method === "dropbox") saveToDropbox(mapData, filename);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ERROR && console.error(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(
|
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",
|
"https://github.com/Azgaar/Fantasy-Map-Generator/issues",
|
||||||
"GitHub"
|
"GitHub"
|
||||||
|
|
@ -167,6 +168,7 @@ function prepareMapData() {
|
||||||
async function saveToStorage(mapData, showTip = false) {
|
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);
|
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");
|
showTip && tip("Map is saved to the browser storage", false, "success");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -210,6 +212,7 @@ async function initiateAutosave() {
|
||||||
lastSavedAt = Date.now();
|
lastSavedAt = Date.now();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ERROR && console.error(error);
|
ERROR && console.error(error);
|
||||||
|
await window.ServerAPI.postData("api/catch-error.json", error, {point: "initiateAutosave", timestamp: Date.now()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ window.ServerAPI = (function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function postMapData(path, mapData, params) {
|
async function postData(path, mapData, params) {
|
||||||
if (!ok) {return null;}
|
if (!ok) {return null;}
|
||||||
|
|
||||||
const url = buildUrl(path, params);
|
const url = buildUrl(path, params);
|
||||||
|
|
@ -140,7 +140,7 @@ window.ServerAPI = (function () {
|
||||||
return {
|
return {
|
||||||
checkData,
|
checkData,
|
||||||
getJson,
|
getJson,
|
||||||
postMapData
|
postData
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
@ -150,5 +150,5 @@ window.ServerAPI = (function () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Ответ сервера (JSON):", data.info);
|
console.log("[ServerAPI][enabled]: ", data.info);
|
||||||
})();
|
})();
|
||||||
Loading…
Add table
Add a link
Reference in a new issue