diff --git a/screenshot.png b/screenshot.png index 0057c1c..1f9f24e 100644 Binary files a/screenshot.png and b/screenshot.png differ diff --git a/src/index.html b/src/index.html index a770039..fe7243f 100644 --- a/src/index.html +++ b/src/index.html @@ -69,6 +69,11 @@ box-shadow: 0 0 10px rgba(255, 107, 107, 0.5); } + .thumbnail.selected { + border-color: #4caf50; + background-color: rgba(76, 175, 80, 0.3); + } + .image-viewer { background: rgba(255,255,255,0.1); backdrop-filter: blur(10px); @@ -182,25 +187,25 @@
+
No folder selected
- - + @@ -214,7 +219,9 @@ 1x
-
No folder selected
+
@@ -228,6 +235,7 @@ let isPlaying = false; let playInterval = null; let playSpeed = 1000; + let selectedIndices = []; function selectFolder() { document.getElementById('folderInput').click(); @@ -273,37 +281,60 @@ function createThumbnails() { const container = document.getElementById('thumbnailsScroll'); const thumbnailsContainer = document.getElementById('thumbnailsContainer'); - container.innerHTML = ''; - if (images.length === 0) { thumbnailsContainer.style.display = 'none'; return; } - thumbnailsContainer.style.display = 'block'; - images.forEach((img, index) => { const thumb = document.createElement('img'); thumb.src = img.url; thumb.className = 'thumbnail'; - thumb.onclick = () => goToImage(index); + thumb.onclick = (e) => handleThumbnailClick(e, index); thumb.title = `${img.name} - ${img.createdDate.toLocaleString()}`; container.appendChild(thumb); }); - updateThumbnailHighlight(); } + function handleThumbnailClick(e, index) { + if (e.ctrlKey || e.metaKey) { + // Toggle selection + if (selectedIndices.includes(index)) { + selectedIndices = selectedIndices.filter(i => i !== index); + } else { + selectedIndices.push(index); + } + } else if (e.shiftKey && selectedIndices.length > 0) { + // Range select + const last = selectedIndices[selectedIndices.length - 1]; + const [start, end] = [Math.min(last, index), Math.max(last, index)]; + selectedIndices = []; + for (let i = start; i <= end; i++) selectedIndices.push(i); + } else { + // Single select + selectedIndices = [index]; + } + updateThumbnailHighlight(); + if (selectedIndices.length === 1) { + currentIndex = selectedIndices[0]; + displayCurrentImage(); + } else { + displayCurrentImage(); + } + updateDeleteButton(); + } + function updateThumbnailHighlight() { const thumbnails = document.querySelectorAll('.thumbnail'); thumbnails.forEach((thumb, index) => { - thumb.classList.toggle('active', index === currentIndex); + thumb.classList.toggle('active', index === currentIndex && selectedIndices.length <= 1); + thumb.classList.toggle('selected', selectedIndices.includes(index)); }); - - // Scroll active thumbnail into view - if (thumbnails[currentIndex]) { - thumbnails[currentIndex].scrollIntoView({ + // Scroll active thumbnail into view + if (selectedIndices.length === 1 && thumbnails[selectedIndices[0]]) { + thumbnails[selectedIndices[0]].scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center' @@ -340,7 +371,10 @@ container.innerHTML = '
No images loaded
'; return; } - + if (selectedIndices.length > 1) { + container.innerHTML = `
${selectedIndices.length} images selected. Use the Delete Selected button to remove them.
`; + return; + } const current = images[currentIndex]; const createdDate = current.createdDate.toLocaleString(); @@ -552,6 +586,24 @@ document.getElementById('status').textContent = message; } + function updateDeleteButton() { + document.getElementById('deleteBtn').disabled = selectedIndices.length === 0; + } + + function deleteSelectedImages() { + if (selectedIndices.length === 0) return; + // Remove selected images + images = images.filter((_, idx) => !selectedIndices.includes(idx)); + // Reset selection and currentIndex + selectedIndices = []; + currentIndex = Math.min(currentIndex, images.length - 1); + createThumbnails(); + updateButtons(); + displayCurrentImage(); + updateStatus(`Deleted selected images.`); + updateDeleteButton(); + } + // Keyboard shortcuts document.addEventListener('keydown', function(e) { switch(e.code) {