dropbox - import changes from alpha

This commit is contained in:
Azgaar 2021-09-01 21:33:49 +03:00
parent 7865497cd2
commit c783301de9
7 changed files with 208 additions and 129 deletions

31
main.js
View file

@ -219,37 +219,6 @@ void (function checkLoadParameters() {
generateMapOnLoad();
})();
function loadMapFromURL(maplink, random) {
const URL = decodeURIComponent(maplink);
fetch(URL, {method: "GET", mode: "cors"})
.then(response => {
if (response.ok) return response.blob();
throw new Error("Cannot load map from URL");
})
.then(blob => uploadMap(blob))
.catch(error => {
showUploadErrorMessage(error.message, URL, random);
if (random) generateMapOnLoad();
});
}
function showUploadErrorMessage(error, URL, random) {
ERROR && console.error(error);
alertMessage.innerHTML = `Cannot load map from the ${link(URL, "link provided")}.
${random ? `A new random map is generated. ` : ""}
Please ensure the linked file is reachable and CORS is allowed on server side`;
$("#alert").dialog({
title: "Loading error",
width: "32em",
buttons: {
OK: function () {
$(this).dialog("close");
}
}
});
}
function generateMapOnLoad() {
applyStyleOnLoad(); // apply default of previously selected style
generate(); // generate map