-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
558 lines (486 loc) Β· 13.3 KB
/
index.html
File metadata and controls
558 lines (486 loc) Β· 13.3 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
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>YouTube Grid - Modern Multiscreen Player</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
/* βββββββββ Variables & Reset βββββββββ */
:root {
--primary: #FF0000;
--primary-dark: #CC0000;
--bg-main: #0f0f0f;
--bg-secondary: #1a1a1a;
--bg-card: #242424;
--text-primary: #ffffff;
--text-secondary: #aaaaaa;
--border-color: #333333;
--shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
--shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
--radius: 12px;
--transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
background: var(--bg-main);
color: var(--text-primary);
min-height: 100vh;
overflow-x: hidden;
}
/* βββββββββ Header βββββββββ */
header {
background: linear-gradient(to bottom, var(--bg-secondary), transparent);
padding: 2rem 1rem 3rem;
position: relative;
}
.header-content {
max-width: 1400px;
margin: 0 auto;
text-align: center;
}
h1 {
font-size: 2.5rem;
font-weight: 700;
margin-bottom: 0.5rem;
background: linear-gradient(135deg, var(--primary), #ff4444);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
animation: glow 3s ease-in-out infinite;
}
@keyframes glow {
0%, 100% { filter: brightness(1); }
50% { filter: brightness(1.2); }
}
.subtitle {
color: var(--text-secondary);
font-size: 1.1rem;
margin-bottom: 2rem;
}
/* βββββββββ Input Area βββββββββ */
.input-container {
max-width: 800px;
margin: 0 auto;
display: flex;
gap: 1rem;
position: relative;
}
.input-wrapper {
flex: 1;
position: relative;
background: var(--bg-card);
border-radius: var(--radius);
border: 1px solid var(--border-color);
transition: var(--transition);
overflow: hidden;
}
.input-wrapper:focus-within {
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(255, 0, 0, 0.1);
}
.input-wrapper::before {
content: 'π';
position: absolute;
left: 1rem;
top: 50%;
transform: translateY(-50%);
font-size: 1.2rem;
opacity: 0.5;
}
#urlInput {
width: 100%;
padding: 1rem 1rem 1rem 3rem;
font-size: 1rem;
background: transparent;
border: none;
color: var(--text-primary);
outline: none;
}
#urlInput::placeholder {
color: var(--text-secondary);
}
#addBtn {
padding: 1rem 2rem;
font-size: 1rem;
font-weight: 600;
border: none;
border-radius: var(--radius);
background: linear-gradient(135deg, var(--primary), var(--primary-dark));
color: white;
cursor: pointer;
transition: var(--transition);
position: relative;
overflow: hidden;
white-space: nowrap;
}
#addBtn:hover {
transform: translateY(-2px);
box-shadow: var(--shadow-lg);
}
#addBtn:active {
transform: translateY(0);
}
#addBtn::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 0;
height: 0;
border-radius: 50%;
background: rgba(255, 255, 255, 0.3);
transform: translate(-50%, -50%);
transition: width 0.6s, height 0.6s;
}
#addBtn:active::after {
width: 300px;
height: 300px;
}
/* βββββββββ Grid Layout βββββββββ */
#grid {
padding: 2rem;
max-width: 1800px;
margin: 0 auto;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
gap: 1.5rem;
animation: fadeIn 0.5s ease-out;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
/* βββββββββ Video Cards βββββββββ */
.video-wrapper {
--size: 1;
grid-column: span var(--size);
aspect-ratio: 16/9;
position: relative;
background: var(--bg-card);
border-radius: var(--radius);
overflow: hidden;
transition: var(--transition);
cursor: move;
animation: slideIn 0.4s ease-out;
border: 1px solid var(--border-color);
}
@keyframes slideIn {
from {
opacity: 0;
transform: scale(0.8) rotate(-5deg);
}
to {
opacity: 1;
transform: scale(1) rotate(0);
}
}
.video-wrapper:hover {
transform: translateY(-4px);
box-shadow: var(--shadow-lg);
border-color: var(--primary);
}
.video-wrapper.dragging {
opacity: 0.5;
transform: scale(0.95);
cursor: grabbing;
}
.video-wrapper iframe {
width: 100%;
height: 100%;
border: 0;
}
/* βββββββββ Video Controls βββββββββ */
.controls {
position: absolute;
top: 0;
right: 0;
display: flex;
gap: 4px;
padding: 8px;
background: linear-gradient(to bottom right, rgba(0,0,0,0.8), rgba(0,0,0,0.4));
border-radius: 0 var(--radius) 0 20px;
opacity: 0;
transform: translateY(-10px);
transition: var(--transition);
}
.video-wrapper:hover .controls {
opacity: 1;
transform: translateY(0);
}
.ctrl {
width: 36px;
height: 36px;
border: none;
border-radius: 50%;
font-size: 18px;
color: var(--text-primary);
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
cursor: pointer;
transition: var(--transition);
display: flex;
align-items: center;
justify-content: center;
}
.ctrl:hover {
background: rgba(255, 255, 255, 0.2);
transform: scale(1.1);
}
.ctrl:active {
transform: scale(0.95);
}
.ctrl.close {
background: rgba(255, 59, 48, 0.2);
}
.ctrl.close:hover {
background: rgba(255, 59, 48, 0.4);
}
/* βββββββββ Empty State βββββββββ */
.empty-state {
text-align: center;
padding: 4rem 2rem;
color: var(--text-secondary);
animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
0%, 100% { opacity: 0.5; }
50% { opacity: 1; }
}
.empty-state h2 {
font-size: 1.5rem;
margin-bottom: 1rem;
}
.empty-state p {
font-size: 1.1rem;
}
/* βββββββββ Responsive βββββββββ */
@media (max-width: 768px) {
h1 { font-size: 2rem; }
.subtitle { font-size: 1rem; }
.input-container { flex-direction: column; }
#addBtn { width: 100%; }
#grid {
grid-template-columns: 1fr;
padding: 1rem;
}
}
/* βββββββββ Loading Animation βββββββββ */
.loading {
position: relative;
overflow: hidden;
}
.loading::after {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
to { left: 100%; }
}
</style>
</head>
<body>
<header>
<div class="header-content">
<h1>YouTube Grid</h1>
<p class="subtitle">Create your personalized multi-video viewing experience</p>
<div class="input-container">
<div class="input-wrapper">
<input id="urlInput" type="text" placeholder="Paste any YouTube URL here..." autocomplete="off">
</div>
<button id="addBtn">Add Video</button>
</div>
</div>
</header>
<main id="grid">
<div class="empty-state">
<h2>π¬ No videos yet</h2>
<p>Add YouTube URLs above to start watching</p>
</div>
</main>
<script>
/* βββ Core Elements βββ */
const urlInput = document.getElementById('urlInput');
const addBtn = document.getElementById('addBtn');
const grid = document.getElementById('grid');
let draggedElement = null;
/* βββ YouTube URL Parser βββ */
function extractVideoId(url) {
const patterns = [
/^https?:\/\/youtu\.be\/([A-Za-z0-9_-]{11})/,
/[?&]v=([A-Za-z0-9_-]{11})(?:&|$)/,
/\/embed\/([A-Za-z0-9_-]{11})/,
/\/shorts\/([A-Za-z0-9_-]{11})/,
/^([A-Za-z0-9_-]{11})$/ // Just the ID
];
for (const pattern of patterns) {
const match = url.trim().match(pattern);
if (match) return match[1];
}
return null;
}
/* βββ Remove Empty State βββ */
function removeEmptyState() {
const emptyState = grid.querySelector('.empty-state');
if (emptyState) {
emptyState.style.animation = 'fadeOut 0.3s ease-out';
setTimeout(() => emptyState.remove(), 300);
}
}
/* βββ Video Creation βββ */
function addVideo() {
const id = extractVideoId(urlInput.value);
if (!id) {
// Shake animation for invalid input
urlInput.parentElement.style.animation = 'shake 0.3s';
setTimeout(() => urlInput.parentElement.style.animation = '', 300);
return;
}
removeEmptyState();
// Create video container
const wrap = document.createElement('div');
wrap.className = 'video-wrapper';
wrap.draggable = true;
// Drag and drop handlers
wrap.addEventListener('dragstart', handleDragStart);
wrap.addEventListener('dragend', handleDragEnd);
wrap.addEventListener('dragover', handleDragOver);
wrap.addEventListener('drop', handleDrop);
// Control buttons
const controls = document.createElement('div');
controls.className = 'controls';
const buttons = [
{ icon: 'β', class: 'ctrl', action: () => adjustSize(wrap, -1) },
{ icon: '+', class: 'ctrl', action: () => adjustSize(wrap, 1) },
{ icon: 'βΆ', class: 'ctrl', action: () => toggleFullscreen(wrap) },
{ icon: 'β', class: 'ctrl close', action: () => removeVideo(wrap) }
];
buttons.forEach(({ icon, class: className, action }) => {
const btn = document.createElement('button');
btn.className = className;
btn.textContent = icon;
btn.onclick = action;
controls.appendChild(btn);
});
// YouTube iframe
const iframe = document.createElement('iframe');
iframe.src = `https://www.youtube.com/embed/${id}?autoplay=1&mute=1&rel=0&modestbranding=1`;
iframe.allow = 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture';
iframe.allowFullscreen = true;
wrap.appendChild(controls);
wrap.appendChild(iframe);
grid.appendChild(wrap);
// Clear input and refocus
urlInput.value = '';
urlInput.focus();
// Success feedback
addBtn.style.background = 'linear-gradient(135deg, #00C853, #00E676)';
setTimeout(() => {
addBtn.style.background = '';
}, 500);
}
/* βββ Size Adjustment βββ */
function adjustSize(wrap, direction) {
const currentSize = parseInt(wrap.style.getPropertyValue('--size') || 1);
const newSize = Math.max(1, Math.min(3, currentSize + direction));
wrap.style.setProperty('--size', newSize);
}
/* βββ Fullscreen βββ */
function toggleFullscreen(wrap) {
if (!document.fullscreenElement) {
wrap.requestFullscreen().catch(err => console.log(err));
} else {
document.exitFullscreen();
}
}
/* βββ Remove Video βββ */
function removeVideo(wrap) {
wrap.style.animation = 'slideOut 0.3s ease-out';
setTimeout(() => {
wrap.remove();
if (grid.children.length === 0) {
grid.innerHTML = `
<div class="empty-state">
<h2>π¬ No videos yet</h2>
<p>Add YouTube URLs above to start watching</p>
</div>
`;
}
}, 300);
}
/* βββ Drag and Drop βββ */
function handleDragStart(e) {
draggedElement = this;
this.classList.add('dragging');
e.dataTransfer.effectAllowed = 'move';
}
function handleDragEnd(e) {
this.classList.remove('dragging');
draggedElement = null;
}
function handleDragOver(e) {
if (e.preventDefault) e.preventDefault();
e.dataTransfer.dropEffect = 'move';
const afterElement = getDragAfterElement(grid, e.clientY);
if (afterElement == null) {
grid.appendChild(draggedElement);
} else {
grid.insertBefore(draggedElement, afterElement);
}
return false;
}
function handleDrop(e) {
if (e.stopPropagation) e.stopPropagation();
return false;
}
function getDragAfterElement(container, y) {
const draggableElements = [...container.querySelectorAll('.video-wrapper:not(.dragging)')];
return draggableElements.reduce((closest, child) => {
const box = child.getBoundingClientRect();
const offset = y - box.top - box.height / 2;
if (offset < 0 && offset > closest.offset) {
return { offset: offset, element: child };
} else {
return closest;
}
}, { offset: Number.NEGATIVE_INFINITY }).element;
}
/* βββ Event Listeners βββ */
addBtn.addEventListener('click', addVideo);
urlInput.addEventListener('keydown', e => {
if (e.key === 'Enter') addVideo();
});
/* βββ Shake Animation βββ */
const style = document.createElement('style');
style.textContent = `
@keyframes shake {
0%, 100% { transform: translateX(0); }
25% { transform: translateX(-5px); }
75% { transform: translateX(5px); }
}
@keyframes slideOut {
to {
opacity: 0;
transform: scale(0.8) rotate(5deg);
}
}
@keyframes fadeOut {
to { opacity: 0; transform: translateY(-20px); }
}
`;
document.head.appendChild(style);
/* βββ Focus input on load βββ */
urlInput.focus();
</script>
</body>
</html>