-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.htm
More file actions
370 lines (340 loc) · 12.4 KB
/
Copy pathindex.htm
File metadata and controls
370 lines (340 loc) · 12.4 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Rocket Launch Panel</title>
<style>
body {
margin: 0;
height: 100vh;
background-color: #2b2b2b;
display: flex;
gap: 12px;
padding: 12px;
box-sizing: border-box;
font-family: sans-serif;
color: white;
overflow: hidden; /* hide scrollbars */
}
.left-panel, .right-panel {
display: flex;
flex-direction: column;
gap: 12px;
flex-shrink: 0;
}
/* Use flex ratios instead of fixed widths so gap doesn't push right panel to edge */
/*.left-panel { flex: 85 1 0; }*/
.left-panel { width: 85%; }
.right-panel { flex: 15 1 0; }
.panel {
position: relative;
border-radius: 12px;
padding: 12px;
box-sizing: border-box;
flex-shrink: 0;
background: linear-gradient(145deg, #555, #3a3a3a);
box-shadow: 4px 4px 8px rgba(0,0,0,0.6),
-2px -2px 6px rgba(255,255,255,0.05);
display: flex;
justify-content: center;
align-items: center;
}
/* Screws */
.screw {
position: absolute;
width: 14px;
height: 14px;
border-radius: 50%;
background: radial-gradient(circle at 30% 30%, #666, #222);
box-shadow: inset -1px -1px 2px rgba(0,0,0,0.6),
inset 1px 1px 2px rgba(255,255,255,0.3);
}
.screw.tl { top: 6px; left: 6px; }
.screw.tr { top: 6px; right: 6px; }
.screw.bl { bottom: 6px; left: 6px; }
.screw.br { bottom: 6px; right: 6px; }
.screw::before, .screw::after {
content: "";
position: absolute;
background: #222;
}
.screw::before { top: 50%; left: 3px; right: 3px; height: 2px; transform: translateY(-50%); }
.screw::after { left: 50%; top: 3px; bottom: 3px; width: 2px; transform: translateX(-50%); }
/* Flex ratios */
.left-top {
flex: 8; /* 7 parts out of 10 */
display: flex;
justify-content: center;
align-items: center;
min-height: 0; /* important: allows shrinking in flexbox */
}
.left-bottom {
flex: 2; /* 3 parts out of 10 */
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 0;
}
.right-top { flex: 40; }
.right-middle { flex: 30; }
.right-bottom { flex: 30; }
/* Video */
video {
width: 98%; /* fill panel width */
height: 98%; /* fill panel height */
aspect-ratio: 16 / 9; /* maintain aspect ratio clue for browsers */
background: rgb(73, 73, 73);
border-radius: 6px;
object-fit: contain; /* entire video visible; switch to 'cover' to crop */
}
/* Video caption overlay */
#video-caption {
position: absolute;
left: 12px;
right: 12px;
bottom: 28px;
text-align: center;
font-size: 28px;
font-weight: 600;
color: #fff;
text-shadow: 0 2px 4px rgba(0,0,0,0.9), 0 0 6px rgba(0,0,0,0.8);
letter-spacing: 1px;
pointer-events: none;
user-select: none;
line-height: 1.2;
opacity: 1;
transition: opacity 0.35s ease;
}
/* Rocket selection */
#rocket-selection {
display: flex;
justify-content: center; /* keep them centered as a group */
align-items: center;
gap: 12px; /* constant space between rockets */
width: 100%;
height: 100%;
overflow: hidden;
}
.rocket {
flex: 1 1 auto;
/* Increased max-width so rockets appear larger and fill panel better */
max-width: 150px; /* was 100px */
height: auto;
border: 3px solid transparent;
border-radius: 6px;
cursor: pointer;
transition: border 0.3s;
}
/* Allow rocket options to scale with shrinking panel height */
.left-bottom { overflow: hidden; }
#rocket-selection { align-items: stretch; }
.rocket-container { flex: 1 1 0; max-height: 100%; }
/* Reserve ~30px for label (font + margin) so image shrinks instead of clipping */
.rocket-container .rocket { max-height: calc(100% - 38px); width: auto; object-fit: contain; }
/* When panel gets very short, also reduce max-width so height constraint governs */
@media (max-height: 600px) {
.rocket-container .rocket { max-width: 120px; }
}
@media (max-height: 480px) {
.rocket-container .rocket { max-width: 100px; }
}
.rocket.selected { border-color: yellow; }
.rocket-container {
display: flex;
flex-direction: column;
align-items: center;
}
.rocket-label {
margin-top: 5px;
font-size: 28px;
font-weight: bold;
color: #fff;
user-select: none;
}
.rocket.selected + .rocket-label { color: yellow; }
/* Countdown */
#countdown-display {
font-size: 120px;
font-weight: bold;
user-select: none;
}
/* Launch button */
#launch-btn {
width: 140px;
height: 140px;
border-radius: 50%;
border: 4px solid #690000; /* darker red border */
background-color: red;
color: white;
font-size: 28px;
cursor: pointer;
box-shadow: 0 0 20px rgba(255, 0, 0, 0.7);
transition: transform 0.1s;
}
#launch-btn:active { transform: scale(0.95); }
#launch-btn:disabled {
background-color: #550000;
cursor: not-allowed;
box-shadow: none;
}
/* Responsive stacking */
@media (max-width: 800px) {
body { flex-direction: column; }
.left-panel, .right-panel { width: 100%; }
}
/* Logo */
#logo {
max-width: 90%;
max-height: 100%;
object-fit: contain;
filter: drop-shadow(0 2px 4px rgba(255, 255, 255, 0.6));
user-select: none;
pointer-events: none;
}
</style>
</head>
<body>
<div class="left-panel">
<div class="panel left-top">
<video id="rocket-video" playsinline></video>
<div id="video-caption"></div>
<span class="screw tl"></span><span class="screw tr"></span>
<span class="screw bl"></span><span class="screw br"></span>
</div>
<div class="panel left-bottom">
<div id="rocket-selection">
<div class="rocket-container"><img src="rocket1.jpg" class="rocket" data-video="rocket1.mp4" data-rocket-id="1" /><div class="rocket-label">1</div></div>
<div class="rocket-container"><img src="rocket2.jpg" class="rocket" data-video="rocket2.mp4" data-rocket-id="2" /><div class="rocket-label">2</div></div>
<div class="rocket-container"><img src="rocket3.jpg" class="rocket" data-video="rocket3.mp4" data-rocket-id="3" /><div class="rocket-label">3</div></div>
<div class="rocket-container"><img src="rocket4.jpg" class="rocket" data-video="rocket4.mp4" data-rocket-id="4" /><div class="rocket-label">4</div></div>
<div class="rocket-container"><img src="rocket5.jpg" class="rocket" data-video="rocket5.mp4" data-rocket-id="5" /><div class="rocket-label">5</div></div>
<div class="rocket-container"><img src="rocket6.jpg" class="rocket" data-video="rocket6.mp4" data-rocket-id="6" /><div class="rocket-label">6</div></div>
<div class="rocket-container"><img src="rocket7.jpg" class="rocket" data-video="rocket7.mp4" data-rocket-id="7" /><div class="rocket-label">7</div></div>
<div class="rocket-container"><img src="rocket8.jpg" class="rocket" data-video="rocket8.mp4" data-rocket-id="8" /><div class="rocket-label">8</div></div>
</div>
<span class="screw tl"></span><span class="screw tr"></span>
<span class="screw bl"></span><span class="screw br"></span>
</div>
</div>
<div class="right-panel">
<div class="panel right-top">
<img id="logo" src="logo.png" alt="Logo" />
<span class="screw tl"></span><span class="screw tr"></span>
<span class="screw bl"></span><span class="screw br"></span>
</div>
<div class="panel right-middle">
<div id="countdown-display">5</div>
<span class="screw tl"></span><span class="screw tr"></span>
<span class="screw bl"></span><span class="screw br"></span>
</div>
<div class="panel right-bottom">
<button id="launch-btn" disabled>Launch</button>
<span class="screw tl"></span><span class="screw tr"></span>
<span class="screw bl"></span><span class="screw br"></span>
</div>
</div>
<script src="captions.js"></script>
<script>
const rockets = document.querySelectorAll('.rocket');
const video = document.getElementById('rocket-video');
const launchBtn = document.getElementById('launch-btn');
const countdownDisplay = document.getElementById('countdown-display');
const caption = document.getElementById('video-caption');
let instantLaunch = true; // Press '0' to toggle fast (true) vs normal (false) countdown
let selectedRocket = null;
let countdown = 5;
let countdownTimer = null;
let beepSound = new Audio('beep.mp3');
let selectionLocked = false;
let captionsData = { byId: {}, byVideo: {} };
// Build lookup tables from global CAPTIONS (loaded via captions.js)
if (window.CAPTIONS && Array.isArray(window.CAPTIONS.rockets)) {
window.CAPTIONS.rockets.forEach(r => {
captionsData.byId[r.id] = r.caption;
captionsData.byVideo[r.video] = r.caption;
});
}
function getCaptionFor(rocketEl, index) {
const id = rocketEl.getAttribute('data-rocket-id');
const videoSrc = rocketEl.dataset.video;
return (captionsData.byId && captionsData.byId[id]) || (captionsData.byVideo && captionsData.byVideo[videoSrc]) || `Rocket ${index+1}`;
}
function selectRocket(index) {
if (selectionLocked) return;
rockets.forEach(r => r.classList.remove('selected'));
const rocket = rockets[index];
if (!rocket) return;
rocket.classList.add('selected');
selectedRocket = rocket.dataset.video;
launchBtn.disabled = false;
video.src = selectedRocket;
video.load();
video.pause();
video.currentTime = 0;
countdownDisplay.textContent = '5';
caption.textContent = getCaptionFor(rocket, index);
caption.style.opacity = '1';
}
rockets.forEach((rocket, idx) => {
rocket.addEventListener('click', () => selectRocket(idx));
});
function startLaunch() {
if (!selectedRocket || launchBtn.disabled) return;
selectionLocked = true;
launchBtn.disabled = true;
countdown = 5;
countdownDisplay.textContent = countdown;
video.play().then(() => {
video.pause();
video.currentTime = 0;
}).catch(() => {});
countdownTimer = setInterval(() => {
countdown--;
if (countdown > 0) {
beepSound.currentTime = 0;
beepSound.play().catch(() => {});
countdownDisplay.textContent = countdown;
} else {
clearInterval(countdownTimer);
countdownDisplay.textContent = 'GO';
beepSound.currentTime = 0;
beepSound.play().catch(() => {});
caption.style.opacity = '0';
video.play();
}
}, instantLaunch ? 10 : 1000);
video.onended = () => {
countdownDisplay.textContent = '5';
launchBtn.disabled = false;
selectionLocked = false;
video.currentTime = 0;
video.pause();
caption.style.opacity = '1';
rockets.forEach(r => r.classList.remove('selected'));
if (selectedRocket) {
const activeRocket = [...rockets].find(r => r.dataset.video === selectedRocket);
if (activeRocket) activeRocket.classList.add('selected');
}
};
}
launchBtn.addEventListener('click', startLaunch);
window.addEventListener('keydown', (e) => {
if (e.repeat) return;
if (e.key >= '1' && e.key <= '8') {
selectRocket(parseInt(e.key) - 1);
} else if (e.key === 'Enter') {
startLaunch();
} else if (e.key === '0') {
instantLaunch = !instantLaunch;
const original = countdownDisplay.style.color;
countdownDisplay.style.color = instantLaunch ? 'lime' : 'orange';
setTimeout(() => countdownDisplay.style.color = original, 300);
}
});
// Initialize first rocket selection now that captions are available
selectRocket(0);
</script>
</body>
</html>