summaryrefslogtreecommitdiffstats
path: root/public/js/album.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/js/album.js')
-rw-r--r--public/js/album.js47
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)
);
})();