document.addEventListener('DOMContentLoaded', () => { const themeSwitcher = document.getElementById('theme-switcher'); const currentTheme = localStorage.getItem('theme') ? localStorage.getItem('theme') : null; if (currentTheme) { document.body.classList.add(currentTheme); if (currentTheme === 'dark-theme') { themeSwitcher.innerHTML = ''; } else { themeSwitcher.innerHTML = ''; } } else { // Default to light document.body.classList.add('light-theme'); themeSwitcher.innerHTML = ''; } themeSwitcher.addEventListener('click', () => { if (document.body.classList.contains('dark-theme')) { document.body.classList.remove('dark-theme'); document.body.classList.add('light-theme'); localStorage.setItem('theme', 'light-theme'); themeSwitcher.innerHTML = ''; } else { document.body.classList.remove('light-theme'); document.body.classList.add('dark-theme'); localStorage.setItem('theme', 'dark-theme'); themeSwitcher.innerHTML = ''; } }); // Folder import functionality const importFolderBtn = document.getElementById('import-folder-btn'); const folderInput = document.getElementById('folder-input'); const photoGallery = document.querySelector('.photo-gallery'); if (importFolderBtn && folderInput && photoGallery) { importFolderBtn.addEventListener('click', () => { folderInput.click(); }); folderInput.addEventListener('change', (event) => { const files = event.target.files; if (files.length > 0) { const formData = new FormData(); const imageFiles = Array.from(files).filter(file => file.type.startsWith('image/')); if (imageFiles.length > 0) { imageFiles.forEach(file => { formData.append('photos[]', file); }); // Show a loading indicator photoGallery.innerHTML = '
Uploading...
Upload Failed:
${errorMessages}An error occurred during upload. Check the browser console for details.
No images found in the selected folder.