MCPcopy Create free account
hub / github.com/error311/FileRise / handleExtractZipSelected

Function handleExtractZipSelected

public/js/fileActions.js:703–776  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

701}
702
703export function handleExtractZipSelected(e) {
704 if (e) {
705 e.preventDefault();
706 e.stopImmediatePropagation();
707 }
708 const checkboxes = getActiveSelectedFileCheckboxes();
709 if (!checkboxes.length) {
710 showToast(t('no_files_selected'), 'warning');
711 return;
712 }
713 const archiveFiles = Array.from(checkboxes)
714 .map(chk => chk.value)
715 .filter(name => isArchiveFileName(name));
716 if (!archiveFiles.length) {
717 showToast(t('no_archive_files_selected'), 'warning');
718 return;
719 }
720
721 // Prepare and show the spinner-only modal
722 const modal = document.getElementById("downloadProgressModal");
723 const titleEl = document.getElementById("downloadProgressTitle");
724 const spinner = modal.querySelector(".download-spinner");
725 const progressBar = document.getElementById("downloadProgressBar");
726 const progressPct = document.getElementById("downloadProgressPercent");
727
728 if (titleEl) titleEl.textContent = t('extracting_files');
729 if (spinner) spinner.style.display = "inline-block";
730 if (progressBar) progressBar.style.display = "none";
731 if (progressPct) progressPct.style.display = "none";
732
733 modal.style.display = "block";
734
735 fetch("/api/file/extractZip.php", {
736 method: "POST",
737 credentials: "include",
738 headers: {
739 "Content-Type": "application/json",
740 "X-CSRF-Token": window.csrfToken
741 },
742 body: JSON.stringify({
743 folder: window.currentFolder || "root",
744 files: archiveFiles
745 })
746 })
747 .then(response => response.json())
748 .then(data => {
749 modal.style.display = "none";
750 const extracted = Array.isArray(data.extractedFiles) ? data.extractedFiles : [];
751 const extractedMsg = extracted.length
752 ? t('extract_result_files', { files: extracted.join(", ") })
753 : t('extract_result_default');
754 const warning = (data && typeof data.warning === "string" && data.warning.trim()) ? data.warning.trim() : "";
755
756 if (data.success) {
757 if (warning) {
758 showToast(t('extract_result_warning', { result: extractedMsg, warning }), 'warning');
759 } else {
760 showToast(extractedMsg, 'success');

Callers 1

menuClickDelegateFunction · 0.85

Calls 5

tFunction · 0.85
isArchiveFileNameFunction · 0.85
loadFileListFunction · 0.85
showToastFunction · 0.70

Tested by

no test coverage detected