From 35a72d21075c9d2331ee4388fe34fe6efd5b65fc Mon Sep 17 00:00:00 2001 From: Ken D'Ambrosio Date: Mon, 11 May 2026 05:43:28 +0000 Subject: Limit slideshow to filtered albums when search filter is active Co-Authored-By: Claude Sonnet 4.6 --- public/js/album.js | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) (limited to 'public') diff --git a/public/js/album.js b/public/js/album.js index dd54ed2..689edee 100644 --- a/public/js/album.js +++ b/public/js/album.js @@ -115,32 +115,39 @@ window.addEventListener('DOMContentLoaded', () => { } }); -// Album search filter +// Album search filter + slideshow link (kept together so filter state feeds the link) (function () { const input = document.getElementById('album-search'); - if (!input) return; - input.addEventListener('input', () => { - const q = input.value.trim().toLowerCase(); - document.querySelectorAll('#album-grid .album-card').forEach(card => { - const label = (card.querySelector('.album-label')?.textContent || '').toLowerCase(); - card.style.display = !q || label.includes(q) ? '' : 'none'; - }); - }); -})(); + const link = document.getElementById('ss-launch'); -// Slideshow launch options (Shuffle / Full screen checkboxes next to the button) -(function () { - const link = document.getElementById('ss-launch'); - if (!link) return; - const base = link.dataset.base; - function update() { + function updateSsLink() { + if (!link) return; const p = []; - if (document.getElementById('ss-opt-shuffle').checked) p.push('shuffle=1'); - if (document.getElementById('ss-opt-fullscreen').checked) p.push('fullscreen=1'); - link.href = base + (p.length ? '?' + p.join('&') : ''); + if (document.getElementById('ss-opt-shuffle')?.checked) p.push('shuffle=1'); + if (document.getElementById('ss-opt-fullscreen')?.checked) p.push('fullscreen=1'); + if (input && input.value.trim()) { + const visible = [...document.querySelectorAll('#album-grid .album-card')] + .filter(c => c.style.display !== 'none') + .map(c => c.dataset.rel) + .filter(Boolean); + if (visible.length) p.push('dirs=' + visible.map(encodeURIComponent).join(',')); + } + link.href = link.dataset.base + (p.length ? '?' + p.join('&') : ''); } + + if (input) { + input.addEventListener('input', () => { + const q = input.value.trim().toLowerCase(); + document.querySelectorAll('#album-grid .album-card').forEach(card => { + const label = (card.querySelector('.album-label')?.textContent || '').toLowerCase(); + card.style.display = !q || label.includes(q) ? '' : 'none'; + }); + updateSsLink(); + }); + } + ['ss-opt-shuffle', 'ss-opt-fullscreen'].forEach(id => - document.getElementById(id).addEventListener('change', update) + document.getElementById(id)?.addEventListener('change', updateSsLink) ); })(); -- cgit v1.2.3