diff --git a/main.py b/main.py index 262e5cd..799f2e2 100644 --- a/main.py +++ b/main.py @@ -1320,6 +1320,31 @@ INDEX_HTML = """ modeIb: document.getElementById("modeIb"), }; + let clickAudioCtx = null; + + function playScopeClick() { + try { + if (!clickAudioCtx) { + clickAudioCtx = new (window.AudioContext || window.webkitAudioContext)(); + } + const now = clickAudioCtx.currentTime; + const osc = clickAudioCtx.createOscillator(); + const gain = clickAudioCtx.createGain(); + osc.type = "triangle"; + osc.frequency.setValueAtTime(1800, now); + osc.frequency.exponentialRampToValueAtTime(950, now + 0.025); + gain.gain.setValueAtTime(0.0001, now); + gain.gain.linearRampToValueAtTime(0.14, now + 0.0025); + gain.gain.exponentialRampToValueAtTime(0.0001, now + 0.04); + osc.connect(gain); + gain.connect(clickAudioCtx.destination); + osc.start(now); + osc.stop(now + 0.045); + } catch (_) { + // Ignore audio failures silently. + } + } + function normalize(s) { return s.toLowerCase().replace(/ё/g, "е"); } @@ -1504,6 +1529,7 @@ INDEX_HTML = """ async function switchScope(scope) { if (scope === state.scope) return; + playScopeClick(); state.scope = scope; state.selectedVendors.clear(); state.selectedCategories.clear();