-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
290 lines (263 loc) · 11 KB
/
index.html
File metadata and controls
290 lines (263 loc) · 11 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cute Egg Timer</title>
<!-- Load Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Load Tone.js for the timer chime -->
<script src="https://cdn.jsdelivr.net/npm/tone@14.7.58/build/Tone.min.js"></script>
<style>
/* Custom styles for the cute aesthetic */
body {
font-family: 'Inter', sans-serif;
background-color: #f7e1e6; /* Soft pink background */
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
padding: 1rem;
}
.app-container {
background-color: #ffffff;
border-radius: 2rem;
box-shadow: 0 20px 25px -5px rgba(234, 110, 142, 0.2), 0 8px 10px -6px rgba(234, 110, 142, 0.1);
max-width: 400px;
width: 100%;
padding: 2rem;
text-align: center;
}
.timer-display {
font-size: 4rem;
font-weight: 700;
color: #ea6e8e; /* Main pink color */
margin: 1.5rem 0;
transition: transform 0.3s ease-in-out;
}
.vibrate {
animation: shake 0.5s;
animation-iteration-count: infinite;
}
@keyframes shake {
0% { transform: translate(1px, 1px) rotate(0deg); }
20% { transform: translate(-1px, -2px) rotate(-1deg); }
40% { transform: translate(-3px, 0px) rotate(1deg); }
60% { transform: translate(3px, 2px) rotate(0deg); }
80% { transform: translate(1px, -1px) rotate(-1deg); }
100% { transform: translate(-1px, 2px) rotate(1deg); }
}
.main-btn {
padding: 0.75rem 2rem;
font-weight: 600;
border-radius: 1.5rem;
transition: all 0.2s;
cursor: pointer;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}
.primary-btn {
background-color: #ea6e8e;
color: white;
}
.primary-btn:hover {
background-color: #d15c7a;
transform: translateY(-2px);
box-shadow: 0 6px 10px -1px rgba(234, 110, 142, 0.3);
}
.secondary-btn {
background-color: #fce7f3;
color: #ea6e8e;
border: 2px solid #ea6e8e;
}
.secondary-btn:hover {
background-color: #f9d7ee;
transform: translateY(-1px);
}
.menu-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 1rem;
margin-top: 1.5rem;
}
.menu-item {
display: flex;
flex-direction: column;
align-items: center;
padding: 1rem;
background-color: #ffe6f0; /* Lighter pink background for options */
border-radius: 1rem;
border: 2px solid #ea6e8e;
transition: transform 0.2s, box-shadow 0.2s;
cursor: pointer;
}
.menu-item:hover {
transform: translateY(-3px);
box-shadow: 0 8px 15px -3px rgba(234, 110, 142, 0.3);
}
.egg-icon {
font-size: 2.5rem;
margin-bottom: 0.5rem;
}
</style>
</head>
<body>
<div class="app-container">
<!-- 1. START PAGE -->
<div id="start-page" class="page">
<div class="text-4xl font-bold text-gray-800 mb-6">🥚</div>
<h1 class="text-3xl font-semibold text-gray-800 mb-4">Let's Time Your Egg!</h1>
<p class="text-gray-500 mb-8">Ready to cook the perfect breakfast?</p>
<button class="main-btn primary-btn" onclick="showPage('menu-page')">Start Timer</button>
</div>
<!-- 2. MENU PAGE -->
<div id="menu-page" class="page hidden">
<h1 class="text-2xl font-semibold text-gray-800 mb-6">Egg Timer: What are you making today?</h1>
<div class="menu-grid">
<div class="menu-item" onclick="startCooking('Soft Boiled', 450)"> <!-- 7:30 -->
<span class="egg-icon">🍳</span>
<span class="font-bold text-lg text-[#ea6e8e]">Soft Boiled</span>
<span class="text-sm text-gray-600">7:30 min</span>
</div>
<div class="menu-item" onclick="startCooking('Hard Boiled', 660)"> <!-- 11:00 -->
<span class="egg-icon">🥚</span>
<span class="font-bold text-lg text-[#ea6e8e]">Hard Boiled</span>
<span class="text-sm text-gray-600">11:00 min</span>
</div>
<div class="menu-item" onclick="startCooking('Fried Egg', 150)"> <!-- 2:30 -->
<span class="egg-icon">🔥</span>
<span class="font-bold text-lg text-[#ea6e8e]">Fried Egg</span>
<span class="text-sm text-gray-600">2:30 min</span>
</div>
<div class="menu-item" onclick="startCooking('Scrambled Egg', 240)"> <!-- 4:00 -->
<span class="egg-icon">🥄</span>
<span class="font-bold text-lg text-[#ea6e8e]">Scrambled</span>
<span class="text-sm text-gray-600">4:00 min</span>
</div>
</div>
<button class="main-btn secondary-btn mt-6" onclick="showPage('start-page')">Back</button>
</div>
<!-- 3. TIMER PAGE -->
<div id="timer-page" class="page hidden">
<h2 id="timer-type" class="text-xl font-medium text-gray-700 mb-2"></h2>
<div id="timer-display" class="timer-display">00:00</div>
<p id="timer-message" class="text-gray-500 mb-8">Cooking in progress...</p>
<button class="main-btn primary-btn" onclick="cancelTimer()">Cancel Timer</button>
</div>
<!-- 4. ENDING SCREEN -->
<div id="ending-page" class="page hidden">
<div class="text-4xl font-bold text-[#4CAF50] mb-6">🎉</div>
<h2 class="text-3xl font-semibold text-gray-800 mb-4">Time's Up!</h2>
<p class="text-gray-600 mb-8">Your egg is ready. Enjoy your perfect <span id="finished-egg-type" class="font-bold text-[#ea6e8e]"></span>!</p>
<div class="flex justify-center space-x-4">
<button class="main-btn secondary-btn" onclick="snoozeTimer()">Snooze (1 min)</button>
<button class="main-btn primary-btn" onclick="closeTimer()">Close</button>
</div>
</div>
</div>
<script>
// --- Core Application State and Setup ---
let currentPage = 'start-page';
let timeRemaining = 0;
let timerInterval = null;
let currentEggType = '';
let timerRunning = false;
// Tone.js Synth for simple sound alert
const synth = new Tone.Synth().toDestination();
// Timer settings in seconds
const TIMES = {
'Soft Boiled': 450,
'Hard Boiled': 660,
'Fried Egg': 150,
'Scrambled Egg': 240,
'Snooze': 60
};
// --- Page Navigation Logic ---
function showPage(pageName) {
document.querySelectorAll('.page').forEach(page => {
page.classList.add('hidden');
});
document.getElementById(pageName).classList.remove('hidden');
currentPage = pageName;
// Ensure no vibration if switching away from the ending page
document.getElementById('timer-display').classList.remove('vibrate');
}
// --- Timer Start Logic ---
function startCooking(type, duration) {
// Stop any existing timer first
if (timerInterval) clearInterval(timerInterval);
currentEggType = type;
timeRemaining = duration;
timerRunning = true;
// Update timer page content
document.getElementById('timer-type').textContent = `Making a ${type} Egg`;
document.getElementById('timer-message').textContent = "Cooking in progress...";
document.getElementById('timer-display').classList.remove('vibrate');
// Start the countdown
updateTimerDisplay();
timerInterval = setInterval(countdown, 1000);
showPage('timer-page');
}
// --- Timer Countdown and Display ---
function countdown() {
if (timeRemaining <= 0) {
endTimer();
return;
}
timeRemaining--;
updateTimerDisplay();
}
function updateTimerDisplay() {
const minutes = Math.floor(timeRemaining / 60);
const seconds = timeRemaining % 60;
const display = `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
document.getElementById('timer-display').textContent = display;
}
// --- Timer End Logic ---
function endTimer() {
clearInterval(timerInterval);
timerRunning = false;
// Play a cute chime sound
synth.triggerAttackRelease("C5", "8n");
synth.triggerAttackRelease("E5", "8n", "+0.2");
synth.triggerAttackRelease("G5", "8n", "+0.4");
// Set ending screen text and show page
document.getElementById('finished-egg-type').textContent = currentEggType;
showPage('ending-page');
// Make the timer display vibrate for attention (even on the ending page for effect)
document.getElementById('timer-display').classList.add('vibrate');
}
// --- Ending Screen Controls ---
function snoozeTimer() {
// Snooze is set to 1 minute (60 seconds)
startCooking(currentEggType, TIMES['Snooze']);
// Update message to indicate it's a snooze
document.getElementById('timer-type').textContent = `Snooze for ${currentEggType}`;
document.getElementById('timer-message').textContent = "1 minute of extra cooking time...";
}
function closeTimer() {
clearInterval(timerInterval);
timerRunning = false;
currentEggType = '';
showPage('start-page');
}
// --- Timer Cancellation Logic (MODIFIED) ---
function cancelTimer() {
// Clear the interval
if (timerInterval) {
clearInterval(timerInterval);
}
// Reset state variables
timerRunning = false;
timeRemaining = 0;
currentEggType = '';
// Navigate back to the menu page
showPage('menu-page');
}
// --- Initialization ---
window.onload = () => {
showPage('start-page');
};
</script>
</body>
</html>