Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ const dropZone = document.getElementById('dropZone');
+ const fileInput = document.getElementById('fileInput');
+ const uploadList = document.getElementById('uploadList');
+ const filesList = document.getElementById('filesList');
+ const menuToggle = document.querySelector('.menu-toggle');
+ const navLinks = document.querySelector('.nav-links');
+
+ // Mobile menu toggle
+ menuToggle.addEventListener('click', () => {
+ navLinks.classList.toggle('active');
+ });
+
+ // Drag and drop functionality
+ 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);
+ });
+
+ fileInput.addEventListener('change', () => {
+ handleFiles(fileInput.files);
+ });
+
+ function handleFiles(files) {
+ Array.from(files).forEach(file => {
+ const reader = new FileReader();
+ reader.onload = () => {
+ addFileToList(file);
+ };
+ reader.readAsDataURL(file);
+ });
+ }
+
+ function addFileToList(file) {
+ const fileDiv = document.createElement('div');
+ fileDiv.className = 'file-item';
+ fileDiv.innerHTML = `
+ ${file.name}
+ ${formatFileSize(file.size)}
+ Share
+ `;
+ filesList.appendChild(fileDiv);
+ }
+
+ function formatFileSize(bytes) {
+ if (bytes === 0) return '0 Bytes';
+ const k = 1024;
+ const sizes = ['Bytes', 'KB', 'MB', 'GB'];
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
+ }
+ });