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

Function ensureZipProgressUI

public/js/fileActions.js:853–927  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

851
852 // Ensure a progress UI exists in the modal
853 function ensureZipProgressUI() {
854 const modalEl = document.getElementById("downloadProgressModal");
855 if (!modalEl) {
856 // really shouldn't happen, but fall back to body
857 console.warn("downloadProgressModal not found; falling back to document.body");
858 }
859 // Prefer a dedicated content node inside the modal
860 let host =
861 (modalEl && modalEl.querySelector("#downloadProgressContent")) ||
862 (modalEl && modalEl.querySelector(".modal-body")) ||
863 (modalEl && modalEl.querySelector(".rise-modal-body")) ||
864 (modalEl && modalEl.querySelector(".modal-content")) ||
865 (modalEl && modalEl.querySelector(".content")) ||
866 null;
867
868 // If no suitable container, create one inside the modal
869 if (!host) {
870 host = document.createElement("div");
871 host.id = "downloadProgressContent";
872 (modalEl || document.body).appendChild(host);
873 }
874
875 // Helper: ensure/move an element with given id into host
876 function ensureInHost(id, tag, init) {
877 let el = document.getElementById(id);
878 if (el && el.parentElement !== host) host.appendChild(el); // move if it exists elsewhere
879 if (!el) {
880 el = document.createElement(tag);
881 el.id = id;
882 if (typeof init === "function") init(el);
883 host.appendChild(el);
884 }
885 return el;
886 }
887
888 // Title
889 const title = ensureInHost("downloadProgressTitle", "div", (el) => {
890 el.style.marginBottom = "8px";
891 el.textContent = "Preparing…";
892 });
893
894 // Progress bar (native <progress>)
895 const bar = (function () {
896 let el = document.getElementById("downloadProgressBar");
897 if (el && el.parentElement !== host) host.appendChild(el); // move into modal
898 if (!el) {
899 el = document.createElement("progress");
900 el.id = "downloadProgressBar";
901 host.appendChild(el);
902 }
903 el.max = 100;
904 el.value = 0;
905 el.style.display = ""; // override any inline display:none
906 el.style.width = "100%";
907 el.style.height = "1.1em";
908 return el;
909 })();
910

Callers 1

fileActions.jsFile · 0.85

Calls 1

ensureInHostFunction · 0.85

Tested by

no test coverage detected