reword dropbox file load select

This commit is contained in:
Azgaar 2021-09-08 17:48:48 +03:00
parent 9adfe70850
commit 21d9eb7d21
2 changed files with 25 additions and 16 deletions

View file

@ -3491,17 +3491,20 @@
</div>
<div id="loadMapData" style="display: none" class="dialog">
<div style="margin-bottom: .3em">Load map from</div>
<div>
<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" style="margin-bottom:.3em">
<span>From your Dropbox account</span>
<select id="loadFromDropboxSelect" style="margin-bottom:.3em"></select>
<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 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">

View file

@ -699,7 +699,7 @@ async function showLoadPane() {
$("#loadMapData").dialog({
title: "Load map",
resizable: false,
width: "22em",
width: "24em",
position: {my: "center", at: "center", of: "svg"},
buttons: {
Close: function () {
@ -708,17 +708,23 @@ async function showLoadPane() {
}
});
const dpx = document.getElementById("loadFromDropbox");
const dpf = dpx.querySelector("select");
const loadFromDropboxButtons = document.getElementById("loadFromDropboxButtons");
const fileSelect = document.getElementById("loadFromDropboxSelect");
const files = await Cloud.providers.dropbox.list();
dpx.style.display = files ? "block" : "none";
if (!files) return;
while (dpf.firstChild) dpf.removeChild(dpf.firstChild);
files.forEach(f => {
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 = f.name;
opt.value = f.path;
dpf.appendChild(opt);
opt.innerText = file.name;
opt.value = file.path;
fileSelect.appendChild(opt);
});
}