-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
380 lines (327 loc) · 13 KB
/
Copy pathtest.html
File metadata and controls
380 lines (327 loc) · 13 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Would You Rather?</title>
<link rel="stylesheet" href="https://polyextended.github.io/nav.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<link rel="icon" type="image/x-icon" href="https://i.imgur.com/kHOeihm.png" id="favicon">
<meta name="twitter:image" content="https://i.imgur.com/kHOeihm.png" id="twitter-image">
<style>
body {
background: linear-gradient(135deg, #1a237e, #0d47a1);
color: white;
min-height: 100vh;
font-family: 'Roboto', sans-serif;
}
.game-container {
background-color: rgba(255, 255, 255, 0.1);
border-radius: 15px;
padding: 30px;
margin-top: 30px;
backdrop-filter: blur(5px);
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
h1 {
font-weight: 700;
text-align: center;
margin-bottom: 30px;
font-size: 3rem;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
color: #ffeb3b;
}
#question {
font-size: 1.5rem;
min-height: 80px;
padding: 20px;
background-color: rgba(255, 255, 255, 0.15);
border-radius: 10px;
margin: 30px 0;
text-align: center;
font-weight: 500;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
#answerButtons {
display: flex;
flex-direction: column;
gap: 15px;
margin: 20px 0;
}
#answerButtons button {
padding: 15px;
font-size: 1.2rem;
border-radius: 8px;
font-weight: 500;
transition: all 0.3s ease;
text-transform: none;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
min-height: 60px;
}
#answerButtons button:nth-child(1) {
background-color: #f44336;
}
#answerButtons button:nth-child(2) {
background-color: #2196f3;
}
#answerButtons button:hover {
transform: translateY(-5px);
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}
#getQuestionBtn {
background-color: #ffeb3b;
color: #333;
font-weight: bold;
font-size: 1.2rem;
padding: 0 30px;
height: 50px;
border-radius: 25px;
display: block;
margin: 0 auto;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}
#getQuestionBtn:hover {
background-color: #ffd600;
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}
#answerResult {
text-align: center;
font-size: 1.3rem;
min-height: 40px;
margin: 20px 0;
font-weight: 500;
color: #81d4fa;
}
.score-container {
text-align: center;
padding: 15px;
background-color: rgba(255, 255, 255, 0.15);
border-radius: 50px;
width: 150px;
margin: 20px auto;
font-size: 1.2rem;
font-weight: 600;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
#userScore {
font-weight: 700;
color: #ffeb3b;
}
.game-title-container {
display: flex;
align-items: center;
justify-content: center;
gap: 15px;
}
.game-icon {
font-size: 2.5rem;
color: #ffeb3b;
}
footer {
text-align: center;
margin-top: 30px;
font-size: 0.9rem;
color: rgba(255, 255, 255, 0.6);
padding: 20px 0;
}
.loader {
border: 5px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
border-top: 5px solid #ffeb3b;
width: 30px;
height: 30px;
animation: spin 1s linear infinite;
margin: 0 auto;
display: none;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.hidden {
display: none;
}
.navbar {
background-color: rgba(0, 0, 0, 0.2) !important;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
@media (max-width: 768px) {
h1 {
font-size: 2.2rem;
}
#question {
font-size: 1.2rem;
min-height: 60px;
}
.game-container {
padding: 20px;
margin-top: 15px;
}
}
</style>
</head>
<body>
<header>
<nav class="navbar navbar-expand-lg navbar-dark">
<div class="container">
<a class="navbar-brand" href="#">
<i class="fas fa-dice-d20 me-2"></i>PolyExtemder
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link" href="https://polyextender.github.io/">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://polyextender.github.io/PolyStreamLookup/">StreamLookup</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="https://polyextender.github.io/PolyCosmetic/">PolyCosmetic</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="container">
<div class="game-container animate__animated animate__fadeIn">
<div class="game-title-container">
<i class="fas fa-question-circle game-icon animate__animated animate__pulse animate__infinite"></i>
<h1>Would You Rather?</h1>
<i class="fas fa-question-circle game-icon animate__animated animate__pulse animate__infinite"></i>
</div>
<button id="getQuestionBtn" class="waves-effect waves-light btn" onclick="getQuestion()">
<i class="fas fa-random"></i> Get a Question
</button>
<div class="loader" id="loader"></div>
<div id="question" class="animate__animated"></div>
<div id="answerButtons" class="animate__animated"></div>
<p id="answerResult" class="animate__animated"></p>
<div class="score-container animate__animated animate__fadeIn">
<i class="fas fa-trophy"></i> Score: <span id="userScore">0</span>
</div>
</div>
<footer>
<p>© 2025 PolyExtender - Fun games for all players</p>
</footer>
</div>
<script>
let userScore = localStorage.getItem('userScore') || 0;
let questions;
let currentQuestion;
// Show loader while fetching questions
document.getElementById('loader').style.display = 'block';
// Fetch questions from the specified URL
fetch('questions.json')
.then(response => response.json())
.then(data => {
questions = data;
document.getElementById('loader').style.display = 'none';
// Auto-load a question on page load
if (questions && questions.length > 0) {
setTimeout(getQuestion, 500);
}
})
.catch(error => {
console.error('Error fetching questions:', error);
document.getElementById('loader').style.display = 'none';
document.getElementById('question').innerHTML =
"<span style='color:#ff6b6b'>Oops! Couldn't load questions. Please try again later.</span>";
document.getElementById('question').classList.add('animate__fadeIn');
});
function getQuestion() {
// Ensure questions are loaded before proceeding
if (!questions || questions.length === 0) {
console.error('Questions not loaded yet.');
return;
}
// Reset and animate
document.getElementById('answerResult').innerText = '';
document.getElementById('question').classList.remove('animate__fadeIn');
document.getElementById('answerButtons').classList.remove('animate__fadeIn');
// Show loader briefly for effect
document.getElementById('loader').style.display = 'block';
document.getElementById('question').innerText = '';
document.getElementById('answerButtons').innerHTML = '';
setTimeout(() => {
// Get a random question
currentQuestion = questions[Math.floor(Math.random() * questions.length)];
// Hide loader
document.getElementById('loader').style.display = 'none';
// Display question with animation
document.getElementById('question').innerText = currentQuestion.question;
document.getElementById('question').classList.add('animate__fadeIn');
// Dynamically generate buttons based on options
const buttonHTML = currentQuestion.options.map((option, index) =>
`<button class="waves-effect waves-light btn animate__animated animate__fadeInUp"
style="animation-delay: ${index * 0.2}s"
onclick="answerQuestion('${option}')">
${option}
</button>`
).join('');
document.getElementById('answerButtons').innerHTML = buttonHTML;
document.getElementById('answerButtons').classList.add('animate__fadeIn');
}, 600);
}
function answerQuestion(userAnswer) {
// Disable all buttons to prevent multiple clicks
const buttons = document.querySelectorAll('#answerButtons button');
buttons.forEach(button => {
button.disabled = true;
if (button.textContent.trim() === userAnswer) {
button.style.backgroundColor = '#4caf50'; // Highlight selected answer
button.classList.add('animate__pulse');
} else {
button.style.opacity = '0.5';
}
});
// Process the user's answer with animation
document.getElementById('answerResult').innerText = '';
document.getElementById('answerResult').classList.remove('animate__fadeIn');
setTimeout(() => {
document.getElementById('answerResult').innerText = `You chose: ${userAnswer}`;
document.getElementById('answerResult').classList.add('animate__fadeIn');
// Increment the score with animation
userScore++;
localStorage.setItem('userScore', userScore);
const scoreElement = document.getElementById('userScore');
scoreElement.classList.add('animate__animated', 'animate__heartBeat');
scoreElement.innerText = userScore;
setTimeout(() => {
scoreElement.classList.remove('animate__animated', 'animate__heartBeat');
}, 1000);
}, 300);
}
// Initialize score display
document.getElementById('userScore').innerText = userScore;
// Add sound effects
function playSound(type) {
const audio = new Audio();
audio.volume = 0.3;
if (type === 'click') {
audio.src = 'https://assets.mixkit.co/active_storage/sfx/2568/2568-preview.mp3';
} else if (type === 'success') {
audio.src = 'https://assets.mixkit.co/active_storage/sfx/2062/2062-preview.mp3';
}
audio.play();
}
// Add button click sounds
document.getElementById('getQuestionBtn').addEventListener('click', () => playSound('click'));
// Initialize tooltips
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.tooltipped');
var instances = M.Tooltip.init(elems);
});
</script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
</body>
</html>