This commit is contained in:
Azgaar 2023-08-16 11:56:36 +04:00
parent 2e0a74f34d
commit 168656c864
6 changed files with 30 additions and 30 deletions

View file

@ -2353,8 +2353,8 @@
<div id="sticked"> <div id="sticked">
<button id="newMapButton" data-tip="Generate a new map based on options" data-shortcut="F2">New Map</button> <button id="newMapButton" data-tip="Generate a new map based on options" data-shortcut="F2">New Map</button>
<button id="exportButton" data-tip="Select format to download image or export map data">Export</button> <button id="exportButton" data-tip="Select format to download image or export map data">Export</button>
<button id="saveButton" data-tip="Save fully-functional map in .gz format">Save</button> <button id="saveButton" data-tip="Save fully-functional map file">Save</button>
<button id="loadButton" data-tip="Load fully-functional map (.gz or .map formats)">Load</button> <button id="loadButton" data-tip="Load fully-functional map (.map or .gz formats)">Load</button>
<button id="zoomReset" data-tip="Reset map zoom" data-shortcut="0 (zero)">Reset Zoom</button> <button id="zoomReset" data-tip="Reset map zoom" data-shortcut="0 (zero)">Reset Zoom</button>
</div> </div>
</div> </div>
@ -5919,7 +5919,7 @@
</button> </button>
</div> </div>
<p> <p>
Maps are saved in <i>.gz</i> format, that can be loaded back via the <i>Load</i> in menu. There is no way to 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 save files on your machine or cloud storage as backups. restore the progress if file is lost. Please keep old save files on your machine or cloud storage as backups.
</p> </p>
</div> </div>
@ -5927,12 +5927,12 @@
<div id="loadMapData" style="display: none" class="dialog"> <div id="loadMapData" style="display: none" class="dialog">
<div> <div>
<strong>Load map from</strong> <strong>Load map from</strong>
<button onclick="mapToLoad.click()" data-tip="Load map file (.gz or .map) from your local disk"> <button onclick="mapToLoad.click()" data-tip="Load map file (.map or .gz) from your local disk">
machine machine
</button> </button>
<button <button
onclick="loadURL()" onclick="loadURL()"
data-tip="Load map file (.gz or .map) file from URL. Note that the server should allow CORS" data-tip="Load map file (.map or .gz) file from URL. Note that the server should allow CORS"
> >
URL URL
</button> </button>
@ -5955,7 +5955,7 @@
<select id="loadFromDropboxSelect" style="width: 22em"></select> <select id="loadFromDropboxSelect" style="width: 22em"></select>
<div id="loadFromDropboxButtons" style="margin-bottom: 0.6em"> <div id="loadFromDropboxButtons" style="margin-bottom: 0.6em">
<button onclick="loadFromDropbox()" data-tip="Load map file (.gz or .map) from your Dropbox">Load</button> <button onclick="loadFromDropbox()" data-tip="Load map file (.map or .gz) from your Dropbox">Load</button>
<button <button
onclick="createSharableDropboxLink()" onclick="createSharableDropboxLink()"
data-tip="Select file and create a link to share with your friends" data-tip="Select file and create a link to share with your friends"
@ -7992,8 +7992,8 @@
<script src="modules/ui/stylePresets.js?v=1.89.11"></script> <script src="modules/ui/stylePresets.js?v=1.89.11"></script>
<script src="modules/ui/general.js?v=1.93.01"></script> <script src="modules/ui/general.js?v=1.93.01"></script>
<script src="modules/ui/options.js?v=1.93.00"></script> <script src="modules/ui/options.js?v=1.93.02"></script>
<script src="main.js?v=1.93.00"></script> <script src="main.js?v=1.93.02"></script>
<script defer src="modules/relief-icons.js"></script> <script defer src="modules/relief-icons.js"></script>
<script defer src="modules/ui/style.js"></script> <script defer src="modules/ui/style.js"></script>
@ -8034,8 +8034,8 @@
<script defer src="modules/coa-renderer.js?v=1.91.00"></script> <script defer src="modules/coa-renderer.js?v=1.91.00"></script>
<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.00"></script> <script defer src="modules/io/save.js?v=1.93.02"></script>
<script defer src="modules/io/load.js?v=1.93.00"></script> <script defer src="modules/io/load.js?v=1.93.02"></script>
<script defer src="modules/io/cloud.js"></script> <script defer src="modules/io/cloud.js"></script>
<script defer src="modules/io/export.js?v=1.89.36"></script> <script defer src="modules/io/export.js?v=1.89.36"></script>
<script defer src="modules/io/formats.js"></script> <script defer src="modules/io/formats.js"></script>

View file

@ -270,7 +270,7 @@ async function checkLoadParameters() {
const url = new URL(window.location.href); const url = new URL(window.location.href);
const params = url.searchParams; const params = url.searchParams;
// of there is a valid maplink, try to load .gz/.map file from URL // of there is a valid maplink, try to load .map/.gz file from URL
if (params.get("maplink")) { if (params.get("maplink")) {
WARN && console.warn("Load map from URL"); WARN && console.warn("Load map from URL");
const maplink = params.get("maplink"); const maplink = params.get("maplink");
@ -580,7 +580,7 @@ void (function addDragToUpload() {
if (!file.name.endsWith(".map") && !file.name.endsWith(".gz")) { if (!file.name.endsWith(".map") && !file.name.endsWith(".gz")) {
alertMessage.innerHTML = alertMessage.innerHTML =
"Please upload a map file (<i>.gz</i> or <i>.map</i> formats) you have previously downloaded"; "Please upload a map file (<i>.map</i> or <i>.gz</i> formats) you have previously downloaded";
$("#alert").dialog({ $("#alert").dialog({
resizable: false, resizable: false,
title: "Invalid file format", title: "Invalid file format",

View file

@ -1,5 +1,5 @@
"use strict"; "use strict";
// Functions to load and parse .gz/.map files // Functions to load and parse .map/.gz files
async function quickLoad() { async function quickLoad() {
const blob = await ldb.get("lastMap"); const blob = await ldb.get("lastMap");
if (blob) loadMapPrompt(blob); if (blob) loadMapPrompt(blob);

View file

@ -6,12 +6,12 @@ async function saveMap(method) {
closeDialogs("#alert"); closeDialogs("#alert");
try { try {
const compressedMapData = await compressData(prepareMapData()); const mapData = prepareMapData();
const filename = getFileName() + ".gz"; const filename = getFileName() + ".map";
saveToStorage(compressedMapData, method === "storage"); // any method saves to indexedDB saveToStorage(mapData, method === "storage"); // any method saves to indexedDB
if (method === "machine") saveToMachine(compressedMapData, filename); if (method === "machine") saveToMachine(mapData, filename);
if (method === "dropbox") saveToDropbox(compressedMapData, filename); if (method === "dropbox") saveToDropbox(mapData, filename);
} catch (error) { } catch (error) {
ERROR && console.error(error); ERROR && console.error(error);
alertMessage.innerHTML = /* html */ `An error is occured on map saving. If the issue persists, please copy the message below and report it on ${link( alertMessage.innerHTML = /* html */ `An error is occured on map saving. If the issue persists, please copy the message below and report it on ${link(
@ -153,15 +153,15 @@ function prepareMapData() {
} }
// save map file to indexedDB // save map file to indexedDB
async function saveToStorage(compressedMapData, showTip = false) { async function saveToStorage(mapData, showTip = false) {
const blob = new Blob([compressedMapData], {type: "text/plain"}); const blob = new Blob([mapData], {type: "text/plain"});
await ldb.set("lastMap", blob); await ldb.set("lastMap", blob);
showTip && tip("Map is saved to the browser storage", false, "success"); showTip && tip("Map is saved to the browser storage", false, "success");
} }
// download .gz file // download map file
function saveToMachine(compressedMapData, filename) { function saveToMachine(mapData, filename) {
const blob = new Blob([compressedMapData], {type: "text/plain"}); const blob = new Blob([mapData], {type: "text/plain"});
const URL = window.URL.createObjectURL(blob); const URL = window.URL.createObjectURL(blob);
const link = document.createElement("a"); const link = document.createElement("a");
@ -173,8 +173,8 @@ function saveToMachine(compressedMapData, filename) {
window.URL.revokeObjectURL(URL); window.URL.revokeObjectURL(URL);
} }
async function saveToDropbox(compressedMapData, filename) { async function saveToDropbox(mapData, filename) {
await Cloud.providers.dropbox.save(filename, compressedMapData); await Cloud.providers.dropbox.save(filename, mapData);
tip("Map is saved to your Dropbox", true, "success", 8000); tip("Map is saved to your Dropbox", true, "success", 8000);
} }
@ -192,8 +192,8 @@ async function initiateAutosave() {
try { try {
tip("Autosave: saving map...", false, "warning", 3000); tip("Autosave: saving map...", false, "warning", 3000);
const compressedMapData = await compressData(prepareMapData()); const mapData = prepareMapData();
await saveToStorage(compressedMapData); await saveToStorage(mapData);
tip("Autosave: map is saved", false, "success", 2000); tip("Autosave: map is saved", false, "success", 2000);
lastSavedAt = Date.now(); lastSavedAt = Date.now();
@ -205,6 +205,7 @@ async function initiateAutosave() {
setInterval(autosave, MINUTE / 2); setInterval(autosave, MINUTE / 2);
} }
// TODO: unused code
async function compressData(uncompressedData) { async function compressData(uncompressedData) {
const compressedStream = new Blob([uncompressedData]).stream().pipeThrough(new CompressionStream("gzip")); const compressedStream = new Blob([uncompressedData]).stream().pipeThrough(new CompressionStream("gzip"));

View file

@ -845,7 +845,7 @@ async function connectToDropbox() {
function loadURL() { function loadURL() {
const pattern = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/; const pattern = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
const inner = `Provide URL to map file: const inner = `Provide URL to map file:
<input id="mapURL" type="url" style="width: 24em" placeholder="https://e-cloud.com/test.gz"> <input id="mapURL" type="url" style="width: 24em" placeholder="https://e-cloud.com/test.map">
<br><i>Please note server should allow CORS for file to be loaded. If CORS is not allowed, save file to Dropbox and provide a direct link</i>`; <br><i>Please note server should allow CORS for file to be loaded. If CORS is not allowed, save file to Dropbox and provide a direct link</i>`;
alertMessage.innerHTML = inner; alertMessage.innerHTML = inner;
$("#alert").dialog({ $("#alert").dialog({

View file

@ -1,7 +1,7 @@
"use strict"; "use strict";
// version and caching control // version and caching control
const version = "1.93.01"; // generator version, update each time const version = "1.93.02"; // generator version, update each time
{ {
document.title += " v" + version; document.title += " v" + version;
@ -29,7 +29,6 @@ const version = "1.93.01"; // generator version, update each time
<ul> <ul>
<strong>Latest changes:</strong> <strong>Latest changes:</strong>
<li>Auto-load of the last saved map is now optional (see <i>Onload behavior</i> in Options)</li> <li>Auto-load of the last saved map is now optional (see <i>Onload behavior</i> in Options)</li>
<li>Save files compression (file extension is changed to <i>.gz</i>). Old <i>.map</i> files are still supported</li>
<li>New label placement algorithm for states</li> <li>New label placement algorithm for states</li>
<li>North and South Poles temperature can be set independently</li> <li>North and South Poles temperature can be set independently</li>
<li>More than 70 new heraldic charges</li> <li>More than 70 new heraldic charges</li>