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>
<div id="loadMapData" style="display: none" class="dialog"> <div id="loadMapData" style="display: none" class="dialog">
<div style="margin-bottom: .3em">Load map from</div>
<div> <div>
<strong>Load map from</strong>
<button onclick="mapToLoad.click()" data-tip="Load .map file from local disk">local disk</button> <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="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> <button onclick="quickLoad()" data-tip="Load map from browser storage (if saved before)">storage</button>
</div> </div>
<div id="loadFromDropbox" style="margin-bottom:.3em"> <div id="loadFromDropbox">
<span>From your Dropbox account</span> <p style="margin-bottom: .3em">From your Dropbox account</p>
<select id="loadFromDropboxSelect" style="margin-bottom:.3em"></select> <select id="loadFromDropboxSelect" style="width: 22em"></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="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 style="margin-top: .3em">
<div id="sharableLinkContainer" style="display: none"> <div id="sharableLinkContainer" style="display: none">

View file

@ -699,7 +699,7 @@ 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 () {
@ -708,17 +708,23 @@ async function showLoadPane() {
} }
}); });
const dpx = document.getElementById("loadFromDropbox"); const loadFromDropboxButtons = document.getElementById("loadFromDropboxButtons");
const dpf = dpx.querySelector("select"); const fileSelect = document.getElementById("loadFromDropboxSelect");
const files = await Cloud.providers.dropbox.list(); const files = await Cloud.providers.dropbox.list();
dpx.style.display = files ? "block" : "none";
if (!files) return; if (!files) {
while (dpf.firstChild) dpf.removeChild(dpf.firstChild); loadFromDropboxButtons.style.display = "none";
files.forEach(f => { 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"); const opt = document.createElement("option");
opt.innerText = f.name; opt.innerText = file.name;
opt.value = f.path; opt.value = file.path;
dpf.appendChild(opt); fileSelect.appendChild(opt);
}); });
} }