-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoffline.html
More file actions
521 lines (451 loc) · 13.7 KB
/
offline.html
File metadata and controls
521 lines (451 loc) · 13.7 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
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Modo offline - Contenido guardado disponible" />
<title>Modo Offline - El Oráculo del I Ching</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Noto Serif SC", serif;
background: linear-gradient(135deg, #8c1c13 0%, #5c0a00 100%);
color: #e8d8c5;
text-align: center;
padding: 20px;
min-height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
}
.container {
max-width: 600px;
margin: 0 auto;
background: rgba(44, 30, 22, 0.8);
border-radius: 10px;
padding: 40px 30px;
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.yin-yang {
width: 120px;
height: 120px;
border-radius: 50%;
background: linear-gradient(90deg, #2c1e16 50%, #f5f2e9 50%);
margin: 0 auto 30px;
position: relative;
animation: pulse 2s infinite;
}
.yin-yang::before,
.yin-yang::after {
content: "";
position: absolute;
border-radius: 50%;
width: 40px;
height: 40px;
border: 13px solid;
}
.yin-yang::before {
background: #2c1e16;
border-color: #f5f2e9;
top: -13px;
left: 50%;
transform: translateX(-50%);
}
.yin-yang::after {
background: #f5f2e9;
border-color: #2c1e16;
bottom: -13px;
left: 50%;
transform: translateX(-50%);
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.7; }
}
h1 {
font-size: 28px;
margin-bottom: 10px;
color: #f5f2e9;
}
.status-badge {
display: inline-block;
background: rgba(255, 107, 107, 0.2);
border: 1px solid #ff6b6b;
color: #ff6b6b;
padding: 8px 16px;
border-radius: 20px;
font-size: 14px;
margin-bottom: 30px;
font-weight: bold;
}
.status-badge.connecting {
background: rgba(255, 193, 7, 0.2);
border-color: #ffc107;
color: #ffc107;
}
.status-badge.connected {
background: rgba(76, 175, 80, 0.2);
border-color: #4caf50;
color: #4caf50;
}
p {
font-size: 16px;
line-height: 1.6;
margin-bottom: 20px;
color: #e8d8c5;
}
.content-section {
text-align: left;
background: rgba(0, 0, 0, 0.3);
padding: 20px;
border-radius: 8px;
margin: 20px 0;
border-left: 4px solid #d4a574;
}
.content-section h2 {
font-size: 18px;
color: #d4a574;
margin-bottom: 15px;
display: flex;
align-items: center;
gap: 10px;
}
.content-section h2::before {
content: "📚";
font-size: 20px;
}
.cached-hexagrams {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
gap: 10px;
margin: 15px 0;
}
.hexagram-card {
background: rgba(212, 165, 116, 0.1);
border: 1px solid rgba(212, 165, 116, 0.3);
padding: 15px;
border-radius: 6px;
cursor: pointer;
transition: all 0.3s ease;
}
.hexagram-card:hover {
background: rgba(212, 165, 116, 0.2);
transform: translateY(-2px);
}
.hexagram-card strong {
display: block;
color: #d4a574;
margin-bottom: 8px;
}
.actions {
display: flex;
gap: 10px;
margin: 25px 0;
flex-wrap: wrap;
justify-content: center;
}
button {
flex: 1;
min-width: 150px;
padding: 12px 20px;
border: 2px solid;
border-radius: 6px;
font-size: 14px;
font-weight: bold;
cursor: pointer;
transition: all 0.3s ease;
font-family: inherit;
}
.btn-primary {
background: #d4a574;
border-color: #d4a574;
color: #2c1e16;
}
.btn-primary:hover {
background: #e8c48a;
border-color: #e8c48a;
transform: translateY(-2px);
}
.btn-secondary {
background: transparent;
border-color: #d4a574;
color: #d4a574;
}
.btn-secondary:hover {
background: rgba(212, 165, 116, 0.1);
transform: translateY(-2px);
}
.tips {
background: rgba(76, 175, 80, 0.1);
border-left: 4px solid #4caf50;
padding: 15px;
border-radius: 4px;
margin: 20px 0;
font-size: 14px;
text-align: left;
}
.tips h3 {
color: #4caf50;
margin-bottom: 10px;
display: flex;
align-items: center;
gap: 8px;
}
.tips h3::before {
content: "💡";
}
.tips ul {
margin-left: 20px;
color: #e8d8c5;
}
.tips li {
margin: 8px 0;
}
.footer {
margin-top: 40px;
padding-top: 20px;
border-top: 1px solid rgba(212, 165, 116, 0.2);
font-size: 12px;
color: rgba(232, 216, 197, 0.7);
}
.connection-indicator {
display: inline-flex;
align-items: center;
gap: 6px;
margin-top: 20px;
font-size: 14px;
}
.connection-dot {
width: 10px;
height: 10px;
border-radius: 50%;
background: #ff6b6b;
animation: blink 1s infinite;
}
.connection-dot.connected {
background: #4caf50;
animation: none;
}
@keyframes blink {
0%, 49%, 100% { opacity: 1; }
50%, 99% { opacity: 0.3; }
}
.skeleton {
background: linear-gradient(90deg, rgba(212, 165, 116, 0.1), rgba(212, 165, 116, 0.3), rgba(212, 165, 116, 0.1));
background-size: 200% 100%;
animation: skeleton-loading 1.5s infinite;
}
@keyframes skeleton-loading {
0% { background-position: 200% 0; }
100% { background-position: -200% 0; }
}
@media (max-width: 600px) {
.container {
padding: 30px 20px;
}
h1 {
font-size: 24px;
}
.yin-yang {
width: 100px;
height: 100px;
}
.cached-hexagrams {
grid-template-columns: repeat(3, 1fr);
}
button {
min-width: 120px;
}
}
</style>
</head>
<body>
<div class="container">
<div class="yin-yang"></div>
<h1>🌐 Modo Offline</h1>
<div class="status-badge" id="statusBadge">
<span class="connection-dot"></span> Sin conexión
</div>
<p>Parece que no hay conexión a Internet en este momento.</p>
<!-- Contenido en caché disponible -->
<div class="content-section">
<h2>Contenido Disponible Offline</h2>
<p>Puedes acceder a los siguientes hexagramas guardados en tu dispositivo:</p>
<div class="cached-hexagrams" id="cachedHexagrams">
<div class="hexagram-card skeleton" style="height: 80px;"></div>
<div class="hexagram-card skeleton" style="height: 80px;"></div>
<div class="hexagram-card skeleton" style="height: 80px;"></div>
</div>
</div>
<!-- Opciones de acción -->
<div class="actions">
<button class="btn-primary" onclick="location.reload()">
🔄 Reintentar Conexión
</button>
<button class="btn-secondary" onclick="goToCache()">
📖 Ver Contenido Guardado
</button>
</div>
<!-- Tips -->
<div class="tips">
<h3>¿Qué puedes hacer?</h3>
<ul>
<li>✓ Ver los hexagramas consultados anteriormente</li>
<li>✓ Revisar tu historial de consultas offline</li>
<li>✓ Leer artículos guardados en caché</li>
<li>✗ Realiza nuevas consultas (requiere conexión)</li>
<li>✗ Acceder a funciones que requieren red</li>
</ul>
</div>
<!-- Indicador de conexión -->
<div class="connection-indicator">
<span class="connection-dot" id="connectionDot"></span>
<span id="connectionStatus">Intentando reconectar...</span>
</div>
<div class="footer">
<p>© 2026 El Oráculo del I Ching | Versión Offline</p>
<p>Esta página se muestra cuando no hay conexión a Internet</p>
</div>
</div>
<script>
// Detectar cuando vuelve la conexión
window.addEventListener('online', function() {
console.log('✅ Conexión restaurada');
const badge = document.getElementById('statusBadge');
const dot = document.getElementById('connectionDot');
const status = document.getElementById('connectionStatus');
badge.className = 'status-badge connected';
badge.textContent = '✅ Conexión restaurada';
dot.className = 'connection-dot connected';
status.textContent = 'Conectado - Recargando...';
// Recargar después de 2 segundos
setTimeout(() => {
location.reload();
}, 2000);
});
window.addEventListener('offline', function() {
console.log('❌ Conexión perdida');
const badge = document.getElementById('statusBadge');
const dot = document.getElementById('connectionDot');
const status = document.getElementById('connectionStatus');
badge.className = 'status-badge';
badge.textContent = '❌ Sin conexión';
dot.className = 'connection-dot';
status.textContent = 'Intentando reconectar...';
});
// Cargar hexagramas en caché
async function loadCachedHexagrams() {
try {
const cacheNames = await caches.keys();
const hexagrams = [];
// Buscar hexagramas en cache de assets
for (const cacheName of cacheNames) {
const cache = await caches.open(cacheName);
const keys = await cache.keys();
// Buscar archivos de hexagramas
keys.forEach(request => {
if (request.url.includes('hexagrama')) {
const id = request.url.match(/id=(\d+)/)?.[1];
if (id && !hexagrams.includes(id)) {
hexagrams.push(id);
}
}
});
}
// Mostrar hexagramas disponibles
const container = document.getElementById('cachedHexagrams');
container.innerHTML = '';
if (hexagrams.length === 0) {
container.innerHTML = '<p style="grid-column: 1/-1; color: #999;">No hay hexagramas guardados aún. Consulta algunos para verlos aquí.</p>';
return;
}
hexagrams.slice(0, 12).forEach(id => {
const card = document.createElement('div');
card.className = 'hexagram-card';
card.innerHTML = `<strong>Hex. ${id}</strong><small>Guardado</small>`;
card.onclick = () => {
window.location.href = `hexagrama.html?id=${id}`;
};
container.appendChild(card);
});
} catch (error) {
console.error('Error cargando hexagramas en caché:', error);
document.getElementById('cachedHexagrams').innerHTML = '<p>Error cargando contenido guardado</p>';
}
}
function goToCache() {
// Intentar ir a index.html (que debería estar en caché)
window.location.href = 'index.html';
}
// Cargar cuando esté listo
document.addEventListener('DOMContentLoaded', loadCachedHexagrams);
// Chequear conexión cada 5 segundos
setInterval(async () => {
try {
const response = await fetch('config.json', { method: 'HEAD', cache: 'no-store' });
if (response.ok) {
document.getElementById('connectionStatus').textContent = 'Conexión detectada - Recargando...';
setTimeout(() => location.reload(), 1000);
}
} catch (e) {
// Sin conexión, continuar mostrando offline
}
}, 5000);
</script>
</body>
</html>
left: 50%;
transform: translateX(-50%);
}
h1 {
font-size: 2.2rem;
margin-bottom: 20px;
}
p {
font-size: 1.2rem;
max-width: 600px;
margin: 0 auto 30px;
line-height: 1.6;
}
.btn {
display: inline-block;
background: #e8d8c5;
color: #8c1c13;
padding: 12px 30px;
border-radius: 30px;
text-decoration: none;
font-weight: bold;
font-size: 1.1rem;
transition: all 0.3s ease;
}
.btn:hover {
transform: translateY(-3px);
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}
.offline-content {
max-width: 800px;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="offline-content">
<div class="yin-yang"></div>
<h1>Modo Offline</h1>
<p>
Parece que estás sin conexión a internet. No te preocupes, puedes seguir
consultando los hexagramas que ya has visto recientemente.
</p>
<p>
Algunas funciones como nuevas consultas completas y carga de datos
adicionales requerirán conexión, pero podrás acceder a tu historial de
consultas y a los hexagramas que ya has explorado.
</p>
<a href="/" class="btn">Volver al inicio</a>
</div>
</body>
</html>