diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-09 19:58:44 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-09 19:58:44 +0300 |
| commit | 868b7fb10c912ea3b7200d1ffa1f287dce335f23 (patch) | |
| tree | a524d91e484bf4c814a269815594b3ebae66bed4 /web/js/shuffle.js | |
| parent | 8c32cd117abe79f4ee6cff3a950ffc35c95faeff (diff) | |
Fix shuffle hotkey reshuffle behavior (q1)
Diffstat (limited to 'web/js/shuffle.js')
| -rw-r--r-- | web/js/shuffle.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/web/js/shuffle.js b/web/js/shuffle.js index bef4dad..ccdede7 100644 --- a/web/js/shuffle.js +++ b/web/js/shuffle.js @@ -1,10 +1,12 @@ let shuffleOn = false; +let shuffleRevision = 0; export function initShuffle({ onChange }) { const btn = document.getElementById('shuffle-toggle'); if (!btn) return; btn.addEventListener('click', () => { shuffleOn = !shuffleOn; + shuffleRevision += 1; updateUI(); onChange?.(shuffleOn); }); @@ -12,12 +14,22 @@ export function initShuffle({ onChange }) { export function toggle() { shuffleOn = !shuffleOn; + shuffleRevision += 1; + updateUI(); + return shuffleOn; +} + +export function enable() { + shuffleOn = true; + shuffleRevision += 1; updateUI(); return shuffleOn; } export function isOn() { return shuffleOn; } +export function revision() { return shuffleRevision; } + function updateUI() { const btn = document.getElementById('shuffle-toggle'); if (btn) btn.classList.toggle('active', shuffleOn); |
