Remove usage of jszip
This commit is contained in:
parent
59e8a34882
commit
9864439b70
|
@ -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) => {
|
||||
element.removeEventListener("click", elementListener);
|
||||
element.setAttribute("href", URL.createObjectURL(blob));
|
||||
element.click();
|
||||
});
|
||||
|
||||
const filename = element.getAttribute("download");
|
||||
const file = files.find((file) => file.name === filename);
|
||||
|
||||
element.removeEventListener("click", elementListener);
|
||||
element.setAttribute("href", URL.createObjectURL(file));
|
||||
element.click();
|
||||
};
|
||||
element.addEventListener("click", elementListener);
|
||||
|
||||
|
|
|
@ -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'
|
||||
% }
|
||||
|
|
|
@ -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'
|
||||
% }
|
||||
|
|
Loading…
Reference in New Issue