Spaces:
Running
Running
Add 2 files
Browse files- README.md +7 -5
- index.html +489 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: the-clock
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: green
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,489 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="de">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Uhrzeit lernen - Spiel für Kinder</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<style>
|
| 10 |
+
@keyframes bounce {
|
| 11 |
+
0%, 100% { transform: translateY(0); }
|
| 12 |
+
50% { transform: translateY(-20px); }
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
@keyframes confetti {
|
| 16 |
+
0% { transform: translateY(0) rotate(0deg); opacity: 1; }
|
| 17 |
+
100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
.confetti {
|
| 21 |
+
position: absolute;
|
| 22 |
+
width: 15px;
|
| 23 |
+
height: 15px;
|
| 24 |
+
background-color: #f00;
|
| 25 |
+
animation: confetti 3s ease-out forwards;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
.clock-face {
|
| 29 |
+
background-color: #FFFAF0;
|
| 30 |
+
border: 8px solid #4B5563;
|
| 31 |
+
box-shadow: 0 0 20px rgba(0,0,0,0.2);
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
.hour-hand {
|
| 35 |
+
background-color: #EF4444; /* Rot für den Stundenzeiger */
|
| 36 |
+
height: 8px;
|
| 37 |
+
width: 30%;
|
| 38 |
+
top: 50%;
|
| 39 |
+
left: 20%;
|
| 40 |
+
transform-origin: 100%;
|
| 41 |
+
border-radius: 6px;
|
| 42 |
+
transform: rotate(90deg);
|
| 43 |
+
z-index: 2;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
.minute-hand {
|
| 47 |
+
background-color: #3B82F6; /* Blau für den Minutenzeiger */
|
| 48 |
+
height: 6px;
|
| 49 |
+
width: 40%;
|
| 50 |
+
top: 50%;
|
| 51 |
+
left: 10%;
|
| 52 |
+
transform-origin: 100%;
|
| 53 |
+
border-radius: 4px;
|
| 54 |
+
transform: rotate(90deg);
|
| 55 |
+
z-index: 3;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
.correct-answer {
|
| 59 |
+
animation: bounce 0.5s ease infinite;
|
| 60 |
+
background-color: #10B981 !important;
|
| 61 |
+
color: white !important;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
.wrong-answer {
|
| 65 |
+
background-color: #EF4444 !important;
|
| 66 |
+
color: white !important;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
.hint-bubble {
|
| 70 |
+
position: absolute;
|
| 71 |
+
background-color: #3B82F6;
|
| 72 |
+
color: white;
|
| 73 |
+
padding: 10px;
|
| 74 |
+
border-radius: 10px;
|
| 75 |
+
animation: float 3s ease-in-out infinite;
|
| 76 |
+
z-index: 10;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
@keyframes float {
|
| 80 |
+
0%, 100% { transform: translateY(0); }
|
| 81 |
+
50% { transform: translateY(-10px); }
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
/* Präzise Positionierung der Ziffern auf einem Kreis */
|
| 85 |
+
.clock-number {
|
| 86 |
+
position: absolute;
|
| 87 |
+
font-size: 1.5rem;
|
| 88 |
+
font-weight: bold;
|
| 89 |
+
width: 32px;
|
| 90 |
+
height: 32px;
|
| 91 |
+
display: flex;
|
| 92 |
+
align-items: center;
|
| 93 |
+
justify-content: center;
|
| 94 |
+
transform: translate(-50%, -50%);
|
| 95 |
+
color: #4B5563;
|
| 96 |
+
background-color: #FFFAF0;
|
| 97 |
+
border-radius: 50%;
|
| 98 |
+
z-index: 1;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
/* Ticks für die Minuten */
|
| 102 |
+
.clock-tick {
|
| 103 |
+
position: absolute;
|
| 104 |
+
background-color: #4B5563;
|
| 105 |
+
width: 2px;
|
| 106 |
+
height: 8px;
|
| 107 |
+
transform-origin: 50% 100%;
|
| 108 |
+
left: 50%;
|
| 109 |
+
top: 10px;
|
| 110 |
+
}
|
| 111 |
+
</style>
|
| 112 |
+
</head>
|
| 113 |
+
<body class="bg-blue-50 min-h-screen flex flex-col items-center justify-center p-4">
|
| 114 |
+
<div class="max-w-2xl w-full bg-white rounded-2xl shadow-xl p-6">
|
| 115 |
+
<h1 class="text-3xl font-bold text-center text-blue-600 mb-2">Lerne die Uhrzeit!</h1>
|
| 116 |
+
<p class="text-center text-gray-600 mb-6">Schau auf die Uhr und wähle die richtige Zeit aus.</p>
|
| 117 |
+
|
| 118 |
+
<div class="flex flex-col md:flex-row items-center justify-between gap-8 mb-8">
|
| 119 |
+
<!-- Analog Clock -->
|
| 120 |
+
<div class="relative w-64 h-64 mx-auto md:mx-0 clock-face rounded-full">
|
| 121 |
+
<!-- Clock center -->
|
| 122 |
+
<div class="absolute w-4 h-4 bg-blue-600 rounded-full" style="top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 4;"></div>
|
| 123 |
+
|
| 124 |
+
<!-- Clock hands -->
|
| 125 |
+
<div class="hour-hand absolute"></div>
|
| 126 |
+
<div class="minute-hand absolute"></div>
|
| 127 |
+
|
| 128 |
+
<!-- Minute ticks -->
|
| 129 |
+
<div id="clock-ticks"></div>
|
| 130 |
+
|
| 131 |
+
<!-- Clock numbers 1-12 - mathematically precise circular positioning -->
|
| 132 |
+
<!-- Using polar coordinates with radius 42% of clock diameter -->
|
| 133 |
+
<div class="clock-number" style="top: 13.4%; left: 75%;">1</div>
|
| 134 |
+
<div class="clock-number" style="top: 7.5%; left: 50%;">12</div>
|
| 135 |
+
<div class="clock-number" style="top: 13.4%; left: 25%;">11</div>
|
| 136 |
+
<div class="clock-number" style="top: 25%; left: 7.5%;">10</div>
|
| 137 |
+
<div class="clock-number" style="top: 50%; left: 13.4%;">9</div>
|
| 138 |
+
<div class="clock-number" style="top: 75%; left: 7.5%;">8</div>
|
| 139 |
+
<div class="clock-number" style="top: 86.6%; left: 25%;">7</div>
|
| 140 |
+
<div class="clock-number" style="top: 92.5%; left: 50%;">6</div>
|
| 141 |
+
<div class="clock-number" style="top: 86.6%; left: 75%;">5</div>
|
| 142 |
+
<div class="clock-number" style="top: 75%; left: 92.5%;">4</div>
|
| 143 |
+
<div class="clock-number" style="top: 50%; left: 86.6%;">3</div>
|
| 144 |
+
<div class="clock-number" style="top: 25%; left: 92.5%;">2</div>
|
| 145 |
+
</div>
|
| 146 |
+
|
| 147 |
+
<!-- Game info -->
|
| 148 |
+
<div class="flex-1">
|
| 149 |
+
<div class="bg-blue-100 rounded-lg p-4 mb-4">
|
| 150 |
+
<h2 class="font-bold text-blue-800 mb-2">Punkte: <span id="score">0</span></h2>
|
| 151 |
+
<div class="w-full bg-gray-200 rounded-full h-4">
|
| 152 |
+
<div id="progress-bar" class="bg-blue-600 h-4 rounded-full" style="width: 0%"></div>
|
| 153 |
+
</div>
|
| 154 |
+
</div>
|
| 155 |
+
|
| 156 |
+
<button id="hint-btn" class="bg-yellow-400 hover:bg-yellow-500 text-white font-bold py-2 px-4 rounded-full mb-4 transition-all flex items-center justify-center">
|
| 157 |
+
<i class="fas fa-lightbulb mr-2"></i> Tipp anzeigen
|
| 158 |
+
</button>
|
| 159 |
+
|
| 160 |
+
<div id="hint-container" class="hidden bg-blue-100 p-3 rounded-lg mb-4">
|
| 161 |
+
<p class="text-blue-800 font-medium" id="hint-text"></p>
|
| 162 |
+
</div>
|
| 163 |
+
</div>
|
| 164 |
+
</div>
|
| 165 |
+
|
| 166 |
+
<!-- Answer options -->
|
| 167 |
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6" id="options-container">
|
| 168 |
+
<!-- Options will be inserted here by JavaScript -->
|
| 169 |
+
</div>
|
| 170 |
+
|
| 171 |
+
<!-- Feedback message -->
|
| 172 |
+
<div id="feedback" class="text-center text-xl font-bold py-4 hidden"></div>
|
| 173 |
+
|
| 174 |
+
<!-- Next button -->
|
| 175 |
+
<button id="next-btn" class="hidden w-full bg-green-500 hover:bg-green-600 text-white font-bold py-3 px-4 rounded-lg transition-all">
|
| 176 |
+
Weiter <i class="fas fa-arrow-right ml-2"></i>
|
| 177 |
+
</button>
|
| 178 |
+
</div>
|
| 179 |
+
|
| 180 |
+
<!-- Audio elements -->
|
| 181 |
+
<audio id="correct-sound" src="https://assets.mixkit.co/sfx/preview/mixkit-correct-answer-tone-2870.mp3"></audio>
|
| 182 |
+
<audio id="wrong-sound" src="https://assets.mixkit.co/sfx/preview/mixkit-wrong-answer-fail-notification-946.mp3"></audio>
|
| 183 |
+
|
| 184 |
+
<script>
|
| 185 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 186 |
+
// DOM elements
|
| 187 |
+
const clockFace = document.querySelector('.clock-face');
|
| 188 |
+
const hourHand = document.querySelector('.hour-hand');
|
| 189 |
+
const minuteHand = document.querySelector('.minute-hand');
|
| 190 |
+
const optionsContainer = document.getElementById('options-container');
|
| 191 |
+
const feedbackElement = document.getElementById('feedback');
|
| 192 |
+
const nextButton = document.getElementById('next-btn');
|
| 193 |
+
const hintButton = document.getElementById('hint-btn');
|
| 194 |
+
const hintContainer = document.getElementById('hint-container');
|
| 195 |
+
const hintText = document.getElementById('hint-text');
|
| 196 |
+
const scoreElement = document.getElementById('score');
|
| 197 |
+
const progressBar = document.getElementById('progress-bar');
|
| 198 |
+
const correctSound = document.getElementById('correct-sound');
|
| 199 |
+
const wrongSound = document.getElementById('wrong-sound');
|
| 200 |
+
const clockTicks = document.getElementById('clock-ticks');
|
| 201 |
+
|
| 202 |
+
// Game variables
|
| 203 |
+
let currentHour = 0;
|
| 204 |
+
let currentMinute = 0;
|
| 205 |
+
let correctAnswer = '';
|
| 206 |
+
let score = 0;
|
| 207 |
+
let questionsAnswered = 0;
|
| 208 |
+
const totalQuestions = 10;
|
| 209 |
+
let hintUsed = false;
|
| 210 |
+
|
| 211 |
+
// Initialize game
|
| 212 |
+
initGame();
|
| 213 |
+
|
| 214 |
+
function initGame() {
|
| 215 |
+
// Create minute ticks
|
| 216 |
+
createMinuteTicks();
|
| 217 |
+
generateRandomTime();
|
| 218 |
+
updateClock();
|
| 219 |
+
generateOptions();
|
| 220 |
+
updateScore();
|
| 221 |
+
questionsAnswered = 0;
|
| 222 |
+
updateProgressBar();
|
| 223 |
+
hintContainer.classList.add('hidden');
|
| 224 |
+
hintUsed = false;
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
function createMinuteTicks() {
|
| 228 |
+
clockTicks.innerHTML = '';
|
| 229 |
+
for (let i = 0; i < 60; i++) {
|
| 230 |
+
const tick = document.createElement('div');
|
| 231 |
+
tick.className = 'clock-tick';
|
| 232 |
+
tick.style.transform = `rotate(${i * 6}deg)`;
|
| 233 |
+
|
| 234 |
+
// Make the 5-minute ticks longer
|
| 235 |
+
if (i % 5 === 0) {
|
| 236 |
+
tick.style.height = '12px';
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
clockTicks.appendChild(tick);
|
| 240 |
+
}
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
function generateRandomTime() {
|
| 244 |
+
// Generate random hour (1-12) and minute (0-55, in 5-minute increments)
|
| 245 |
+
currentHour = Math.floor(Math.random() * 12) + 1;
|
| 246 |
+
currentMinute = Math.floor(Math.random() * 12) * 5;
|
| 247 |
+
|
| 248 |
+
// Format the correct answer
|
| 249 |
+
const formattedHour = currentHour < 10 ? `0${currentHour}` : currentHour;
|
| 250 |
+
const formattedMinute = currentMinute < 10 ? `0${currentMinute}` : currentMinute;
|
| 251 |
+
correctAnswer = `${formattedHour}:${formattedMinute}`;
|
| 252 |
+
|
| 253 |
+
console.log(`Correct time set to: ${currentHour}:${currentMinute}`);
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
function updateClock() {
|
| 257 |
+
// Calculate angles for clock hands
|
| 258 |
+
// Hour hand moves 30 degrees per hour + 0.5 degrees per minute
|
| 259 |
+
const hourAngle = (currentHour % 12) * 30 + (currentMinute / 2) + 90;
|
| 260 |
+
// Minute hand moves 6 degrees per minute
|
| 261 |
+
const minuteAngle = currentMinute * 6 + 90;
|
| 262 |
+
|
| 263 |
+
// Apply rotation to clock hands
|
| 264 |
+
hourHand.style.transform = `rotate(${hourAngle}deg)`;
|
| 265 |
+
minuteHand.style.transform = `rotate(${minuteAngle}deg)`;
|
| 266 |
+
|
| 267 |
+
console.log(`Clock updated - Hour: ${currentHour}, Minute: ${currentMinute}`);
|
| 268 |
+
console.log(`Hour angle: ${hourAngle}°, Minute angle: ${minuteAngle}°`);
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
function generateOptions() {
|
| 272 |
+
optionsContainer.innerHTML = '';
|
| 273 |
+
|
| 274 |
+
// Create 3 options (1 correct, 2 incorrect)
|
| 275 |
+
const options = [correctAnswer];
|
| 276 |
+
|
| 277 |
+
// Generate 2 incorrect options
|
| 278 |
+
while (options.length < 3) {
|
| 279 |
+
let wrongHour = Math.floor(Math.random() * 12) + 1;
|
| 280 |
+
let wrongMinute = Math.floor(Math.random() * 12) * 5;
|
| 281 |
+
|
| 282 |
+
// Make sure wrong time is different from correct time
|
| 283 |
+
if (wrongHour === currentHour && wrongMinute === currentMinute) {
|
| 284 |
+
wrongHour = (wrongHour % 12) + 1;
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
const formattedWrongHour = wrongHour < 10 ? `0${wrongHour}` : wrongHour;
|
| 288 |
+
const formattedWrongMinute = wrongMinute < 10 ? `0${wrongMinute}` : wrongMinute;
|
| 289 |
+
const wrongOption = `${formattedWrongHour}:${formattedWrongMinute}`;
|
| 290 |
+
|
| 291 |
+
// Make sure all options are unique
|
| 292 |
+
if (!options.includes(wrongOption)) {
|
| 293 |
+
options.push(wrongOption);
|
| 294 |
+
}
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
// Shuffle options
|
| 298 |
+
options.sort(() => Math.random() - 0.5);
|
| 299 |
+
|
| 300 |
+
// Create buttons for each option
|
| 301 |
+
options.forEach(option => {
|
| 302 |
+
const button = document.createElement('button');
|
| 303 |
+
button.textContent = option;
|
| 304 |
+
button.className = 'bg-blue-100 hover:bg-blue-200 text-blue-800 font-bold py-4 px-4 rounded-lg text-xl transition-all';
|
| 305 |
+
button.addEventListener('click', () => checkAnswer(option));
|
| 306 |
+
optionsContainer.appendChild(button);
|
| 307 |
+
});
|
| 308 |
+
|
| 309 |
+
// Generate hint text
|
| 310 |
+
generateHint();
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
function generateHint() {
|
| 314 |
+
const hourText = currentHour === 1 ? 'Stunde' : 'Stunden';
|
| 315 |
+
const minuteText = currentMinute === 1 ? 'Minute' : 'Minuten';
|
| 316 |
+
|
| 317 |
+
hintText.textContent = `Der große Zeiger (blau) zeigt auf ${currentMinute} ${minuteText} und der kleine Zeiger (rot) zeigt auf ${currentHour} ${hourText}.`;
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
function checkAnswer(selectedAnswer) {
|
| 321 |
+
// Disable all option buttons
|
| 322 |
+
const optionButtons = document.querySelectorAll('#options-container button');
|
| 323 |
+
optionButtons.forEach(button => {
|
| 324 |
+
button.disabled = true;
|
| 325 |
+
button.classList.remove('hover:bg-blue-200');
|
| 326 |
+
|
| 327 |
+
if (button.textContent === correctAnswer) {
|
| 328 |
+
button.classList.add('correct-answer');
|
| 329 |
+
} else if (button.textContent === selectedAnswer && selectedAnswer !== correctAnswer) {
|
| 330 |
+
button.classList.add('wrong-answer');
|
| 331 |
+
}
|
| 332 |
+
});
|
| 333 |
+
|
| 334 |
+
// Check if answer is correct
|
| 335 |
+
if (selectedAnswer === correctAnswer) {
|
| 336 |
+
// Correct answer
|
| 337 |
+
feedbackElement.textContent = 'Richtig! 🎉';
|
| 338 |
+
feedbackElement.className = 'text-center text-xl font-bold py-4 text-green-600';
|
| 339 |
+
correctSound.play();
|
| 340 |
+
score += hintUsed ? 5 : 10; // Give less points if hint was used
|
| 341 |
+
createConfetti();
|
| 342 |
+
} else {
|
| 343 |
+
// Wrong answer
|
| 344 |
+
feedbackElement.textContent = `Falsch! Die richtige Antwort ist ${correctAnswer}.`;
|
| 345 |
+
feedbackElement.className = 'text-center text-xl font-bold py-4 text-red-600';
|
| 346 |
+
wrongSound.play();
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
feedbackElement.classList.remove('hidden');
|
| 350 |
+
nextButton.classList.remove('hidden');
|
| 351 |
+
questionsAnswered++;
|
| 352 |
+
updateScore();
|
| 353 |
+
updateProgressBar();
|
| 354 |
+
}
|
| 355 |
+
|
| 356 |
+
function createConfetti() {
|
| 357 |
+
const colors = ['#EF4444', '#3B82F6', '#10B981', '#F59E0B', '#8B5CF6'];
|
| 358 |
+
|
| 359 |
+
for (let i = 0; i < 50; i++) {
|
| 360 |
+
const confetti = document.createElement('div');
|
| 361 |
+
confetti.className = 'confetti';
|
| 362 |
+
confetti.style.left = Math.random() * 100 + 'vw';
|
| 363 |
+
confetti.style.backgroundColor = colors[Math.floor(Math.random() * colors.length)];
|
| 364 |
+
confetti.style.animationDuration = Math.random() * 2 + 2 + 's';
|
| 365 |
+
confetti.style.animationDelay = Math.random() * 2 + 's';
|
| 366 |
+
|
| 367 |
+
// Random shape (circle or square)
|
| 368 |
+
if (Math.random() > 0.5) {
|
| 369 |
+
confetti.style.borderRadius = '50%';
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
document.body.appendChild(confetti);
|
| 373 |
+
|
| 374 |
+
// Remove confetti after animation
|
| 375 |
+
setTimeout(() => {
|
| 376 |
+
confetti.remove();
|
| 377 |
+
}, 5000);
|
| 378 |
+
}
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
function updateScore() {
|
| 382 |
+
scoreElement.textContent = score;
|
| 383 |
+
}
|
| 384 |
+
|
| 385 |
+
function updateProgressBar() {
|
| 386 |
+
const progress = (questionsAnswered / totalQuestions) * 100;
|
| 387 |
+
progressBar.style.width = `${progress}%`;
|
| 388 |
+
|
| 389 |
+
if (questionsAnswered >= totalQuestions) {
|
| 390 |
+
// Game over
|
| 391 |
+
setTimeout(() => {
|
| 392 |
+
alert(`Spiel beendet! Dein Punktestand: ${score}`);
|
| 393 |
+
initGame(); // Restart game
|
| 394 |
+
}, 1000);
|
| 395 |
+
}
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
// Event listeners
|
| 399 |
+
nextButton.addEventListener('click', function() {
|
| 400 |
+
feedbackElement.classList.add('hidden');
|
| 401 |
+
nextButton.classList.add('hidden');
|
| 402 |
+
generateRandomTime();
|
| 403 |
+
updateClock();
|
| 404 |
+
generateOptions();
|
| 405 |
+
hintContainer.classList.add('hidden');
|
| 406 |
+
hintUsed = false;
|
| 407 |
+
});
|
| 408 |
+
|
| 409 |
+
hintButton.addEventListener('click', function() {
|
| 410 |
+
hintContainer.classList.toggle('hidden');
|
| 411 |
+
if (!hintContainer.classList.contains('hidden')) {
|
| 412 |
+
hintUsed = true;
|
| 413 |
+
}
|
| 414 |
+
});
|
| 415 |
+
|
| 416 |
+
// Make clock draggable for fun
|
| 417 |
+
let isDragging = false;
|
| 418 |
+
let startX, startY, initialX, initialY;
|
| 419 |
+
|
| 420 |
+
clockFace.addEventListener('mousedown', function(e) {
|
| 421 |
+
isDragging = true;
|
| 422 |
+
startX = e.clientX;
|
| 423 |
+
startY = e.clientY;
|
| 424 |
+
initialX = clockFace.offsetLeft;
|
| 425 |
+
initialY = clockFace.offsetTop;
|
| 426 |
+
clockFace.style.cursor = 'grabbing';
|
| 427 |
+
clockFace.style.transition = 'none';
|
| 428 |
+
document.addEventListener('mousemove', dragClock);
|
| 429 |
+
document.addEventListener('mouseup', stopDrag);
|
| 430 |
+
});
|
| 431 |
+
|
| 432 |
+
function dragClock(e) {
|
| 433 |
+
if (!isDragging) return;
|
| 434 |
+
const dx = e.clientX - startX;
|
| 435 |
+
const dy = e.clientY - startY;
|
| 436 |
+
clockFace.style.left = `${initialX + dx}px`;
|
| 437 |
+
clockFace.style.top = `${initialY + dy}px`;
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
function stopDrag() {
|
| 441 |
+
isDragging = false;
|
| 442 |
+
clockFace.style.cursor = 'grab';
|
| 443 |
+
clockFace.style.transition = 'all 0.3s ease';
|
| 444 |
+
document.removeEventListener('mousemove', dragClock);
|
| 445 |
+
document.removeEventListener('mouseup', stopDrag);
|
| 446 |
+
|
| 447 |
+
// Snap back to original position after a delay
|
| 448 |
+
setTimeout(() => {
|
| 449 |
+
clockFace.style.left = '';
|
| 450 |
+
clockFace.style.top = '';
|
| 451 |
+
}, 1000);
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
// Also make clock draggable on touch devices
|
| 455 |
+
clockFace.addEventListener('touchstart', function(e) {
|
| 456 |
+
isDragging = true;
|
| 457 |
+
startX = e.touches[0].clientX;
|
| 458 |
+
startY = e.touches[0].clientY;
|
| 459 |
+
initialX = clockFace.offsetLeft;
|
| 460 |
+
initialY = clockFace.offsetTop;
|
| 461 |
+
clockFace.style.cursor = 'grabbing';
|
| 462 |
+
clockFace.style.transition = 'none';
|
| 463 |
+
e.preventDefault();
|
| 464 |
+
});
|
| 465 |
+
|
| 466 |
+
clockFace.addEventListener('touchmove', function(e) {
|
| 467 |
+
if (!isDragging) return;
|
| 468 |
+
const dx = e.touches[0].clientX - startX;
|
| 469 |
+
const dy = e.touches[0].clientY - startY;
|
| 470 |
+
clockFace.style.left = `${initialX + dx}px`;
|
| 471 |
+
clockFace.style.top = `${initialY + dy}px`;
|
| 472 |
+
e.preventDefault();
|
| 473 |
+
});
|
| 474 |
+
|
| 475 |
+
clockFace.addEventListener('touchend', function() {
|
| 476 |
+
isDragging = false;
|
| 477 |
+
clockFace.style.cursor = 'grab';
|
| 478 |
+
clockFace.style.transition = 'all 0.3s ease';
|
| 479 |
+
|
| 480 |
+
// Snap back to original position after a delay
|
| 481 |
+
setTimeout(() => {
|
| 482 |
+
clockFace.style.left = '';
|
| 483 |
+
clockFace.style.top = '';
|
| 484 |
+
}, 1000);
|
| 485 |
+
});
|
| 486 |
+
});
|
| 487 |
+
</script>
|
| 488 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=ThetaPhiPsi/the-clock" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 489 |
+
</html>
|