mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-23 12:31:24 +01:00
Merge branch 'master' of https://github.com/Azgaar/Fantasy-Map-Generator into fonts
This commit is contained in:
commit
8dd7b3c8a9
6 changed files with 279 additions and 72 deletions
49
dropbox.html
Normal file
49
dropbox.html
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" dir="ltr">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<script type="text/javascript" src="https://unpkg.com/dropbox@10.8.0/dist/Dropbox-sdk.min.js"></script>
|
||||||
|
<title>FMG Dropbox Auth</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
/*
|
||||||
|
open this page in a new window without query parameter to start auth
|
||||||
|
window.opener.setDropBoxToken(token) will be called on the opener
|
||||||
|
window.
|
||||||
|
*/
|
||||||
|
const REDIRECT_URI = window.location.origin + window.location.pathname;
|
||||||
|
const dbxAuth = new Dropbox.DropboxAuth({clientId: "pdr9ae64ip0qno4"});
|
||||||
|
|
||||||
|
const spObj = new URLSearchParams(window.location.search);
|
||||||
|
const searchParams = Object.fromEntries(spObj.entries());
|
||||||
|
|
||||||
|
if (searchParams.code) getToken();
|
||||||
|
else doAuth(); // start authentication
|
||||||
|
|
||||||
|
function doAuth() {
|
||||||
|
dbxAuth
|
||||||
|
.getAuthenticationUrl(REDIRECT_URI, undefined, "code", "offline", undefined, undefined, true)
|
||||||
|
.then(authUrl => {
|
||||||
|
window.sessionStorage.clear();
|
||||||
|
window.sessionStorage.setItem("codeVerifier", dbxAuth.codeVerifier);
|
||||||
|
window.location.href = authUrl;
|
||||||
|
})
|
||||||
|
.catch(error => console.error(error));
|
||||||
|
}
|
||||||
|
|
||||||
|
function getToken() {
|
||||||
|
dbxAuth.setCodeVerifier(window.sessionStorage.getItem("codeVerifier"));
|
||||||
|
dbxAuth
|
||||||
|
.getAccessTokenFromCode(REDIRECT_URI, searchParams.code)
|
||||||
|
.then(resp => {
|
||||||
|
const token = resp.result.access_token;
|
||||||
|
window.opener.Cloud.providers.dropbox.setDropBoxToken(token);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
48
index.html
48
index.html
|
|
@ -3490,11 +3490,9 @@
|
||||||
<button onclick="saveGeoJSON_Rivers()" data-tip="Download rivers data in GeoJSON format">rivers</button>
|
<button onclick="saveGeoJSON_Rivers()" data-tip="Download rivers data in GeoJSON format">rivers</button>
|
||||||
<button onclick="saveGeoJSON_Markers()" data-tip="Download markers data in GeoJSON format">markers</button>
|
<button onclick="saveGeoJSON_Markers()" data-tip="Download markers data in GeoJSON format">markers</button>
|
||||||
</div>
|
</div>
|
||||||
<p style="font-style: italic">GeoJSON format is used in GIS tools such as QGIS. Check out <a href="https://github.com/Azgaar/Fantasy-Map-Generator/wiki/GIS-data-export" target="_blank">wiki-page</a> for guidance</p>
|
<p>GeoJSON format is used in GIS tools such as QGIS. Check out <a href="https://github.com/Azgaar/Fantasy-Map-Generator/wiki/GIS-data-export" target="_blank">wiki-page</a> for guidance.</p>
|
||||||
|
<p>Generator uses pop-up window to download files. Please ensure your browser does not block popups.</p>
|
||||||
<p style="font-style: italic">Generator uses pop-up window to download files. Please ensure your browser does not block popups.</p>
|
<p>It's also possible to export map to <i>Foundry VTT</i>, see <a href="https://github.com/Ethck/azgaar-foundry" target="_blank">the module.</a></p>
|
||||||
|
|
||||||
<p style="font-style: italic">It's also possible to export map to Foundry VTT, see <a href="https://github.com/Ethck/azgaar-foundry" target="_blank">the module.</a></p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="saveMapData" style="display: none" class="dialog">
|
<div id="saveMapData" style="display: none" class="dialog">
|
||||||
|
|
@ -3502,33 +3500,38 @@
|
||||||
<strong>Save map to</strong>
|
<strong>Save map to</strong>
|
||||||
<button onclick="dowloadMap()" data-tip="Download .map file to your local disk. Shortcut: Ctrl + S">machine</button>
|
<button onclick="dowloadMap()" data-tip="Download .map file to your local disk. Shortcut: Ctrl + S">machine</button>
|
||||||
<button onclick="saveToDropbox()" data-tip="Save .map file to your Dropbox">dropbox</button>
|
<button onclick="saveToDropbox()" data-tip="Save .map file to your Dropbox">dropbox</button>
|
||||||
<button onclick="quickSave()" data-tip="Save the project to browser storage (quick save). It can be unreliable. Shortcut: F6">browser</button>
|
<button onclick="quickSave()" data-tip="Save the project to browser storage. It can be unreliable. Shortcut: F6">browser</button>
|
||||||
|
</div>
|
||||||
|
<p>Maps are saved in <i>.map</i> format, that can be loaded back via the <i>Load</i> in menu. There is no way to restore the progress if file is lost. Please keep old <i>.map</i> files on your machine or cloud storage as backups.</p>
|
||||||
</div>
|
</div>
|
||||||
<p style="font-style: italic">Maps are saved in <i>.map</i> format, that can be loaded back via 'Load' in menu. Please keep noted that we do not keep any data on our side. There is no way to restore the progress if .map file is lost. Please keep old .map files on your machine or cloud storage as backups.</p>
|
|
||||||
<p style="font-style: italic">Saving to Dropbox may not be allowed for big files. In this case open <a href="https://www.dropbox.com/home/FMG" target="_blank">Dropbox</a>, download the .map file and upload it manually.</p>
|
|
||||||
|
|
||||||
<div style="margin-top: .3em" data-tip="Select .map file on dropbox and share a sharable link">
|
<div id="loadMapData" style="display: none" class="dialog">
|
||||||
<strong>Create sharable link</strong>
|
<div>
|
||||||
<button onclick="createSharableDropboxLink()">select file</button>
|
<strong>Load map from</strong>
|
||||||
|
<button onclick="mapToLoad.click()" data-tip="Load .map file from local disk">local disk</button>
|
||||||
|
<button onclick="loadURL()" data-tip="Load .map file from URL (server should allow CORS)">URL</button>
|
||||||
|
<button onclick="quickLoad()" data-tip="Load map from browser storage (if saved before)">storage</button>
|
||||||
|
</div>
|
||||||
|
<div id="loadFromDropbox">
|
||||||
|
<p style="margin-bottom: .3em">From your Dropbox account</p>
|
||||||
|
<select id="loadFromDropboxSelect" style="width: 22em"></select>
|
||||||
|
|
||||||
|
<div id="loadFromDropboxButtons" style="margin-bottom: .3em">
|
||||||
|
<button onclick="loadFromDropbox()" data-tip="Load .map file from your Dropbox">Open</button>
|
||||||
|
<button onclick="createSharableDropboxLink()" data-tip="Select file and create a link to share with your friends">Create link</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="margin-top: .3em">
|
||||||
<div id="sharableLinkContainer" style="display: none">
|
<div id="sharableLinkContainer" style="display: none">
|
||||||
<a id="sharableLink" target="_blank"></a>
|
<a id="sharableLink" target="_blank"></a>
|
||||||
<i data-tip="Copy link to the clipboard" onclick="copyLinkToClickboard()" class="icon-clone pointer"></i>
|
<i data-tip="Copy link to the clipboard" onclick="copyLinkToClickboard()" class="icon-clone pointer"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="loadMapData" style="display: none" class="dialog">
|
|
||||||
<div style="margin-bottom: .3em">Load map from</div>
|
|
||||||
<div>
|
|
||||||
<button onclick="mapToLoad.click()" data-tip="Load .map file from local disk">local disk</button>
|
|
||||||
<button onclick="loadFromDropbox()" data-tip="Load .map file from your Dropbox">Dropbox</button>
|
|
||||||
<button onclick="loadURL()" data-tip="Load .map file from URL (server should allow CORS)">URL</button>
|
|
||||||
<button onclick="quickLoad()" data-tip="Load map from browser storage (if saved before)">storage</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="saveTilesScreen" style="display: none" class="dialog">
|
<div id="saveTilesScreen" style="display: none" class="dialog">
|
||||||
<p style="font-style: italic">Map will be split into tiles and downloaded as a single zip file. Avoid saving to big images</p>
|
<p>Map will be split into tiles and downloaded as a single zip file. Avoid saving to big images</p>
|
||||||
<div data-tip="Number of columns" style="margin-bottom: .3em">
|
<div data-tip="Number of columns" style="margin-bottom: .3em">
|
||||||
<div class="label">Columns:</div>
|
<div class="label">Columns:</div>
|
||||||
<input id="tileColsInput" data-stored="tileCols" type="range" min=2 max=20 value=8 style="width: 11em">
|
<input id="tileColsInput" data-stored="tileCols" type="range" min=2 max=20 value=8 style="width: 11em">
|
||||||
|
|
@ -4265,11 +4268,13 @@
|
||||||
<script src="modules/ui/layers.js"></script>
|
<script src="modules/ui/layers.js"></script>
|
||||||
<script src="modules/ui/measurers.js"></script>
|
<script src="modules/ui/measurers.js"></script>
|
||||||
|
|
||||||
|
<script defer src="https://unpkg.com/dropbox@10.8.0/dist/Dropbox-sdk.min.js"></script>
|
||||||
<script defer src="modules/ui/general.js"></script>
|
<script defer src="modules/ui/general.js"></script>
|
||||||
<script defer src="modules/ui/options.js"></script>
|
<script defer src="modules/ui/options.js"></script>
|
||||||
<script defer src="modules/ui/style.js"></script>
|
<script defer src="modules/ui/style.js"></script>
|
||||||
<script defer src="modules/save.js"></script>
|
<script defer src="modules/save.js"></script>
|
||||||
<script defer src="modules/load.js"></script>
|
<script defer src="modules/load.js"></script>
|
||||||
|
<script defer src="modules/cloud.js"></script>
|
||||||
<script defer src="main.js"></script>
|
<script defer src="main.js"></script>
|
||||||
<script defer src="modules/relief-icons.js"></script>
|
<script defer src="modules/relief-icons.js"></script>
|
||||||
<script defer src="modules/ui/tools.js"></script>
|
<script defer src="modules/ui/tools.js"></script>
|
||||||
|
|
@ -4310,6 +4315,5 @@
|
||||||
<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="libs/pell.min.js"></script>
|
<script defer src="libs/pell.min.js"></script>
|
||||||
<script defer src="libs/jszip.min.js"></script>
|
<script defer src="libs/jszip.min.js"></script>
|
||||||
<script defer src="libs/dropins.min.js" id="dropboxjs" data-app-key="pdr9ae64ip0qno4"></script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
139
modules/cloud.js
Normal file
139
modules/cloud.js
Normal file
|
|
@ -0,0 +1,139 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cloud provider implementations (Dropbox only as now)
|
||||||
|
|
||||||
|
provider Interface:
|
||||||
|
|
||||||
|
name: name of the provider
|
||||||
|
async auth(): authenticate and get access tokens from provider
|
||||||
|
async save(filename): save map file to provider as filename
|
||||||
|
async load(filename): load filename from provider
|
||||||
|
async list(): list available filenames at provider
|
||||||
|
async getLink(filePath): get shareable link for file
|
||||||
|
restore(): restore access tokens from storage if possible
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
window.Cloud = (function () {
|
||||||
|
// helpers to use in providers for token handling
|
||||||
|
const lSKey = x => `auth-${x}`;
|
||||||
|
const setToken = (prov, key) => localStorage.setItem(lSKey(prov), key);
|
||||||
|
const getToken = prov => localStorage.getItem(lSKey(prov));
|
||||||
|
|
||||||
|
/**********************************************************/
|
||||||
|
/* Dropbox provider */
|
||||||
|
/**********************************************************/
|
||||||
|
|
||||||
|
const DBP = {
|
||||||
|
name: "dropbox",
|
||||||
|
clientId: "pdr9ae64ip0qno4",
|
||||||
|
authWindow: undefined,
|
||||||
|
token: null, // Access token
|
||||||
|
api: null,
|
||||||
|
|
||||||
|
restore() {
|
||||||
|
this.token = getToken(this.name);
|
||||||
|
if (this.token) this.connect(this.token);
|
||||||
|
},
|
||||||
|
|
||||||
|
async call(name, param) {
|
||||||
|
try {
|
||||||
|
return await this.api[name](param);
|
||||||
|
} catch (e) {
|
||||||
|
if (e.name !== "DropboxResponseError") throw e;
|
||||||
|
// retry with auth
|
||||||
|
await this.auth();
|
||||||
|
return await this.api[name](param);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
connect(token) {
|
||||||
|
const clientId = this.clientId;
|
||||||
|
const auth = new Dropbox.DropboxAuth({clientId});
|
||||||
|
auth.setAccessToken(token);
|
||||||
|
this.api = new Dropbox.Dropbox({auth});
|
||||||
|
},
|
||||||
|
|
||||||
|
async save(fileName, contents) {
|
||||||
|
if (!this.api) await this.auth();
|
||||||
|
const resp = this.call("filesUpload", {path: "/" + fileName, contents});
|
||||||
|
console.log("Dropbox response:", resp);
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
async load(path) {
|
||||||
|
if (!this.api) await this.auth();
|
||||||
|
const resp = await this.call("filesDownload", {path});
|
||||||
|
const blob = resp.result.fileBlob;
|
||||||
|
if (!blob) throw new Error("Invalid response from dropbox.");
|
||||||
|
return blob;
|
||||||
|
},
|
||||||
|
|
||||||
|
async list() {
|
||||||
|
if (!this.api) return null;
|
||||||
|
const resp = await this.call("filesListFolder", {path: ""});
|
||||||
|
return resp.result.entries.map(e => ({name: e.name, path: e.path_lower}));
|
||||||
|
},
|
||||||
|
|
||||||
|
auth() {
|
||||||
|
const url = window.location.origin + window.location.pathname + "dropbox.html";
|
||||||
|
this.authWindow = window.open(url, "auth", "width=640,height=480");
|
||||||
|
// child window expected to call
|
||||||
|
// window.opener.Cloud.providers.dropbox.setDropBoxToken (see below)
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const watchDog = () => {
|
||||||
|
this.authWindow.close();
|
||||||
|
reject(new Error("Timeout. No auth for dropbox."));
|
||||||
|
};
|
||||||
|
setTimeout(watchDog, 120 * 1000);
|
||||||
|
window.addEventListener("dropboxauth", e => {
|
||||||
|
clearTimeout(watchDog);
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
// Callback function for auth window.
|
||||||
|
setDropBoxToken(token) {
|
||||||
|
console.log("Access token got:", token);
|
||||||
|
setToken(this.name, token);
|
||||||
|
this.connect(token);
|
||||||
|
this.authWindow.close();
|
||||||
|
window.dispatchEvent(new Event("dropboxauth"));
|
||||||
|
},
|
||||||
|
|
||||||
|
async getLink(path) {
|
||||||
|
if (!this.api) await this.auth();
|
||||||
|
let resp;
|
||||||
|
|
||||||
|
// already exists?
|
||||||
|
resp = await this.call("sharingListSharedLinks", {path});
|
||||||
|
if (resp.result.links.length) return resp.result.links[0].url;
|
||||||
|
|
||||||
|
// create new
|
||||||
|
resp = await this.call("sharingCreateSharedLinkWithSettings", {
|
||||||
|
path,
|
||||||
|
settings: {
|
||||||
|
require_password: false,
|
||||||
|
audience: "public",
|
||||||
|
access: "viewer",
|
||||||
|
requested_visibility: "public",
|
||||||
|
allow_download: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log("dropbox link object:", resp.result);
|
||||||
|
return resp.result.url;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// register providers here:
|
||||||
|
const providers = {
|
||||||
|
dropbox: DBP
|
||||||
|
};
|
||||||
|
|
||||||
|
// restore all providers at startup
|
||||||
|
for (const p of Object.values(providers)) p.restore();
|
||||||
|
|
||||||
|
return {providers};
|
||||||
|
})();
|
||||||
|
|
@ -12,16 +12,35 @@ function quickLoad() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadFromDropbox() {
|
async function loadFromDropbox() {
|
||||||
const options = {
|
const mapPath = document.getElementById("loadFromDropboxSelect")?.value;
|
||||||
success: function (files) {
|
|
||||||
const url = files[0].link;
|
DEBUG && console.log("Loading map from Dropbox:", mapPath);
|
||||||
loadMapFromURL(url);
|
const blob = await Cloud.providers.dropbox.load(mapPath);
|
||||||
},
|
uploadMap(blob);
|
||||||
linkType: "direct",
|
}
|
||||||
extensions: [".map"]
|
|
||||||
};
|
async function createSharableDropboxLink() {
|
||||||
Dropbox.choose(options);
|
const mapFile = document.querySelector("#loadFromDropbox select").value;
|
||||||
|
const sharableLink = document.getElementById("sharableLink");
|
||||||
|
const sharableLinkContainer = document.getElementById("sharableLinkContainer");
|
||||||
|
let url;
|
||||||
|
try {
|
||||||
|
url = await Cloud.providers.dropbox.getLink(mapFile);
|
||||||
|
} catch {
|
||||||
|
tip("Dropbox API error. Can not create link.", true, "error", 2000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
|
|
||||||
|
|
@ -444,42 +444,19 @@ function dowloadMap() {
|
||||||
window.URL.revokeObjectURL(URL);
|
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");
|
if (customization) return tip("Map cannot be saved when edit mode is active, please exit the mode and retry", false, "error");
|
||||||
closeDialogs("#alert");
|
closeDialogs("#alert");
|
||||||
|
|
||||||
const mapData = getMapData();
|
const mapData = getMapData();
|
||||||
const URL = "data:text/plain; base64," + btoa(encodeURIComponent(mapData));
|
|
||||||
const filename = getFileName() + ".map";
|
const filename = getFileName() + ".map";
|
||||||
const options = {
|
try {
|
||||||
success: () => tip("Map is saved to your Dropbox", true, "success", 8000),
|
await Cloud.providers.dropbox.save(filename, mapData);
|
||||||
error: function (errorMessage) {
|
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);
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveGeoJSON_Cells() {
|
function saveGeoJSON_Cells() {
|
||||||
|
|
|
||||||
|
|
@ -663,7 +663,7 @@ function showSavePane() {
|
||||||
$("#saveMapData").dialog({
|
$("#saveMapData").dialog({
|
||||||
title: "Save map",
|
title: "Save map",
|
||||||
resizable: false,
|
resizable: false,
|
||||||
width: "27em",
|
width: "25em",
|
||||||
position: {my: "center", at: "center", of: "svg"},
|
position: {my: "center", at: "center", of: "svg"},
|
||||||
buttons: {
|
buttons: {
|
||||||
Close: function () {
|
Close: function () {
|
||||||
|
|
@ -695,11 +695,11 @@ function showExportPane() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function showLoadPane() {
|
async function showLoadPane() {
|
||||||
$("#loadMapData").dialog({
|
$("#loadMapData").dialog({
|
||||||
title: "Load map",
|
title: "Load map",
|
||||||
resizable: false,
|
resizable: false,
|
||||||
width: "22em",
|
width: "24em",
|
||||||
position: {my: "center", at: "center", of: "svg"},
|
position: {my: "center", at: "center", of: "svg"},
|
||||||
buttons: {
|
buttons: {
|
||||||
Close: function () {
|
Close: function () {
|
||||||
|
|
@ -707,6 +707,25 @@ function showLoadPane() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const loadFromDropboxButtons = document.getElementById("loadFromDropboxButtons");
|
||||||
|
const fileSelect = document.getElementById("loadFromDropboxSelect");
|
||||||
|
const files = await Cloud.providers.dropbox.list();
|
||||||
|
|
||||||
|
if (!files) {
|
||||||
|
loadFromDropboxButtons.style.display = "none";
|
||||||
|
fileSelect.innerHTML = `<option value="" disabled selected>Save files to Dropbox first</option>`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadFromDropboxButtons.style.display = "block";
|
||||||
|
fileSelect.innerHTML = "";
|
||||||
|
files.forEach(file => {
|
||||||
|
const opt = document.createElement("option");
|
||||||
|
opt.innerText = file.name;
|
||||||
|
opt.value = file.path;
|
||||||
|
fileSelect.appendChild(opt);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadURL() {
|
function loadURL() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue