Files
treywisp.com/main.js

46 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function createParticles(containerSelector, count = 60, baseHue = 180) {
const container = document.querySelector(containerSelector);
for (let i = 0; i < count; i++) {
const particle = document.createElement('div');
particle.classList.add('particle');
const size = Math.random() * 8 + 2;
const posX = Math.random() * 100;
const posY = Math.random() * 100;
const duration = Math.random() * 5 + 5;
const variation = Math.random() * 10 - 5;
particle.style.background = `hsl(${baseHue + variation}, 100%, 50%)`;
particle.style.width = size + 'px';
particle.style.height = size + 'px';
particle.style.left = posX + '%';
particle.style.top = posY + '%';
particle.style.animationDuration = `${duration}s`;
container.appendChild(particle);
}
}
createParticles('.particles', 60, 180);
const hitButton = document.getElementById('hitButton');
const audio = document.getElementById('winxAudio');
hitButton.addEventListener('click', () => {
if (audio.paused) {
audio.play();
hitButton.classList.add('playing');
hitButton.textContent = 'БОЛЬШЕ НЕ СЛУШАТЬ ХИТ 2007';
} else {
audio.pause();
audio.currentTime = 0;
hitButton.classList.remove('playing');
hitButton.textContent = 'СЛУШАТЬ ХИТ 2007';
}
});
audio.addEventListener('ended', () => {
hitButton.classList.remove('playing');
hitButton.textContent = 'СЛУШАТЬ ХИТ 2007';
audio.currentTime = 0;
});