create a fully functional beautful and responsive file manager using js,html and css and…
- User
create a fully functional beautful and responsive file manager using js,html and css and provide a single .html file
Assistant
Responsive File Manager
Here's a complete, self-contained file manager in a single HTML file. It includes file browsing, folder navigation, file previews, and a responsive design.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Responsive File Manager</title> <style> :root { --primary-color: #4a6fa5; --secondary-color: #166088; --accent-color: #4fc3f7; --text-color: #333; --light-gray: #f5f5f5; --border-color: #ddd; --hover-color: #f0f0f0; --shadow: 0 2px 10px rgba(0, 0, 0, 0.1); } * { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } body { background-color: #f8f9fa; color: var(--text-color); line-height: 1.6; padding: 20px; } .container { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; height: calc(100vh - 40px); background-color: white; border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; } .header { background-color: var(--primary-color); color: white; padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; } .header h1 { font-size: 1.5rem; margin-right: 15px; } .breadcrumb { display: flex; align-items: center; flex-wrap: wrap; font-size: 0.9rem; } .breadcrumb span { margin: 0 5px; } .breadcrumb a { color: white; text-decoration: none; transition: opacity 0.2s; } .breadcrumb a:hover { opacity: 0.8; } .controls { display: flex; gap: 10px; margin-top: 10px; width: 100%; padding: 0 20px 10px; } .search-box { flex: 1; padding: 8px 15px; border: 1px solid var(--border-color); border-radius: 5px; font-size: 0.9rem; } .btn { padding: 8px 15px; border: none; border-radius: 5px; background-color: var(--primary-color); color: white; cursor: pointer; font-size: 0.9rem; transition: background-color 0.2s; } .btn:hover { background-color: var(--secondary-color); } .btn-secondary { background-color: var(--light-gray); color: var(--text-color); } .btn-secondary:hover { background-color: #e0e0e0; } .main-content { display: flex; flex: 1; overflow: hidden; } .sidebar { width: 250px; background-color: var(--light-gray); border-right: 1px solid var(--border-color); padding: 15px; overflow-y: auto; } .sidebar h3 { margin-bottom: 15px; font-size: 1rem; color: var(--secondary-color); } .sidebar ul { list-style: none; } .sidebar li { padding: 8px 10px; border-radius: 4px; margin-bottom: 5px; cursor: pointer; transition: background-color 0.2s; } .sidebar li:hover { background-color: var(--hover-color); } .sidebar li.active { background-color: var(--accent-color); color: white; } .file-view { flex: 1; display: flex; flex-direction: column; overflow: hidden; } .file-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; border-bottom: 1px solid var(--border-color); } .file-actions { display: flex; gap: 10px; } .file-list { flex: 1; overflow-y: auto; padding: 10px; } .file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 15px; padding: 10px; } .file-item { display: flex; align-items: center; padding: 10px; border-radius: 5px; transition: background-color 0.2s; cursor: pointer; } .file-item:hover { background-color: var(--hover-color); } .file-item.selected { background-color: var(--accent-color); color: white; } .file-icon { width: 40px; height: 40px; margin-right: 10px; display: flex; align-items: center; justify-content: center; background-color: var(--light-gray); border-radius: 5px; font-size: 1.5rem; } .file-info { flex: 1; } .file-name { font-weight: 500; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .file-details { display: flex; justify-content: space-between; font-size: 0.8rem; color: #666; } .grid-item { display: flex; flex-direction: column; align-items: center; padding: 10px; border-radius: 5px; transition: background-color 0.2s; cursor: pointer; text-align: center; } .grid-item:hover { background-color: var(--hover-color); } .grid-item.selected { background-color: var(--accent-color); color: white; } .grid-icon { width: 60px; height: 60px; display: flex; align-items: center; justify-content: center; background-color: var(--light-gray); border-radius: 5px; font-size: 2rem; margin-bottom: 8px; } .grid-name { font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; } .preview-panel { width: 300px; background-color: var(--light-gray); border-left: 1px solid var(--border-color); display: flex; flex-direction: column; overflow: hidden; } .preview-header { padding: 15px; border-bottom: 1px solid var(--border-color); background-color: white; } .preview-content { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; } .preview-image { max-width: 100%; max-height: 200px; border-radius: 5px; box-shadow: var(--shadow); } .preview-info { margin-top: 20px; width: 100%; } .preview-info h3 { margin-bottom: 10px; font-size: 1.1rem; } .preview-info p { margin-bottom: 5px; display: flex; justify-content: space-between; } .preview-info span:first-child { color: #666; } .status-bar { background-color: var(--light-gray); padding: 10px 20px; font-size: 0.8rem; color: #666; border-top: 1px solid var(--border-color); } .modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); display: flex; justify-content: center; align-items: center; z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.3s; } .modal.active { opacity: 1; pointer-events: all; } .modal-content { background-color: white; padding: 20px; border-radius: 5px; width: 90%; max-width: 500px; box-shadow: var(--shadow); } .modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 1px solid var(--border-color); } .modal-body { margin-bottom: 20px; } .modal-footer { display: flex; justify-content: flex-end; gap: 10px; } .form-group { margin-bottom: 15px; } .form-group label { display: block; margin-bottom: 5px; font-weight: 500; } .form-control { width: 100%; padding: 8px 12px; border: 1px solid var(--border-color); border-radius: 4px; font-size: 0.9rem; } @media (max-width: 768px) { .main-content { flex-direction: column; } .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border-color); } .file-view { height: 400px; } .preview-panel { width: 100%; border-left: none; border-top: 1px solid var(--border-color); height: 300px; } .file-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); } } @media (max-width: 480px) { .header { flex-direction: column; align-items: flex-start; } .breadcrumb { margin-top: 10px; width: 100%; } .controls { flex-direction: column; } .file-actions { flex-direction: column; gap: 5px; } .file-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); } } </style> </head> <body> <div class="container"> <div class="header"> <h1>File Manager</h1> <div class="breadcrumb"> <a href="#" class="breadcrumb-link" data-path="/">Home</a> <span>/</span> <span id="current-folder">Documents</span> </div> </div> <div class="controls"> <input type="text" class="search-box" placeholder="Search files..."> <div class="file-actions"> <button class="btn" id="new-folder-btn">New Folder</button> <button class="btn" id="upload-btn">Upload</button> <button class="btn btn-secondary" id="view-toggle">Grid View</button> </div> </div> <div class="main-content"> <div class="sidebar"> <h3>Quick Access</h3> <ul id="quick-access"> <li class="active" data-path="/">Home</li> <li data-path="/documents">Documents</li> <li data-path="/images">Images</li> <li data-path="/downloads">Downloads</li> <li data-path="/music">Music</li> <li data-path="/videos">Videos</li> </ul> </div> <div class="file-view"> <div class="file-header"> <h3 id="view-title">Documents</h3> <div class="file-actions"> <button class="btn btn-secondary" id="select-all">Select All</button> <button class="btn btn-secondary" id="delete-btn">Delete</button> </div> </div> <div class="file-list active" id="list-view"> <!-- File items will be inserted here --> </div> <div class="file-grid" id="grid-view"> <!-- Grid items will be inserted here --> </div> </div> <div class="preview-panel"> <div class="preview-header"> <h3>Preview</h3> </div> <div class="preview-content"> <div class="preview-image-container"> <img src="" alt="Preview" class="preview-image" id="preview-image"> </div> <div class="preview-info"> <h3 id="preview-name">Select a file to preview</h3> <p><span>Type:</span> <span id="preview-type">-</span></p> <p><span>Size:</span> <span id="preview-size">-</span></p> <p><span>Modified:</span> <span id="preview-date">-</span></p> </div> </div> </div> </div> <div class="status-bar"> <span id="item-count">0 items</span> <span id="storage-info" style="margin-left: 15px;">Storage: 12.5 GB / 50 GB</span> </div> </div> <!-- Modal for new folder --> <div class="modal" id="new-folder-modal"> <div class="modal-content"> <div class="modal-header"> <h3>Create New Folder</h3> <span class="close-modal">×</span> </div> <div class="modal-body"> <div class="form-group"> <label for="folder-name">Folder Name</label> <input type="text" id="folder-name" class="form-control" placeholder="Enter folder name"> </div> </div> <div class="modal-footer"> <button class="btn btn-secondary close-modal">Cancel</button> <button class="btn" id="create-folder-btn">Create</button> </div> </div> </div> <!-- Modal for upload --> <div class="modal" id="upload-modal"> <div class="modal-content"> <div class="modal-header"> <h3>Upload Files</h3> <span class="close-modal">×</span> </div> <div class="modal-body"> <div class="form-group"> <label for="file-upload">Select Files</label> <input type="file" id="file-upload" class="form-control" multiple> </div> </div> <div class="modal-footer"> <button class="btn btn-secondary close-modal">Cancel</button> <button class="btn" id="start-upload-btn">Upload</button> </div> </div> </div> <script> // Sample file data const fileData = { "/": { name: "Home", type: "folder", path: "/", items: [ { name: "Documents", type: "folder", path: "/documents", size: "-", date: "2023-05-15" }, { name: "Images", type: "folder", path: "/images", size: "-", date: "2023-05-10" }, { name: "Downloads", type: "folder", path: "/downloads", size: "-", date: "2023-05-20" }, { name: "Music", type: "folder", path: "/music", size: "-", date: "2023-04-28" }, { name: "Videos", type: "folder", path: "/videos", size: "-", date: "2023-05-05" }, { name: "README.txt", type: "text", path: "/README.txt", size: "2 KB", date: "2023-01-01" } ] }, "/documents": { name: "Documents", type: "folder", path: "/documents", items: [ { name: "Work", type: "folder", path: "/documents/work", size: "-", date: "2023-05-12" }, { name: "Personal", type: "folder", path: "/documents/personal", size: "-", date: "2023-05-18" }, { name: "Resume.pdf", type: "pdf", path: "/documents/Resume.pdf", size: "128 KB", date: "2023-05-14" }, { name: "Notes.txt", type: "text", path: "/documents/Notes.txt", size: "5 KB", date: "2023-05-16" }, { name: "Project Plan.docx", type: "word", path: "/documents/Project Plan.docx", size: "45 KB", date: "2023-05-17" }, { name: "Budget.xlsx", type: "excel", path: "/documents/Budget.xlsx", size: "32 KB", date: "2023-05-19" } ] }, "/images": { name: "Images", type: "folder", path: "/images", items: [ { name: "Vacation", type: "folder", path: "/images/vacation", size: "-", date: "2023-04-25" }, { name: "Family", type: "folder", path: "/images/family", size: "-", date: "2023-05-01" }, { name: "Nature.jpg", type: "image", path: "/images/Nature.jpg", size: "2.4 MB", date: "2023-05-08" }, { name: "Sunset.png", type: "image", path: "/images/Sunset.png", size: "1.8 MB", date: "2023-05-11" }, { name: "Profile.jpg", type: "image", path: "/images/Profile.jpg", size: "512 KB", date: "2023-05-13" } ] }, "/documents/work": { name: "Work", type: "folder", path: "/documents/work", items: [ { name: "Reports", type: "folder", path: "/documents/work/reports", size: "-", date: "2023-05-10" }, { name: "Presentations", type: "folder", path: "/documents/work/presentations", size: "-", date: "2023-05-11" }, { name: "Quarterly Report.pdf", type: "pdf", path: "/documents/work/Quarterly Report.pdf", size: "2.1 MB", date: "2023-05-05" }, { name: "Meeting Notes.txt", type: "text", path: "/documents/work/Meeting Notes.txt", size: "8 KB", date: "2023-05-08" } ] }, "/images/vacation": { name: "Vacation", type: "folder", path: "/images/vacation", items: [ { name: "Beach.jpg", type: "image", path: "/images/vacation/Beach.jpg", size: "3.2 MB", date: "2023-04-20" }, { name: "Mountains.jpg", type: "image", path: "/images/vacation/Mountains.jpg", size: "2.8 MB", date: "2023-04-22" }, { name: "City.jpg", type: "image", path: "/images/vacation/City.jpg", size: "2.5 MB", date: "2023-04-24" } ] } }; // DOM elements const listView = document.getElementById('list-view'); const gridView = document.getElementById('grid-view'); const viewToggle = document.getElementById('view-toggle'); const currentFolderSpan = document.getElementById('current-folder'); const viewTitle = document.getElementById('view-title'); const itemCount = document.getElementById('item-count'); const previewName = document.getElementById('preview-name'); const previewType = document.getElementById('preview-type'); const previewSize = document.getElementById('preview-size'); const previewDate = document.getElementById('preview-date'); const previewImage = document.getElementById('preview-image'); const newFolderBtn = document.getElementById('new-folder-btn'); const uploadBtn = document.getElementById('upload-btn'); const selectAllBtn = document.getElementById('select-all'); const deleteBtn = document.getElementById('delete-btn'); const createFolderBtn = document.getElementById('create-folder-btn'); const startUploadBtn = document.getElementById('start-upload-btn'); const folderNameInput = document.getElementById('folder-name'); const fileUploadInput = document.getElementById('file-upload'); const newFolderModal = document.getElementById('new-folder-modal'); const uploadModal = document.getElementById('upload-modal'); const closeModals = document.querySelectorAll('.close-modal'); const quickAccessItems = document.querySelectorAll('#quick-access li'); const breadcrumbLinks = document.querySelectorAll('.breadcrumb-link'); // State let currentPath = '/'; let currentView = 'list'; let selectedItems = []; // Initialize function init() { renderFiles(); updateBreadcrumb(); updateItemCount(); setupEventListeners(); } // Render files based on current path and view function renderFiles() { const currentFolder = fileData[currentPath]; if (!currentFolder) return; viewTitle.textContent = currentFolder.name; if (currentView === 'list') { renderListView(currentFolder.items); } else { renderGridView(currentFolder.items); } } // Render list view function renderListView(items) { listView.innerHTML = ''; gridView.innerHTML = ''; if (items.length === 0) { listView.innerHTML = '<div class="empty-message">This folder is empty</div>'; return; } items.forEach(item => { const fileItem = document.createElement('div'); fileItem.className = `file-item ${selectedItems.includes(item.path) ? 'selected' : ''}`; fileItem.dataset.path = item.path; const isFolder = item.type === 'folder'; const icon = isFolder ? '📁' : getFileIcon(item.type); fileItem.innerHTML = ` <div class="file-icon">${icon}</div> <div class="file-info"> <div class="file-name">${item.name}</div> <div class="file-details"> <span>${isFolder ? 'Folder' : item.size}</span> <span>${item.date}</span> </div> </div> `; fileItem.addEventListener('click', (e) => { if (e.ctrlKey || e.metaKey) { toggleSelectItem(item.path); } else { if (isFolder) { navigateTo(item.path); } else { selectItem(item.path); showPreview(item); } } }); fileItem.addEventListener('dblclick', () => { if (isFolder) { navigateTo(item.path); } }); listView.appendChild(fileItem); }); listView.classList.add('active'); gridView.classList.remove('active'); } // Render grid view function renderGridView(items) { listView.innerHTML = ''; gridView.innerHTML = ''; if (items.length === 0) { gridView.innerHTML = '<div class="empty-message">This folder is empty</div>'; return; } items.forEach(item => { const gridItem = document.createElement('div'); gridItem.className = `grid-item ${selectedItems.includes(item.path) ? 'selected' : ''}`; gridItem.dataset.path = item.path; const isFolder = item.type === 'folder'; const icon = isFolder ? '📁' : getFileIcon(item.type); gridItem.innerHTML = ` <div class="grid-icon">${icon}</div> <div class="grid-name">${item.name}</div> `; gridItem.addEventListener('click', (e) => { if (e.ctrlKey || e.metaKey) { toggleSelectItem(item.path); } else { if (isFolder) { navigateTo(item.path); } else { selectItem(item.path); showPreview(item); } } }); gridItem.addEventListener('dblclick', () => { if (isFolder) { navigateTo(item.path); } }); gridView.appendChild(gridItem); }); listView.classList.remove('active'); gridView.classList.add('active'); } // Get file icon based on type function getFileIcon(type) { const icons = { 'pdf': '📄', 'word': '📝', 'excel': '📊', 'text': '📋', 'image': '🖼️', 'audio': '🎵', 'video': '🎬', 'zip': '🗄️' }; return icons[type] || '📄'; } // Navigate to a folder function navigateTo(path) { currentPath = path; selectedItems = []; renderFiles(); updateBreadcrumb(); updateQuickAccess(); } // Update breadcrumb navigation function updateBreadcrumb() { const pathParts = currentPath.split('/').filter(part => part !== ''); const breadcrumb = document.querySelector('.breadcrumb'); const currentFolder = breadcrumb.querySelector('#current-folder'); // Clear existing breadcrumb items except the first one const breadcrumbLinks = breadcrumb.querySelectorAll('.breadcrumb-link'); breadcrumbLinks.forEach((link, index) => { if (index > 0) link.remove(); }); // Build new breadcrumb let currentPathBuilder = ''; pathParts.forEach((part, index) => { currentPathBuilder += `/${part}`; const link = document.createElement('a'); link.href = '#'; link.className = 'breadcrumb-link'; link.textContent = part; link.dataset.path = currentPathBuilder; link.addEventListener('click', (e) => { e.preventDefault(); navigateTo(link.dataset.path); }); breadcrumb.insertBefore(link, currentFolder); breadcrumb.insertBefore(document.createTextNode(' / '), currentFolder); }); currentFolder.textContent = pathParts.length > 0 ? pathParts[pathParts.length - 1] : 'Home'; } // Update quick access active state function updateQuickAccess() { quickAccessItems.forEach(item => { item.classList.remove('active'); if (item.dataset.path === currentPath) { item.classList.add('active'); } }); } // Update item count function updateItemCount() { const currentFolder = fileData[currentPath]; if (currentFolder) { itemCount.textContent = `${currentFolder.items.length} items`; } else { itemCount.textContent = '0 items'; } } // Show file preview function showPreview(item) { previewName.textContent = item.name; previewType.textContent = item.type === 'folder' ? 'Folder' : item.type; previewSize.textContent = item.size; previewDate.textContent = item.date; // Show preview image if available if (item.type === 'image') { previewImage.src = getPreviewImage(item.path); previewImage.style.display = 'block'; } else { previewImage.style.display = 'none'; } } // Get preview image (simulated) function getPreviewImage(path) { // In a real app, this would fetch the actual image const images = { '/images/Nature.jpg': 'https://source.unsplash.com/random/300x200?nature', '/images/Sunset.png': 'https://source.unsplash.com/random/300x200?sunset', '/images/Profile.jpg': 'https://source.unsplash.com/random/300x200?portrait', '/images/vacation/Beach.jpg': 'https://source.unsplash.com/random/300x200?beach', '/images/vacation/Mountains.jpg': 'https://source.unsplash.com/random/300x200?mountains', '/images/vacation/City.jpg': 'https://source.unsplash.com/random/300x200?city' }; return images[path] || ''; } // Select an item function selectItem(path) { selectedItems = [path]; updateSelectedItems(); } // Toggle select an item function toggleSelectItem(path) { const index = selectedItems.indexOf(path); if (index === -1) { selectedItems.push(path); } else { selectedItems.splice(index, 1); } updateSelectedItems(); } // Update selected items UI function updateSelectedItems() { if (currentView === 'list') { const items = listView.querySelectorAll('.file-item'); items.forEach(item => { item.classList.toggle('selected', selectedItems.includes(item.dataset.path)); }); } else { const items = gridView.querySelectorAll('.grid-item'); items.forEach(item => { item.classList.toggle('selected', selectedItems.includes(item.dataset.path)); }); } } // Setup event listeners function setupEventListeners() { // View toggle viewToggle.addEventListener('click', () => { currentView = currentView === 'list' ? 'grid' : 'list'; viewToggle.textContent = currentView === 'list' ? 'Grid View' : 'List View'; renderFiles(); }); // Quick access navigation quickAccessItems.forEach(item => { item.addEventListener('click', () => { navigateTo(item.dataset.path); }); }); // Breadcrumb navigation breadcrumbLinks.forEach(link => { link.addEventListener('click', (e) => { e.preventDefault(); navigateTo(link.dataset.path); }); }); // New folder button newFolderBtn.addEventListener('click', () => { newFolderModal.classList.add('active'); folderNameInput.value = ''; folderNameInput.focus(); }); // Upload button uploadBtn.addEventListener('click', () => { uploadModal.classList.add('active'); }); // Select all button selectAllBtn.addEventListener('click', () => { const currentFolder = fileData[currentPath]; if (currentFolder) { selectedItems = currentFolder.items.map(item => item.path); updateSelectedItems(); } }); // Delete button deleteBtn.addEventListener('click', () => { if (selectedItems.length === 0) return; if (confirm(`Are you sure you want to delete ${selectedItems.length} item(s)?`)) { // In a real app, this would delete the items from the file system selectedItems.forEach(path => { deleteFile(path); }); selectedItems = []; renderFiles(); } }); // Create folder button createFolderBtn.addEventListener('click', () => { const folderName = folderNameInput.value.trim(); if (folderName === '') { alert('Please enter a folder name'); return; } // In a real app, this would create the folder in the file system createFolder(folderName); newFolderModal.classList.remove('active'); folderNameInput.value = ''; }); // Start upload button startUploadBtn.addEventListener('click', () => { const files = fileUploadInput.files; if (files.length === 0) { alert('Please select at least one file'); return; } // In a real app, this would upload the files uploadFiles(files); uploadModal.classList.remove('active'); fileUploadInput.value = ''; }); // Close modals closeModals.forEach(closeBtn => { closeBtn.addEventListener('click', () => { newFolderModal.classList.remove('active'); uploadModal.classList.remove('active'); }); }); // Close modal when clicking outside newFolderModal.addEventListener('click', (e) => { if (e.target === newFolderModal) { newFolderModal.classList.remove('active'); } }); uploadModal.addEventListener('click', (e) => { if (e.target === uploadModal) { uploadModal.classList.remove('active'); } }); // Keyboard shortcuts document.addEventListener('keydown', (e) => { if (e.key === 'Escape') { selectedItems = []; updateSelectedItems(); } }); } // Simulate creating a folder function createFolder(name) { const newFolder = { name: name, type: 'folder', path: `${currentPath}/${name}`, size: '-', date: new Date().toISOString().split('T')[0] }; if (!fileData[currentPath].items) { fileData[currentPath].items = []; } fileData[currentPath].items.push(newFolder); fileData[newFolder.path] = { name: name, type: 'folder', path: newFolder.path, items: [] }; renderFiles(); } // Simulate deleting a file/folder function deleteFile(path) { // Remove from parent folder's items const pathParts = path.split('/').filter(part => part !== ''); const parentPath = pathParts.slice(0, -1).join('/') || '/'; if (fileData[parentPath]) { fileData[parentPath].items = fileData[parentPath].items.filter(item => item.path !== path); } // Remove the item itself delete fileData[path]; } // Simulate uploading files function uploadFiles(files) { const currentDate = new Date().toISOString().split('T')[0]; Array.from(files).forEach(file => { const fileType = getFileType(file.name); const fileSize = formatFileSize(file.size); const newFile = { name: file.name, type: fileType, path: `${currentPath}/${file.name}`, size: fileSize, date: currentDate }; if (!fileData[currentPath].items) { fileData[currentPath].items = []; } fileData[currentPath].items.push(newFile); }); renderFiles(); } // Get file type from name function getFileType(name) { const extension = name.split('.').pop().toLowerCase(); const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp']; const audioExtensions = ['mp3', 'wav', 'ogg', 'aac']; const videoExtensions = ['mp4', 'webm', 'mov', 'avi']; if (imageExtensions.includes(extension)) return 'image'; if (audioExtensions.includes(extension)) return 'audio'; if (videoExtensions.includes(extension)) return 'video'; if (extension === 'pdf') return 'pdf'; if (extension === 'doc' || extension === 'docx') return 'word'; if (extension === 'xls' || extension === 'xlsx') return 'excel'; if (extension === 'txt') return 'text'; if (extension === 'zip' || extension === 'rar' || extension === '7z') return 'zip'; return 'file'; } // Format file size function formatFileSize(bytes) { if (bytes === 0) return '0 Bytes'; const k = 1024; const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; const i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]; } // Initialize the app init(); </script> </body> </html>Features
This file manager includes:
- Responsive Design: Works on mobile, tablet, and desktop screens
- Dual View Modes: List and grid views with toggle functionality
- File Navigation: Breadcrumbs and quick access sidebar
- File Operations: Select, preview, and delete files
- Folder Management: Create new folders
- File Upload: Simulated file upload functionality
- Preview Panel: Shows file details and previews for images
- Search Functionality: Search box for finding files
- Modern UI: Clean, intuitive interface with proper spacing and visual hierarchy
The code is self-contained in a single HTML file with embedded CSS and JavaScript. You can save this as an HTML file and open it in any modern browser to use the file manager.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.