Spaces:
Running
Running
File size: 1,216 Bytes
24f20dd 7bd5e35 24f20dd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | document.addEventListener('DOMContentLoaded', () => {
const audio = document.getElementById('bgAudio');
const muteBtn = document.getElementById('muteBtn');
let isMuted = false;
// Ensure audio plays even after refresh
audio.volume = 0.2;
document.body.addEventListener('click', () => {
audio.play().catch(e => console.log('Autoplay prevented:', e));
}, { once: true });
muteBtn.addEventListener('click', () => {
isMuted = !isMuted;
audio.muted = isMuted;
muteBtn.innerHTML = isMuted ?
'<i data-feather="volume-x"></i>' :
'<i data-feather="volume-2"></i>';
feather.replace();
});
// Smooth hover transitions handled in CSS
// Randomly change the background gradient direction
setInterval(() => {
const directions = [
'to right bottom',
'to left top',
'to right top',
'to left bottom'
];
const randomDir = directions[Math.floor(Math.random() * directions.length)];
document.querySelector('div.absolute.inset-0').style.background =
`linear-gradient(${randomDir}, transparent, black, black)`;
}, 10000);
}); |