-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoffline.html
More file actions
277 lines (237 loc) · 7.89 KB
/
offline.html
File metadata and controls
277 lines (237 loc) · 7.89 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Offline - ProjectControl</title>
<style>
:root {
--color-primary: #0082c9;
--color-primary-hover: #006aa3;
--color-background: #ffffff;
--color-text: #333333;
--color-border: #e1e5e9;
--color-error: #e74c3c;
--color-warning: #f39c12;
--font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}
* {
box-sizing: border-box;
}
html {
font-size: 14px;
line-height: 1.5;
}
body {
font-family: var(--font-family);
color: var(--color-text);
background-color: var(--color-background);
margin: 0;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.offline-container {
text-align: center;
max-width: 500px;
padding: 2rem;
}
.offline-icon {
width: 80px;
height: 80px;
margin: 0 auto 2rem;
background-color: var(--color-warning);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 2rem;
color: white;
}
.offline-title {
font-size: 1.5rem;
font-weight: 600;
margin-bottom: 1rem;
color: var(--color-text);
}
.offline-message {
font-size: 1rem;
line-height: 1.6;
margin-bottom: 2rem;
color: #666;
}
.offline-actions {
display: flex;
gap: 1rem;
justify-content: center;
flex-wrap: wrap;
}
.btn {
display: inline-block;
padding: 0.75rem 1.5rem;
font-size: 0.875rem;
font-weight: 500;
text-align: center;
text-decoration: none;
border: 1px solid transparent;
border-radius: 4px;
cursor: pointer;
transition: all 0.2s ease;
background-color: var(--color-primary);
color: white;
}
.btn:hover {
background-color: var(--color-primary-hover);
}
.btn-secondary {
background-color: transparent;
color: var(--color-primary);
border-color: var(--color-primary);
}
.btn-secondary:hover {
background-color: var(--color-primary);
color: white;
}
.offline-status {
margin-top: 2rem;
padding: 1rem;
background-color: #f8f9fa;
border-radius: 4px;
font-size: 0.875rem;
color: #666;
}
.status-indicator {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
background-color: var(--color-error);
margin-right: 0.5rem;
}
.status-indicator.online {
background-color: #27ae60;
}
@media (prefers-color-scheme: dark) {
:root {
--color-background: #1a1a1a;
--color-text: #ffffff;
--color-border: #404040;
}
.offline-status {
background-color: #2a2a2a;
color: #ccc;
}
}
@media (max-width: 768px) {
.offline-container {
padding: 1rem;
}
.offline-title {
font-size: 1.25rem;
}
.offline-actions {
flex-direction: column;
}
.btn {
width: 100%;
}
}
</style>
</head>
<body>
<div class="offline-container">
<div class="offline-icon">
📶
</div>
<h1 class="offline-title">You're Offline</h1>
<p class="offline-message">
It looks like you've lost your internet connection. Some features of ProjectControl may not be available while you're offline.
</p>
<div class="offline-actions">
<button class="btn" onclick="window.location.reload()">
Try Again
</button>
<button class="btn btn-secondary" onclick="checkConnection()">
Check Connection
</button>
</div>
<div class="offline-status">
<span class="status-indicator" id="statusIndicator"></span>
<span id="statusText">Checking connection...</span>
</div>
</div>
<script>
// Check connection status
function checkConnection() {
const statusIndicator = document.getElementById('statusIndicator');
const statusText = document.getElementById('statusText');
statusText.textContent = 'Checking connection...';
statusIndicator.className = 'status-indicator';
// Try to fetch a small resource to test connectivity
fetch('/favicon.ico', {
method: 'HEAD',
cache: 'no-cache'
})
.then(() => {
statusIndicator.className = 'status-indicator online';
statusText.textContent = 'Connection restored! Reloading...';
setTimeout(() => {
window.location.reload();
}, 1000);
})
.catch(() => {
statusIndicator.className = 'status-indicator';
statusText.textContent = 'Still offline. Please check your internet connection.';
});
}
// Monitor connection status
function updateConnectionStatus() {
const statusIndicator = document.getElementById('statusIndicator');
const statusText = document.getElementById('statusText');
if (navigator.onLine) {
statusIndicator.className = 'status-indicator online';
statusText.textContent = 'Connection restored! Reloading...';
setTimeout(() => {
window.location.reload();
}, 1000);
} else {
statusIndicator.className = 'status-indicator';
statusText.textContent = 'You are currently offline.';
}
}
// Listen for online/offline events
window.addEventListener('online', updateConnectionStatus);
window.addEventListener('offline', updateConnectionStatus);
// Initial status check
updateConnectionStatus();
// Periodic connection check
setInterval(checkConnection, 30000); // Check every 30 seconds
// Try to reload when connection is restored
let reloadAttempts = 0;
const maxReloadAttempts = 10;
function attemptReload() {
if (reloadAttempts >= maxReloadAttempts) {
return;
}
reloadAttempts++;
fetch('/favicon.ico', {
method: 'HEAD',
cache: 'no-cache'
})
.then(() => {
window.location.reload();
})
.catch(() => {
// Try again in 5 seconds
setTimeout(attemptReload, 5000);
});
}
// Start attempting to reload after 10 seconds
setTimeout(attemptReload, 10000);
</script>
</body>
</html>