fix fonts load error and reword save dialog text

This commit is contained in:
Azgaar 2021-09-08 17:30:32 +03:00
parent d19899f0fc
commit 9adfe70850
4 changed files with 24 additions and 26 deletions

View file

@ -3475,11 +3475,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">
@ -3487,9 +3485,9 @@
<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> </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>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>
<div id="loadMapData" style="display: none" class="dialog"> <div id="loadMapData" style="display: none" class="dialog">
@ -3499,12 +3497,11 @@
<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"> <div id="loadFromDropbox" style="margin-bottom:.3em">
<p>From your Dropbox account:</p> <span>From your Dropbox account</span>
<select style="margin-bottom:.3em"> <select id="loadFromDropboxSelect" style="margin-bottom:.3em"></select>
</select>
<button onclick="loadFromDropbox()" data-tip="Load .map file from your Dropbox">Open</button> <button onclick="loadFromDropbox()" data-tip="Load .map file from your Dropbox">Open</button>
<button onclick="createSharableDropboxLink()" data-tip="Select .map file on dropbox and share a sharable link">Create link</button> <button onclick="createSharableDropboxLink()" data-tip="Select file and create a link to share with your friends">Create link</button>
<div style="margin-top: .3em"> <div style="margin-top: .3em">
<div id="sharableLinkContainer" style="display: none"> <div id="sharableLinkContainer" style="display: none">
@ -3516,7 +3513,7 @@
</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">

View file

@ -61,7 +61,7 @@ function convertFontToDataURI(url) {
style.innerHTML = text; style.innerHTML = text;
document.head.appendChild(style); document.head.appendChild(style);
const styleSheet = document.styleSheets.find(sheet => sheet.ownerNode === style); const styleSheet = Array.from(document.styleSheets).find(sheet => sheet.ownerNode === style);
const FontRule = rule => { const FontRule = rule => {
const src = rule.style.getPropertyValue("src"); const src = rule.style.getPropertyValue("src");

View file

@ -12,9 +12,10 @@ function quickLoad() {
}); });
} }
async function loadFromDropbox(fileName) { async function loadFromDropbox() {
const map = document.querySelector("#loadFromDropbox select").value; const mapPath = document.getElementById("#loadFromDropboxSelect")?.value;
console.log('loading dropbox map', map);
DEBUG && console.log("Loading map from Dropbox:", mapPath);
const blob = await Cloud.providers.dropbox.load(map); const blob = await Cloud.providers.dropbox.load(map);
uploadMap(blob); uploadMap(blob);
} }
@ -23,18 +24,18 @@ 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 let url;
try { try {
url = await Cloud.providers.dropbox.getLink(mapFile); url = await Cloud.providers.dropbox.getLink(mapFile);
} catch { } catch {
tip("Dropbox API error. Can not create link.", true, "error", 2000); tip("Dropbox API error. Can not create link.", true, "error", 2000);
return return;
} }
const fmg = window.location.href.split("?")[0]; const fmg = window.location.href.split("?")[0];
const reallink = `${fmg}?maplink=${url}`; const reallink = `${fmg}?maplink=${url}`;
// voodoo magic required by the yellow god of CORS // voodoo magic required by the yellow god of CORS
const link = reallink.replace('www.dropbox.com/s/', 'dl.dropboxusercontent.com/1/view/') const link = reallink.replace("www.dropbox.com/s/", "dl.dropboxusercontent.com/1/view/");
const shortLink = link.slice(0, 50) + "..."; const shortLink = link.slice(0, 50) + "...";
sharableLinkContainer.style.display = "block"; sharableLinkContainer.style.display = "block";

View file

@ -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 () {
@ -715,7 +715,7 @@ async function showLoadPane() {
if (!files) return; if (!files) return;
while (dpf.firstChild) dpf.removeChild(dpf.firstChild); while (dpf.firstChild) dpf.removeChild(dpf.firstChild);
files.forEach(f => { files.forEach(f => {
const opt = document.createElement('option'); const opt = document.createElement("option");
opt.innerText = f.name; opt.innerText = f.name;
opt.value = f.path; opt.value = f.path;
dpf.appendChild(opt); dpf.appendChild(opt);