diff options
| author | Ken D'Ambrosio <ken@jots.org> | 2026-05-11 05:43:28 +0000 |
|---|---|---|
| committer | Ken D'Ambrosio <ken@jots.org> | 2026-05-11 05:43:28 +0000 |
| commit | 35a72d21075c9d2331ee4388fe34fe6efd5b65fc (patch) | |
| tree | a7d00b185f1f77c658cbc05ca663a381bfbcc7db /public | |
| parent | 9f586a8db100c586b33f425f7699355bca43f8b4 (diff) | |
Limit slideshow to filtered albums when search filter is active
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'public')
| -rw-r--r-- | public/js/album.js | 47 |
1 files changed, 27 insertions, 20 deletions
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) ); })(); |
