-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesp.html
More file actions
680 lines (593 loc) · 23 KB
/
esp.html
File metadata and controls
680 lines (593 loc) · 23 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
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>YouTube Simplificado</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Arial', sans-serif;
background-color: #f8f9fa;
color: #333;
line-height: 1.6;
}
/* Pagina di ricerca */
.search-page {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
padding: 20px;
}
.logo {
font-size: 48px;
font-weight: bold;
color: #ff0000;
margin-bottom: 40px;
text-align: center;
}
.search-container {
width: 100%;
max-width: 600px;
margin-bottom: 30px;
}
.search-input {
width: 100%;
padding: 20px 25px;
font-size: 24px;
border: 3px solid #ddd;
border-radius: 50px;
outline: none;
transition: border-color 0.3s;
}
.search-input:focus {
border-color: #ff0000;
}
.search-button {
background-color: #ff0000;
color: white;
border: none;
padding: 20px 40px;
font-size: 24px;
border-radius: 50px;
cursor: pointer;
margin-top: 20px;
transition: background-color 0.3s;
min-width: 200px;
}
.search-button:hover {
background-color: #cc0000;
}
/* Pagina risultati */
.results-page {
display: none;
padding: 20px;
max-width: 1000px;
margin: 0 auto;
}
.header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 40px;
padding: 20px;
background: white;
border-radius: 15px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.back-button {
background-color: #28a745;
color: white;
border: none;
padding: 15px 30px;
font-size: 20px;
border-radius: 10px;
cursor: pointer;
transition: background-color 0.3s;
}
.back-button:hover {
background-color: #218838;
}
.current-search {
font-size: 24px;
font-weight: bold;
color: #666;
}
.video-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 30px;
}
.video-card {
background: white;
border-radius: 15px;
overflow: hidden;
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
transition: transform 0.3s, box-shadow 0.3s;
cursor: pointer;
}
.video-card:hover {
transform: translateY(-5px);
box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}
.video-thumbnail {
width: 100%;
height: 200px;
background-color: #000;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 18px;
}
.video-info {
padding: 20px;
}
.video-title {
font-size: 20px;
font-weight: bold;
margin-bottom: 10px;
line-height: 1.4;
}
.video-channel {
font-size: 16px;
color: #666;
margin-bottom: 8px;
}
.video-views {
font-size: 14px;
color: #999;
}
/* Pagina video */
.video-page {
display: none;
padding: 20px;
max-width: 1000px;
margin: 0 auto;
}
.video-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 30px;
padding: 20px;
background: white;
border-radius: 15px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.video-player-container {
background: white;
border-radius: 15px;
overflow: hidden;
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.video-player {
width: 100%;
height: 500px;
border: none;
}
.video-details {
padding: 30px;
background: white;
margin-top: 20px;
border-radius: 15px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.video-title-large {
font-size: 28px;
font-weight: bold;
margin-bottom: 15px;
line-height: 1.3;
}
.video-meta {
font-size: 18px;
color: #666;
margin-bottom: 10px;
}
/* Loading */
.loading {
display: none;
text-align: center;
padding: 50px;
font-size: 24px;
color: #666;
}
/* Focus visibile per navigazione keyboard */
.search-input:focus,
.search-button:focus,
.back-button:focus,
.video-card:focus {
outline: 4px solid #0066cc;
outline-offset: 2px;
}
/* Miglioramento contrasti per AAA */
.search-button:focus,
.back-button:focus {
box-shadow: 0 0 0 4px rgba(0, 102, 204, 0.3);
}
/* Screen reader only content */
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
/* Status announcement styles */
.status-announcement {
font-size: 18px;
font-weight: bold;
color: #333;
padding: 15px;
text-align: center;
}
@media (max-width: 768px) {
.search-input {
font-size: 20px;
padding: 18px 20px;
}
.search-button {
font-size: 20px;
padding: 18px 35px;
}
.logo {
font-size: 36px;
}
.video-grid {
grid-template-columns: 1fr;
}
.header {
flex-direction: column;
gap: 15px;
text-align: center;
}
.video-player {
height: 250px;
}
}
/* Fix per coerenza colori - tutto rosso brand */
/* Bottone standard per tutte le azioni "Nuova Ricerca" */
.back-button.new-search {
background-color: #ff0000 !important; /* Rosso brand come search button */
color: white;
border: none;
padding: 15px 30px;
font-size: 20px;
border-radius: 10px;
cursor: pointer;
transition: background-color 0.3s;
}
.back-button.new-search:hover {
background-color: #cc0000 !important; /* Stesso hover del search button */
}
/* Bottone per "Torna ai risultati" - può rimanere verde per differenziare */
.back-button.results {
background-color: #28a745;
color: white;
}
.back-button.results:hover {
background-color: #218838;
}
/* CSS per gli esempi semplici */
.search-examples {
max-width: 600px;
margin-bottom: 25px;
text-align: center;
}
.examples-intro {
font-size: 18px;
color: #666;
margin-bottom: 8px;
font-weight: 500;
}
.examples-text {
font-size: 16px;
color: #888;
font-style: italic;
line-height: 1.4;
}
/* Responsive */
@media (max-width: 768px) {
.examples-intro {
font-size: 16px;
}
.examples-text {
font-size: 14px;
}
}
</style>
</head>
<body>
<!-- Pagina di ricerca principale -->
<main class="search-page" id="searchPage">
<header>
<h1 class="logo">YouTube Fácil</h1>
<p class="sr-only">Interfaz simplificada para buscar y ver videos de YouTube</p>
</header>
<!-- Sezione esempi semplice da aggiungere dopo il logo -->
<section class="search-examples">
<p class="examples-intro">Ejemplos de búsqueda:</p>
<div class="examples-text">
concierto para clarinete • receta de paella
</div>
</section>
<section class="search-container">
<label for="searchInput" class="sr-only">Buscar videos en YouTube</label>
<input type="text"
class="search-input"
id="searchInput"
placeholder="Buscar videos..."
autocomplete="off"
aria-describedby="search-help">
<div id="search-help" class="sr-only">Ingresa las palabras para buscar videos y presiona Enter o haz clic en Buscar Videos</div>
<div style="text-align: center;">
<button class="search-button"
onclick="searchVideos()"
aria-describedby="search-button-help">
Buscar Videos
</button>
<div id="search-button-help" class="sr-only">Iniciar la búsqueda de videos con las palabras ingresadas</div>
</div>
</section>
</main>
<!-- Loading con aria-live per screen readers -->
<div class="loading" id="loading" aria-live="polite" role="status">
<div class="status-announcement">Buscando videos...</div>
<div class="sr-only">Búsqueda en curso, por favor espera</div>
</div>
<!-- Pagina risultati -->
<main class="results-page" id="resultsPage" role="main">
<header class="header">
<button class="back-button new-search"
onclick="showSearchPage()"
aria-label="Volver a la página de búsqueda para buscar otros videos">
← Nueva Búsqueda
</button>
<h1 class="current-search" id="currentSearch"></h1>
</header>
<section aria-live="polite" aria-label="Resultados de la búsqueda">
<div class="video-grid" id="videoGrid" role="list"></div>
</section>
</main>
<!-- Pagina video -->
<main class="video-page" id="videoPage" role="main">
<header class="video-header">
<button class="back-button results"
onclick="showResultsPage()"
aria-label="Volver a los resultados de la búsqueda">
← Volver a Resultados
</button>
<button class="back-button new-search"
onclick="showSearchPage()"
style="background-color: #17a2b8;"
aria-label="Volver a la página principal para una nueva búsqueda">
← Nueva Búsqueda
</button>
</header>
<section class="video-player-container" aria-label="Reproductor de video">
<iframe class="video-player"
id="videoPlayer"
src=""
allowfullscreen
title="Video de YouTube seleccionado"
aria-describedby="video-description"></iframe>
</section>
<section class="video-details" aria-labelledby="video-title">
<h1 class="video-title-large" id="videoTitle"></h1>
<div class="video-meta" id="videoChannel" aria-label="Nombre del canal"></div>
<div class="video-meta" id="videoViews" aria-label="Fecha de publicación"></div>
<div id="video-description" class="sr-only">Detalles del video actualmente en reproducción</div>
</section>
</main>
<script>
// Configurazione dinamica da localStorage
let YOUTUBE_API_KEY = localStorage.getItem('bigbuttonplay_api_key');
if (!YOUTUBE_API_KEY) {
window.location.href = './config.html';
}
const YOUTUBE_API_URL = 'https://www.googleapis.com/youtube/v3/search';
let currentQuery = '';
let currentResults = [];
function formatDate(dateString) {
try {
const date = new Date(dateString);
const now = new Date();
const diffTime = Math.abs(now - date);
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
if (diffDays === 1) return 'hace 1 día';
if (diffDays < 30) return `hace ${diffDays} días`;
if (diffDays < 365) return `hace ${Math.floor(diffDays / 30)} meses`;
return `hace ${Math.floor(diffDays / 365)} años`;
} catch (e) {
return 'Fecha no disponible';
}
}
// Event listener per Enter
document.getElementById('searchInput').addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
searchVideos();
}
});
function searchVideos() {
const query = document.getElementById('searchInput').value.trim();
if (!query) return;
// Verifica que l'API key sia configurata
if (YOUTUBE_API_KEY === 'YOUR_API_KEY_HERE') {
alert('Error: Clave API de YouTube no configurada. Ingresa tu clave API en el código.');
return;
}
currentQuery = query;
showLoading();
// Chiamata reale alle YouTube Data API v3
const searchParams = new URLSearchParams({
part: 'snippet',
q: query,
type: 'video',
maxResults: 12,
key: YOUTUBE_API_KEY,
regionCode: 'ES', // Resultados localizados para España
relevanceLanguage: 'es' // Preferencia para contenidos en español
});
fetch(`${YOUTUBE_API_URL}?${searchParams}`)
.then(response => {
if (!response.ok) {
throw new Error(`Error API: ${response.status} - ${response.statusText}`);
}
return response.json();
})
.then(data => {
console.log('Datos recibidos de YouTube:', data);
if (!data.items || data.items.length === 0) {
currentResults = [];
} else {
// Trasforma i dati di YouTube nel formato del nostro client
currentResults = data.items.map(item => ({
id: item.id.videoId,
title: item.snippet.title,
channel: item.snippet.channelTitle,
description: item.snippet.description,
thumbnail: item.snippet.thumbnails.medium ? item.snippet.thumbnails.medium.url : '',
publishTime: item.snippet.publishTime
}));
}
displayResults();
})
.catch(error => {
console.error('Error en la búsqueda de YouTube:', error);
document.getElementById('loading').style.display = 'none';
document.getElementById('searchPage').style.display = 'flex';
let errorMessage = 'Se produjo un error en la búsqueda. ';
if (error.message.includes('403')) {
errorMessage += 'Verifica que tu clave API sea válida y tenga los permisos correctos.';
} else if (error.message.includes('400')) {
errorMessage += 'La solicitud no es válida. Verifica los parámetros.';
} else {
errorMessage += 'Verifica la conexión a internet e inténtalo de nuevo.';
}
alert(errorMessage);
});
}
// Annuncio status per screen readers
function announceStatus(message) {
const statusDiv = document.createElement('div');
statusDiv.setAttribute('aria-live', 'polite');
statusDiv.setAttribute('aria-atomic', 'true');
statusDiv.className = 'sr-only';
statusDiv.textContent = message;
document.body.appendChild(statusDiv);
// Rimuovi dopo 3 secondi
setTimeout(() => {
document.body.removeChild(statusDiv);
}, 3000);
}
function showLoading() {
document.getElementById('searchPage').style.display = 'none';
document.getElementById('resultsPage').style.display = 'none';
document.getElementById('videoPage').style.display = 'none';
document.getElementById('loading').style.display = 'block';
}
function displayResults() {
document.getElementById('loading').style.display = 'none';
document.getElementById('resultsPage').style.display = 'block';
document.getElementById('currentSearch').textContent = `Resultados para: "${currentQuery}"`;
const grid = document.getElementById('videoGrid');
grid.innerHTML = '';
if (currentResults.length === 0) {
grid.innerHTML = '<div style="text-align: center; font-size: 24px; color: #666; grid-column: 1/-1;" role="alert" aria-live="polite">No se encontraron videos. Prueba con palabras diferentes.</div>';
return;
}
currentResults.forEach((video, index) => {
const videoCard = document.createElement('div');
videoCard.className = 'video-card';
videoCard.onclick = () => playVideo(video);
videoCard.setAttribute('role', 'listitem');
videoCard.setAttribute('tabindex', '0');
videoCard.setAttribute('aria-label', `Video: ${video.title} de ${video.channel}. Presiona Enter para ver.`);
// Gestione keyboard
videoCard.addEventListener('keydown', function(e) {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
playVideo(video);
}
});
videoCard.innerHTML = `
<div class="video-thumbnail">
${video.thumbnail ?
`<img src="${video.thumbnail}" alt="Vista previa" style="width: 100%; height: 100%; object-fit: cover;">` :
`<div style="width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: white; background: #333;">▶ Video</div>`
}
</div>
<div class="video-info">
<div class="video-title">${video.title}</div>
<div class="video-channel">${video.channel}</div>
<div class="video-views">${video.publishTime ? formatDate(video.publishTime) : ''}</div>
</div>
`;
grid.appendChild(videoCard);
});
}
function playVideo(video) {
document.getElementById('resultsPage').style.display = 'none';
document.getElementById('videoPage').style.display = 'block';
// Aggiorna il testo del bottone con la query corrente
const backButton = document.querySelector('.video-header .back-button[onclick="showResultsPage()"]');
const queryText = currentQuery.length > 25 ? currentQuery.substring(0, 25) + '...' : currentQuery;
backButton.textContent = `← Resultados de "${queryText}"`;
// Aggiorna anche l'aria-label per accessibilità
backButton.setAttribute('aria-label', `Volver a los resultados de la búsqueda de "${currentQuery}"`);
document.getElementById('videoPlayer').src = `https://www.youtube.com/embed/${video.id}?autoplay=1&rel=0&modestbranding=1`;
document.getElementById('videoTitle').textContent = video.title;
document.getElementById('videoChannel').textContent = `Canal: ${video.channel}`;
document.getElementById('videoViews').textContent = video.publishTime ? formatDate(video.publishTime) : '';
}
function showResultsPage() {
document.getElementById('videoPage').style.display = 'none';
document.getElementById('resultsPage').style.display = 'block';
// Ferma il video
document.getElementById('videoPlayer').src = '';
}
function showSearchPage() {
document.getElementById('resultsPage').style.display = 'none';
document.getElementById('videoPage').style.display = 'none';
document.getElementById('searchPage').style.display = 'flex';
// Ferma il video e pulisce la ricerca
document.getElementById('videoPlayer').src = '';
document.getElementById('searchInput').value = '';
document.getElementById('searchInput').focus();
// Annuncia il cambio di pagina
announceStatus('Has vuelto a la página de búsqueda principal');
}
// Gestione keyboard per l'intera app
document.addEventListener('keydown', function(e) {
// ESC per tornare indietro
if (e.key === 'Escape') {
const currentPage = getCurrentPage();
if (currentPage === 'video') {
showResultsPage();
} else if (currentPage === 'results') {
showSearchPage();
}
}
});
function getCurrentPage() {
if (document.getElementById('videoPage').style.display !== 'none') return 'video';
if (document.getElementById('resultsPage').style.display !== 'none') return 'results';
return 'search';
}
// Focus automatico al caricamento
window.onload = function() {
document.getElementById('searchInput').focus();
};
</script>
</body>
</html>