Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
43 lines (36 loc) · 1.41 KB
/
Copy pathscript.js
File metadata and controls
43 lines (36 loc) · 1.41 KB
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
34
35
36
37
38
39
40
41
42
43
const moods = [
{ color: '#FF6B6B', caption: 'Feeling fiery ❤️🔥' },
{ color: '#6BCB77', caption: 'Chill and grounded 🌿' },
{ color: '#4D96FF', caption: 'Peaceful and calm 🌊' },
{ color: '#FFD93D', caption: 'Bright and sunny ☀️' },
{ color: '#C780FA', caption: 'Magical and dreamy 🪄' },
{ color: '#F94C66', caption: 'Spicy and bold 🌶️' },
{ color: '#00C49A', caption: 'Balanced and fresh 🍃' },
{ color: '#FF9F1C', caption: 'Creative spark ⚡️' },
{ color: '#A9DEF9', caption: 'Breezy & light 💨' },
{ color: '#E4C1F9', caption: 'Soft & introspective 🌸' },
{ color: '#FCF6BD', caption: 'Mellow vibes 🍯' },
{ color: '#D0F4DE', caption: 'Freshly reset 🌱' }
];
let lastMoodIndex = -1;
function changeMood() {
const orb = document.getElementById('orb');
const caption = document.getElementById('caption');
let newIndex;
do {
newIndex = Math.floor(Math.random() * moods.length);
} while (newIndex === lastMoodIndex);
lastMoodIndex = newIndex;
const mood = moods[newIndex];
// Start fade-out
orb.classList.add('fade');
caption.classList.add('fade');
// After fade-out (300ms), change mood and fade back in
setTimeout(() => {
orb.style.backgroundColor = mood.color;
orb.style.boxShadow = `0 0 50px ${mood.color}`;
caption.textContent = mood.caption;
orb.classList.remove('fade');
caption.classList.remove('fade');
}, 300);
}