diff --git a/public/index.html b/public/index.html index a6a9e0e..779f4ad 100644 --- a/public/index.html +++ b/public/index.html @@ -11,6 +11,7 @@ + diff --git a/public/js/index.js b/public/js/index.js index ebc82b8..103e6e2 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -152,49 +152,6 @@ socket.on("successful-upload", () => { uploadStatusEl.textContent = "Upload succeeded!"; }); -// INFO-MODAL LOGIC -const aboutButton = document.getElementById("about-button"); -const modalOverlay = document.getElementById("modal-overlay"); -const modalContent = document.getElementById("modal-content"); -const modalClose = document.getElementById("modal-close"); - -function show_modal_with(content) { - modalOverlay.classList.remove("hidden"); - modalContent.innerHTML = ""; - modalContent.appendChild(content); - modalOverlay.focus(); -} - -// open modal -aboutButton.addEventListener("click", () => { - show_modal_with(about.content.cloneNode(true)); -}); - -// close modal via “×” button -modalClose.addEventListener("click", () => { - modalOverlay.classList.add("hidden"); -}); - -// also close if you click outside the white box -modalOverlay.addEventListener("click", (e) => { - if (e.target === modalOverlay) { - modalOverlay.classList.add("hidden"); - } -}); - -modalOverlay.addEventListener("keydown", (e) => { - if (e.key === "Escape") { - modalOverlay.classList.add("hidden"); - console.log("hiding"); - } -}); - -["download", "upload", "results"].forEach((section) => { - window[`info-${section}-btn`].addEventListener("click", () => { - show_modal_with(window[`info-${section}`].content.cloneNode(true)); - }); -}); - document.getElementById("request-status").onclick = async () => { if (!uuid.reportValidity()) return; const res = await fetch(`/answers/status/${uuid.value}`, { diff --git a/public/js/modal.js b/public/js/modal.js new file mode 100644 index 0000000..00eed61 --- /dev/null +++ b/public/js/modal.js @@ -0,0 +1,42 @@ +// INFO-MODAL LOGIC +const aboutButton = document.getElementById("about-button"); +const modalOverlay = document.getElementById("modal-overlay"); +const modalContent = document.getElementById("modal-content"); +const modalClose = document.getElementById("modal-close"); + +function show_modal_with(content) { + modalOverlay.classList.remove("hidden"); + modalContent.innerHTML = ""; + modalContent.appendChild(content); + modalOverlay.focus(); +} + +// open modal +aboutButton.addEventListener("click", () => { + show_modal_with(about.content.cloneNode(true)); +}); + +// close modal via “×” button +modalClose.addEventListener("click", () => { + modalOverlay.classList.add("hidden"); +}); + +// also close if you click outside the white box +modalOverlay.addEventListener("click", (e) => { + if (e.target === modalOverlay) { + modalOverlay.classList.add("hidden"); + } +}); + +modalOverlay.addEventListener("keydown", (e) => { + if (e.key === "Escape") { + modalOverlay.classList.add("hidden"); + console.log("hiding"); + } +}); + +["download", "upload", "results"].forEach((section) => { + window[`info-${section}-btn`].addEventListener("click", () => { + show_modal_with(window[`info-${section}`].content.cloneNode(true)); + }); +});