ProjectGenesis's picture
<div class="control-panel">
758010d verified
raw
history blame contribute delete
948 Bytes
// Add sound effects for toggle
document.addEventListener('DOMContentLoaded', () => {
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
document.querySelectorAll('input[type="checkbox"]').forEach(checkbox => {
checkbox.addEventListener('change', function() {
playToggleSound(this.checked);
});
});
function playToggleSound(isOn) {
const oscillator = audioContext.createOscillator();
const gainNode = audioContext.createGain();
oscillator.type = 'sine';
oscillator.frequency.value = isOn ? 800 : 400;
gainNode.gain.value = 0.1;
oscillator.connect(gainNode);
gainNode.connect(audioContext.destination);
oscillator.start();
gainNode.gain.exponentialRampToValueAtTime(0.001, audioContext.currentTime + 0.3);
oscillator.stop(audioContext.currentTime + 0.3);
}
});