-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
425 lines (374 loc) · 11.5 KB
/
index.html
File metadata and controls
425 lines (374 loc) · 11.5 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
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Epoch Express - A Terrible Date Picker</title>
<style>
body {
font-family: "Courier New", monospace;
background: linear-gradient(135deg, #1e3c72, #2a5298);
color: white;
margin: 0;
padding: 20px;
min-height: 100vh;
}
.container {
max-width: 800px;
margin: 0 auto;
text-align: center;
}
h1 {
color: #ffaa00;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
margin-bottom: 10px;
}
.subtitle {
color: #ccc;
margin-bottom: 30px;
font-style: italic;
}
.game-container {
background: rgba(0, 0, 0, 0.3);
border-radius: 10px;
padding: 20px;
margin: 20px 0;
border: 2px solid #ffaa00;
display: flex;
justify-content: center;
}
.info-panel {
background: rgba(0, 0, 0, 0.5);
border-radius: 8px;
padding: 15px;
margin: 20px 0;
text-align: left;
}
.selected-date {
background: #2a5298;
border: 2px solid #4caf50;
border-radius: 5px;
padding: 10px;
margin: 10px 0;
font-weight: bold;
}
pre {
background: #1a1a1a;
border: 1px solid #333;
border-radius: 5px;
padding: 15px;
margin: 10px 0;
overflow-x: auto;
}
code {
font-family: "Courier New", monospace;
font-size: 14px;
color: #f8f8f2;
display: block;
white-space: pre;
}
button {
background: #ffaa00;
color: #000;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
font-family: "Courier New", monospace;
font-weight: bold;
margin: 5px;
}
button:hover {
background: #ffcc44;
}
.config-controls {
display: grid;
gap: 15px;
margin: 15px 0;
}
.config-group {
display: flex;
flex-direction: column;
gap: 5px;
}
.checkbox-group {
display: flex;
flex-direction: row;
align-items: center;
gap: 10px;
}
.config-group label {
font-weight: bold;
color: #ffaa00;
font-size: 14px;
}
.config-group input,
.config-group select {
padding: 8px 12px;
border: 1px solid #555;
border-radius: 4px;
background: #333;
color: #fff;
font-size: 14px;
font-family: inherit;
}
.config-group input[type="number"] {
width: 120px;
}
.config-group input[type="color"] {
width: 60px;
height: 40px;
padding: 2px;
cursor: pointer;
}
.config-group select {
width: 200px;
cursor: pointer;
}
.config-description {
font-size: 12px;
color: #aaa;
font-style: italic;
}
.web-component-info {
background: linear-gradient(135deg, #2a2a2a, #1a1a1a);
border: 2px solid #ffaa00;
border-radius: 10px;
padding: 20px;
margin: 20px 0;
text-align: center;
}
.web-component-info h2 {
color: #ffaa00;
margin-top: 0;
font-size: 24px;
}
.web-component-info p {
color: #fff;
font-size: 16px;
line-height: 1.6;
margin: 15px 0;
}
.usage-example {
background: #1a1a1a;
border: 1px solid #444;
border-radius: 8px;
padding: 15px;
margin: 20px 0;
text-align: left;
}
.usage-example h3 {
color: #ffaa00;
margin-top: 0;
font-size: 18px;
}
</style>
</head>
<body>
<div class="container">
<h1>🚗 Epoch Express - A Terrible Date Picker</h1>
<p class="subtitle">
The worst way to select a date - now as a driving game!
</p>
<div class="web-component-info">
<p>
This is a <strong>genuine web component</strong> that you can use in
your own projects! Simply include the JavaScript file and use the
custom element in your HTML.
</p>
<div class="usage-example">
<h3>Quick Start:</h3>
<pre><code><!-- Include the component -->
<script src="epoch-express.js"></script>
<!-- Use it anywhere in your HTML -->
<epoch-express />
<!-- Listen for date selection -->
<script>
const picker = document.querySelector('epoch-express');
picker.addEventListener('dateselected', (e) => {
console.log('Selected date:', e.detail.date);
});
</script></code></pre>
</div>
</div>
<div class="game-container">
<epoch-express id="datePicker" />
</div>
<div class="info-panel">
<h3>Selected Date:</h3>
<div id="selectedDate" class="selected-date">
No date selected yet. Start driving to see the timestamp increase!
</div>
<button onclick="resetGame()">Reset Game</button>
</div>
<div class="info-panel">
<h3>Live Configuration:</h3>
<div class="config-controls">
<div class="config-group">
<label for="daysPerSecond">Days per Second:</label>
<input
type="number"
id="daysPerSecond"
value="350"
min="1"
max="1000"
step="10"
/>
<span class="config-description"
>Higher = faster time progression</span
>
</div>
<div class="config-group">
<label for="updateInterval">Update Interval (ms):</label>
<input
type="number"
id="updateInterval"
value="500"
min="100"
max="2000"
step="100"
/>
<span class="config-description">How often events fire</span>
</div>
<div class="config-group">
<label for="carColor">Car Color:</label>
<input type="color" id="carColor" value="#bada55" />
<span class="config-description">Customize your car</span>
</div>
<div class="config-group">
<label for="difficulty">Difficulty:</label>
<select id="difficulty">
<option value="easy">Easy (Few obstacles)</option>
<option value="normal" selected>Normal (Default)</option>
<option value="hard">Hard (Many obstacles)</option>
</select>
<span class="config-description">Obstacle spawn rate</span>
</div>
<div class="config-group">
<div class="checkbox-group">
<label for="reverse">Enable Reverse:</label>
<input type="checkbox" id="reverse" />
</div>
<span class="config-description"
>Allow driving backward in time</span
>
</div>
</div>
</div>
<div class="info-panel">
<h3>Web Component API:</h3>
<pre><code>// Get the selected date
const date = document.getElementById('datePicker').value;
// Listen for date changes (fires every 0.5 seconds while driving)
datePicker.addEventListener('dateselected', (e) => {
console.log('Selected date:', e.detail.date);
console.log('Timestamp:', e.detail.timestamp);
});
// Reset the game
datePicker.reset();
// Select current date immediately (bypasses update interval)
datePicker.selectCurrentDate();</code></pre>
</div>
<div class="info-panel">
<h3>Configuration Options:</h3>
<pre><code><epoch-express
days-per-second="350"
update-interval="500"
car-color="#bada55"
difficulty="normal"
></epoch-express></code></pre>
<h4>Attribute Descriptions:</h4>
<ul>
<li>
<strong>days-per-second</strong> (number): How many days pass per
second of driving. Higher values = faster time progression. Default:
350
</li>
<li>
<strong>update-interval</strong> (number): How often the
'dateselected' event fires in milliseconds. Lower values = more
frequent updates. Default: 500
</li>
<li>
<strong>car-color</strong> (string): Custom car color as a hex color
code. Default: "#bada55"
</li>
<li>
<strong>difficulty</strong> (string): Game difficulty level.
Currently unused, reserved for future features. Default: "normal"
</li>
</ul>
</div>
</div>
<script src="epoch-express.js"></script>
<script>
const datePicker = document.getElementById("datePicker");
const selectedDateDiv = document.getElementById("selectedDate");
// Listen for date changes
datePicker.addEventListener("dateselected", (e) => {
const date = e.detail.date;
const timestamp = e.detail.timestamp;
console.log(date, timestamp);
selectedDateDiv.innerHTML = `
<strong>Selected Date:</strong> ${date.toLocaleString()}<br>
<strong>Epoch Timestamp:</strong> ${Math.floor(timestamp)}<br>
<strong>ISO String:</strong> ${date.toISOString()}
`;
});
function resetGame() {
datePicker.reset();
selectedDateDiv.textContent =
"Game reset! Start driving to see the timestamp increase.";
}
function applyConfiguration() {
// Get values from form inputs
const daysPerSecond = document.getElementById("daysPerSecond").value;
const updateInterval = document.getElementById("updateInterval").value;
const carColor = document.getElementById("carColor").value;
const difficulty = document.getElementById("difficulty").value;
const reverse = document.getElementById("reverse").checked;
// Apply configuration to the date picker
datePicker.setAttribute("days-per-second", daysPerSecond);
datePicker.setAttribute("update-interval", updateInterval);
datePicker.setAttribute("car-color", carColor);
datePicker.setAttribute("difficulty", difficulty);
if (reverse) {
datePicker.setAttribute("reverse", "");
} else {
datePicker.removeAttribute("reverse");
}
// Show confirmation
console.log("Configuration applied:", {
daysPerSecond,
updateInterval,
carColor,
difficulty,
reverse,
});
}
// Add event listeners for immediate updates
document.addEventListener("DOMContentLoaded", function () {
// Days per second
document
.getElementById("daysPerSecond")
.addEventListener("input", applyConfiguration);
// Update interval
document
.getElementById("updateInterval")
.addEventListener("input", applyConfiguration);
// Car color
document
.getElementById("carColor")
.addEventListener("change", applyConfiguration);
// Difficulty
document
.getElementById("difficulty")
.addEventListener("change", applyConfiguration);
// Reverse checkbox
document
.getElementById("reverse")
.addEventListener("change", applyConfiguration);
});
</script>
</body>
</html>