mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 17:51:24 +01:00
Cloud support / Dropbox OAuth reference client (#659)
* bioms shouldn't be masked or the style selection box is useless * fix: misleading comment * Fix: calculating absolute flux from precipitation normal-value. * Fix: River automatic rerender on regeneration. * Dropbox OAuth implementation and Cloud framework * add some space * removing unnecessary logs, defer script load Created by: Mészáros Gergely <monk@geotronic.hu>
This commit is contained in:
parent
f7d72c2255
commit
2d3f465d68
6 changed files with 256 additions and 57 deletions
|
|
@ -435,42 +435,19 @@ function dowloadMap() {
|
|||
window.URL.revokeObjectURL(URL);
|
||||
}
|
||||
|
||||
function saveToDropbox() {
|
||||
async function saveToDropbox() {
|
||||
const sharableLinkContainer = document.getElementById("sharableLinkContainer");
|
||||
if (customization) return tip("Map cannot be saved when edit mode is active, please exit the mode and retry", false, "error");
|
||||
closeDialogs("#alert");
|
||||
|
||||
const mapData = getMapData();
|
||||
const URL = "data:text/plain; base64," + btoa(encodeURIComponent(mapData));
|
||||
const filename = getFileName() + ".map";
|
||||
const options = {
|
||||
success: () => tip("Map is saved to your Dropbox", true, "success", 8000),
|
||||
error: function (errorMessage) {
|
||||
tip("Cannot save .map to your Dropbox", true, "error", 8000);
|
||||
console.error(errorMessage);
|
||||
}
|
||||
};
|
||||
Dropbox.save(URL, filename, options);
|
||||
}
|
||||
|
||||
function createSharableDropboxLink() {
|
||||
const sharableLink = document.getElementById("sharableLink");
|
||||
const sharableLinkContainer = document.getElementById("sharableLinkContainer");
|
||||
|
||||
const options = {
|
||||
success: function (files) {
|
||||
const url = files[0].link;
|
||||
const fmg = window.location.href.split("?")[0];
|
||||
const link = `${fmg}/?maplink=${url}`;
|
||||
const shortLink = link.slice(0, 50) + "...";
|
||||
|
||||
sharableLinkContainer.style.display = "block";
|
||||
sharableLink.innerText = shortLink;
|
||||
sharableLink.setAttribute("href", link);
|
||||
},
|
||||
linkType: "direct",
|
||||
extensions: [".map"]
|
||||
};
|
||||
Dropbox.choose(options);
|
||||
try {
|
||||
await Cloud.providers.dropbox.save(filename, mapData);
|
||||
tip("Map is saved to your Dropbox", true, "success", 8000);
|
||||
} catch (msg) {
|
||||
console.error(msg);
|
||||
tip("Cannot save .map to your Dropbox", true, "error", 8000);
|
||||
}
|
||||
}
|
||||
|
||||
function saveGeoJSON_Cells() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue