const dropZone=document.getElementById("dropZone"),fileInput=document.getElementById("fileInput");function handleFiles(e){const n=new FormData;for(const o of e)n.append("file",o);let o=window.location.pathname;o+="/upload",fetch(o,{method:"POST",body:n}).then((e=>e.text())).then((e=>{window.location.reload()})).catch((e=>console.error("Error:",e)))}dropZone.addEventListener("dragover",(e=>{e.preventDefault(),dropZone.classList.add("drag-over")})),dropZone.addEventListener("dragleave",(()=>{dropZone.classList.remove("drag-over")})),dropZone.addEventListener("drop",(e=>{e.preventDefault(),dropZone.classList.remove("drag-over");handleFiles(e.dataTransfer.files)})),dropZone.addEventListener("click",(()=>{fileInput.click()})),fileInput.addEventListener("change",(()=>{handleFiles(fileInput.files)}));