-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
105 lines (96 loc) · 3.55 KB
/
Copy pathscript.js
File metadata and controls
105 lines (96 loc) · 3.55 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
const challenges = {
easy: [
"Do 10 push-ups",
"Sing a song out loud",
"Tell a joke",
"wherever you are, sit and stand 7 times",
"Stand on one leg for 30 seconds",
"Say the alphabet backwards",
"Do a silly dance for 10 seconds",
"Compliment someone genuinely",
"Steal something from someone and return it when they really need it",
"Yodel for 5 seconds",
"Speak in an accent for 1 minute",
"Make animal sounds for 10 seconds",
"Draw something without looking",
"Send a 50$ to someone",
"Hug someone"
],
medium: [
"Do 25 push-ups",
"Stand on your head for 30 seconds",
"Eat something spicy",
"Call someone and make them laugh",
"Do 20 squats",
"Buy your friends a chocolate each",
"Balance a book on your head while walking",
"Do a handstand against a wall for 20 seconds",
"Text your crush with a compliment",
"Perform a magic trick",
"Do 50 jumping jacks",
"Hold an ice cube for as long as possible",
"Write a poem about the person next to you",
"Run around the block",
"Imitate a celebrity for 1 minute"
],
hard: [
"Do 50 push-ups",
"Plank for 2 minutes",
"Give a 3-minute speech on a random topic to someone random",
"Send 100$ to your friend",
"Learn a dance in 10 minutes",
"Go live on social media for 5 minutes",
"Dye your hair a temporary color",
"Do 30 jumps",
"Recite a Shakespeare monologue",
"Create and post a song on social media",
"Let someone else choose your outfit for the day",
"Do not eat or drink for the next 2 hours",
"Let someone borrow your unlocked phone for the next 5 minutes",
"Perform stand-up comedy for 5 minutes",
"Give a stranger a funny compliment"
]
};
const difficultySelect = document.getElementById('difficulty');
const generateBtn = document.getElementById('generate-btn');
const challengeText = document.getElementById('challenge-text');
// update body gradient when difficulty changes and on load
difficultySelect.addEventListener('change', updateBackground);
generateBtn.addEventListener('click', generateChallenge);
// initialize background class based on default select value
updateBackground();
function generateChallenge() {
const difficulty = difficultySelect.value;
const challengeList = challenges[difficulty];
const randomIndex = Math.floor(Math.random() * challengeList.length);
const randomChallenge = challengeList[randomIndex];
challengeText.textContent = randomChallenge;
challengeText.style.animation = 'none';
// Trigger animation
setTimeout(() => {
challengeText.style.animation = 'slideIn 0.5s ease';
}, 10);
}
function updateBackground() {
const difficulty = difficultySelect.value;
document.body.classList.remove('bg-easy', 'bg-medium', 'bg-hard');
document.body.classList.add(`bg-${difficulty}`);
// also update button color
generateBtn.classList.remove('btn-easy', 'btn-medium', 'btn-hard');
generateBtn.classList.add(`btn-${difficulty}`);
}
// CSS animation (add to stylesheet dynamically)
const style = document.createElement('style');
style.textContent = `
@keyframes slideIn {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
`;
document.head.appendChild(style);