Changed around line 1
+ const dropzone = document.getElementById('dropzone');
+ const fileInput = document.getElementById('file-input');
+ const progressContainer = document.getElementById('progress-container');
+ const progressBar = document.getElementById('progress-bar');
+ const shareSection = document.getElementById('share-section');
+ const shareUrl = document.getElementById('share-url');
+ const copyButton = document.getElementById('copy-button');
+
+ // Handle file drag and drop
+ dropzone.addEventListener('dragover', (e) => {
+ e.preventDefault();
+ dropzone.classList.add('dragover');
+ });
+
+ dropzone.addEventListener('dragleave', () => {
+ dropzone.classList.remove('dragover');
+ });
+
+ dropzone.addEventListener('drop', (e) => {
+ e.preventDefault();
+ dropzone.classList.remove('dragover');
+ handleFiles(e.dataTransfer.files);
+ });
+
+ // Handle file selection
+ fileInput.addEventListener('change', () => {
+ handleFiles(fileInput.files);
+ });
+
+ // Handle file upload
+ function handleFiles(files) {
+ if (files.length === 0) return;
+
+ const formData = new FormData();
+ for (const file of files) {
+ formData.append('files', file);
+ }
+
+ progressContainer.style.display = 'block';
+
+ const xhr = new XMLHttpRequest();
+ xhr.open('POST', '/upload', true);
+
+ xhr.upload.onprogress = (e) => {
+ if (e.lengthComputable) {
+ const percent = (e.loaded / e.total) * 100;
+ progressBar.style.width = `${percent}%`;
+ }
+ };
+
+ xhr.onload = () => {
+ if (xhr.status === 200) {
+ const response = JSON.parse(xhr.responseText);
+ shareUrl.value = response.downloadUrl;
+ shareSection.hidden = false;
+ progressContainer.style.display = 'none';
+ } else {
+ alert('Upload failed. Please try again.');
+ }
+ };
+
+ xhr.send(formData);
+ }
+
+ // Handle copy link
+ copyButton.addEventListener('click', () => {
+ shareUrl.select();
+ document.execCommand('copy');
+ copyButton.textContent = 'Copied!';
+ setTimeout(() => {
+ copyButton.textContent = 'Copy Link';
+ }, 2000);
+ });