mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
fix: dropbox sharing maps
This commit is contained in:
parent
5ec59da7b7
commit
3353789146
4 changed files with 15 additions and 18 deletions
|
|
@ -7989,8 +7989,8 @@
|
||||||
<script defer src="libs/rgbquant.min.js"></script>
|
<script defer src="libs/rgbquant.min.js"></script>
|
||||||
<script defer src="libs/jquery.ui.touch-punch.min.js"></script>
|
<script defer src="libs/jquery.ui.touch-punch.min.js"></script>
|
||||||
<script defer src="modules/io/save.js?v=1.93.02"></script>
|
<script defer src="modules/io/save.js?v=1.93.02"></script>
|
||||||
<script defer src="modules/io/load.js?v=1.94.01"></script>
|
<script defer src="modules/io/load.js?v=1.94.04"></script>
|
||||||
<script defer src="modules/io/cloud.js"></script>
|
<script defer src="modules/io/cloud.js?v=1.94.04"></script>
|
||||||
<script defer src="modules/io/export.js?v=1.94.03"></script>
|
<script defer src="modules/io/export.js?v=1.94.03"></script>
|
||||||
<script defer src="modules/io/formats.js"></script>
|
<script defer src="modules/io/formats.js"></script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -118,9 +118,9 @@ window.Cloud = (function () {
|
||||||
},
|
},
|
||||||
|
|
||||||
async getLink(path) {
|
async getLink(path) {
|
||||||
// return existitng shared link
|
// return existing shared link
|
||||||
const sharedLinks = await this.call("sharingListSharedLinks", {path});
|
const sharedLinks = await this.call("sharingListSharedLinks", {path});
|
||||||
if (sharedLinks.result.links.length) return resp.result.links[0].url;
|
if (sharedLinks.result.links.length) return sharedLinks.result.links[0].url;
|
||||||
|
|
||||||
// create new shared link
|
// create new shared link
|
||||||
const settings = {
|
const settings = {
|
||||||
|
|
|
||||||
|
|
@ -21,22 +21,19 @@ async function createSharableDropboxLink() {
|
||||||
const mapFile = document.querySelector("#loadFromDropbox select").value;
|
const mapFile = document.querySelector("#loadFromDropbox select").value;
|
||||||
const sharableLink = document.getElementById("sharableLink");
|
const sharableLink = document.getElementById("sharableLink");
|
||||||
const sharableLinkContainer = document.getElementById("sharableLinkContainer");
|
const sharableLinkContainer = document.getElementById("sharableLinkContainer");
|
||||||
let url;
|
|
||||||
try {
|
try {
|
||||||
url = await Cloud.providers.dropbox.getLink(mapFile);
|
const previewLink = await Cloud.providers.dropbox.getLink(mapFile);
|
||||||
} catch {
|
const directLink = previewLink.replace("www.dropbox.com", "dl.dropboxusercontent.com"); // DL allows CORS
|
||||||
|
const finalLink = `${location.origin}${location.pathname}?maplink=${directLink}`;
|
||||||
|
|
||||||
|
sharableLink.innerText = finalLink.slice(0, 45) + "...";
|
||||||
|
sharableLink.setAttribute("href", finalLink);
|
||||||
|
sharableLinkContainer.style.display = "block";
|
||||||
|
} catch (error) {
|
||||||
|
ERROR && console.error(error);
|
||||||
return tip("Dropbox API error. Can not create link.", true, "error", 2000);
|
return tip("Dropbox API error. Can not create link.", true, "error", 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
const fmg = window.location.href.split("?")[0];
|
|
||||||
const reallink = `${fmg}?maplink=${url}`;
|
|
||||||
// voodoo magic required by the yellow god of CORS
|
|
||||||
const link = reallink.replace("www.dropbox.com/s/", "dl.dropboxusercontent.com/1/view/");
|
|
||||||
const shortLink = link.slice(0, 50) + "...";
|
|
||||||
|
|
||||||
sharableLinkContainer.style.display = "block";
|
|
||||||
sharableLink.innerText = shortLink;
|
|
||||||
sharableLink.setAttribute("href", link);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadMapPrompt(blob) {
|
function loadMapPrompt(blob) {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// version and caching control
|
// version and caching control
|
||||||
const version = "1.94.03"; // generator version, update each time
|
const version = "1.94.04"; // generator version, update each time
|
||||||
|
|
||||||
{
|
{
|
||||||
document.title += " v" + version;
|
document.title += " v" + version;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue