Adding gzip compression for improving storage use and backward compatibility. (#984)

* Basic gzip an gunzip on load and save.

* refactor file save type to .gz and update the data in ui.

---------

Co-authored-by: Azgaar <maxganiev@yandex.com>
This commit is contained in:
Efruz Yıldırır 2023-08-15 11:26:01 +03:00 committed by GitHub
parent 5fba7d60f4
commit ef24e3ea1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 111 additions and 68 deletions

10
main.js
View file

@ -270,7 +270,7 @@ async function checkLoadParameters() {
const url = new URL(window.location.href);
const params = url.searchParams;
// of there is a valid maplink, try to load .map file from URL
// of there is a valid maplink, try to load .gz/.map file from URL
if (params.get("maplink")) {
WARN && console.warn("Load map from URL");
const maplink = params.get("maplink");
@ -574,9 +574,9 @@ void (function addDragToUpload() {
overlay.style.display = "none";
if (e.dataTransfer.items == null || e.dataTransfer.items.length !== 1) return; // no files or more than one
const file = e.dataTransfer.items[0].getAsFile();
if (file.name.indexOf(".map") == -1) {
// not a .map file
alertMessage.innerHTML = "Please upload a <b>.map</b> file you have previously downloaded";
if (!file.name.endsWith(".map") && !file.name.endsWith(".gz")) {
// not a .gz/.map file
alertMessage.innerHTML = "Please upload a <b>.gz or .map</b> file you have previously downloaded";
$("#alert").dialog({
resizable: false,
title: "Invalid file format",
@ -596,7 +596,7 @@ void (function addDragToUpload() {
if (closeDialogs) closeDialogs();
uploadMap(file, () => {
overlay.style.display = "none";
overlay.innerHTML = "Drop a .map file to open";
overlay.innerHTML = "Drop a .gz or .map file to open";
});
});
})();