Remove usage of jszip

This commit is contained in:
Booteille 2024-11-13 19:19:04 +01:00
parent 59e8a34882
commit 9864439b70
No known key found for this signature in database
GPG Key ID: 0AB6C6CA01272646
3 changed files with 13 additions and 16 deletions

View File

@ -187,23 +187,23 @@ const updateProgress = (lufiFile) => {
document.getElementById("pbt").innerHTML = `${percent}%`;
};
const showZipContent = (blob) => {
const showZipContent = (zipFile) => {
const showZipContentDOM = document.getElementById("showZipContent");
const showZipContentDOMListener = () => {
JSZip.loadAsync(blob).then((zip) => {
lufi.decompress(zipFile).andThen((files) => {
const newElement = document.createElement("div");
let innerHTML = `<h3>${i18n.zipContent}</h3><ul>`;
zip.forEach(function (_relativePath, zipEntry) {
files.forEach((file) => {
innerHTML += `<li>
${escapeHtml(zipEntry.name)}
(${filesize(zipEntry._data.uncompressedSize, {
${escapeHtml(file.name)}
(${filesize(file.size, {
base: 10,
})})
<a href="#"
download="${escapeHtml(zipEntry.name)}"
download="${escapeHtml(file.name)}"
class="download-zip-content"
title="${i18n.download}">
<i class="mdi-file-file-download"></i>
@ -217,17 +217,16 @@ const showZipContent = (blob) => {
pbd.append(newElement);
console.debug();
document.querySelectorAll(".download-zip-content").forEach((element) => {
const elementListener = (e) => {
e.preventDefault();
var filename = element.getAttribute("download");
zip.files[filename].async("blob").then((blob) => {
const filename = element.getAttribute("download");
const file = files.find((file) => file.name === filename);
element.removeEventListener("click", elementListener);
element.setAttribute("href", URL.createObjectURL(blob));
element.setAttribute("href", URL.createObjectURL(file));
element.click();
});
};
element.addEventListener("click", elementListener);

View File

@ -161,7 +161,6 @@
%= javascript '/partial/index.js'
% }
%= javascript '/js/filesize.min.js'
%= javascript '/js/jszip.min.js'
%= javascript '/js/lufi-notifications.js'
%= javascript '/js/lufi-up.js', type => 'module'
% }

View File

@ -43,7 +43,6 @@
</div>
%= javascript '/partial/render.js?nbslices='.stash('f')->nbslices.'&file='.stash('f')->short
%= javascript '/js/filesize.min.js'
%= javascript '/js/jszip.min.js'
%= javascript '/js/lufi-notifications.js'
%= javascript '/js/lufi-down.js', type => 'module'
% }