-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoffline-fallback.html
More file actions
219 lines (192 loc) · 7.51 KB
/
offline-fallback.html
File metadata and controls
219 lines (192 loc) · 7.51 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
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SUPACO - Modo Offline</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" rel="stylesheet">
<link href="assets/css/offline-indicator.css" rel="stylesheet">
<style>
body {
background: linear-gradient(135deg, #0F1116 0%, #1F2937 100%);
color: white;
font-family: 'Inter', sans-serif;
min-height: 100vh;
}
.offline-container {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.offline-card {
background: rgba(31, 41, 55, 0.8);
backdrop-filter: blur(10px);
border: 1px solid rgba(75, 85, 99, 0.3);
border-radius: 1rem;
padding: 2rem;
text-align: center;
max-width: 500px;
width: 90%;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}
.offline-icon {
width: 80px;
height: 80px;
margin: 0 auto 1.5rem;
background: linear-gradient(135deg, #EF4444, #DC2626);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
animation: pulse-offline 2s infinite;
}
.offline-icon i {
font-size: 2rem;
color: white;
}
.retry-btn {
background: linear-gradient(135deg, #3B82F6, #2563EB);
border: none;
padding: 0.75rem 2rem;
border-radius: 0.5rem;
color: white;
font-weight: 600;
transition: all 0.3s ease;
}
.retry-btn:hover {
transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
}
.cache-info {
background: rgba(34, 197, 94, 0.1);
border: 1px solid rgba(34, 197, 94, 0.3);
border-radius: 0.5rem;
padding: 1rem;
margin: 1rem 0;
font-size: 0.875rem;
}
.features-list {
text-align: left;
margin: 1.5rem 0;
}
.features-list li {
margin: 0.5rem 0;
display: flex;
align-items: center;
gap: 0.5rem;
}
.features-list i {
color: #10B981;
width: 16px;
}
</style>
</head>
<body>
<div class="offline-container">
<div class="offline-card">
<div class="offline-icon">
<i class="fas fa-wifi-slash"></i>
</div>
<h2 class="mb-3">SUPACO Offline</h2>
<p class="text-muted mb-4">
Você está sem conexão com a internet, mas ainda pode usar o SUPACO com os dados salvos!
</p>
<div class="cache-info">
<i class="fas fa-database me-2"></i>
<strong>Dados disponíveis offline:</strong>
</div>
<ul class="features-list">
<li><i class="fas fa-check"></i> Informações do usuário</li>
<li><i class="fas fa-check"></i> Boletim acadêmico</li>
<li><i class="fas fa-check"></i> Horários das aulas</li>
<li><i class="fas fa-check"></i> Histórico de notas</li>
</ul>
<div class="d-grid gap-2">
<button class="retry-btn" onclick="tryReconnect()">
<i class="fas fa-sync-alt me-2"></i>
Tentar Reconectar
</button>
<button class="btn btn-outline-light" onclick="goToMainApp()">
<i class="fas fa-home me-2"></i>
Continuar Offline
</button>
</div>
<div class="mt-3">
<small class="text-muted">
Os dados serão sincronizados automaticamente quando a conexão for restaurada.
</small>
</div>
</div>
</div>
<script>
// Função para tentar reconectar
function tryReconnect() {
const btn = document.querySelector('.retry-btn');
const icon = btn.querySelector('i');
// Animação de loading
icon.className = 'fas fa-spinner fa-spin me-2';
btn.disabled = true;
// Verifica conexão
setTimeout(() => {
if (navigator.onLine) {
// Online - redireciona para a aplicação
window.location.href = 'index.php';
} else {
// Ainda offline - restaura botão
icon.className = 'fas fa-sync-alt me-2';
btn.disabled = false;
// Mostra notificação
showNotification('Ainda sem conexão. Tente novamente.', 'warning');
}
}, 2000);
}
// Função para ir para a aplicação principal
function goToMainApp() {
window.location.href = 'index.php';
}
// Função para mostrar notificação
function showNotification(message, type = 'info') {
const notification = document.createElement('div');
notification.className = `alert alert-${type} alert-dismissible fade show position-fixed`;
notification.style.cssText = 'top: 20px; right: 20px; z-index: 9999; min-width: 300px;';
notification.innerHTML = `
${message}
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
`;
document.body.appendChild(notification);
// Remove automaticamente após 3 segundos
setTimeout(() => {
if (notification.parentElement) {
notification.remove();
}
}, 3000);
}
// Monitora mudanças de conexão
window.addEventListener('online', function() {
showNotification('Conexão restaurada! Redirecionando...', 'success');
setTimeout(() => {
window.location.href = 'index.php';
}, 1500);
});
window.addEventListener('offline', function() {
showNotification('Conexão perdida. Continuando offline...', 'warning');
});
// Inicialização
document.addEventListener('DOMContentLoaded', function() {
// Verifica se há dados em cache
if (typeof localStorage !== 'undefined') {
const hasCache = localStorage.getItem('supaco_full_app_cache');
if (hasCache) {
const cacheInfo = document.querySelector('.cache-info');
cacheInfo.innerHTML = `
<i class="fas fa-database me-2"></i>
<strong>Dados salvos disponíveis!</strong> Última atualização: ${new Date().toLocaleString()}
`;
}
}
});
</script>
</body>
</html>