-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudent-console.html
More file actions
277 lines (257 loc) · 14.3 KB
/
Copy pathstudent-console.html
File metadata and controls
277 lines (257 loc) · 14.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Console | BusTrack</title>
<link rel="stylesheet" href="css/leaflet.css?v=12">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.4.0/css/all.min.css" crossorigin="anonymous" referrerpolicy="no-referrer">
<script src="js/icons.js?v=12"></script>
<link rel="stylesheet" href="css/driver.css">
<link rel="manifest" href="/manifest.json">
<meta name="theme-color" content="#1A1A1A">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<meta name="apple-mobile-web-app-title" content="BusTrack">
<style>
/* Custom location prompt styling reusing driver UI aesthetics */
.location-prompt-modal {
display: none;
position: fixed;
inset: 0;
background: rgba(15, 23, 42, 0.4);
z-index: 10000;
align-items: center;
justify-content: center;
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
.location-prompt-modal.active {
display: flex;
}
.location-prompt-card {
background: rgba(255, 255, 255, 0.8);
padding: 32px;
border-radius: 24px;
width: 90%;
max-width: 420px;
text-align: center;
border: 1px solid rgba(255, 255, 255, 0.9);
box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
}
.location-prompt-card h3 {
color: #0f172a;
margin-bottom: 12px;
font-size: 22px;
font-weight: 800;
letter-spacing: -0.5px;
}
.location-prompt-card p {
color: #64748b;
margin-bottom: 28px;
line-height: 1.6;
font-size: 15px;
font-weight: 500;
}
.prompt-btn-group {
display: flex;
gap: 12px;
}
.prompt-btn-group button {
flex: 1;
padding: 14px;
border-radius: 14px;
font-weight: 700;
cursor: pointer;
border: none;
font-family: 'Inter', sans-serif;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
font-size: 14px;
}
.btn-allow {
background: #4f46e5;
color: white;
box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}
.btn-allow:hover {
background: #4338ca;
transform: translateY(-2px);
box-shadow: 0 8px 16px rgba(79, 70, 229, 0.3);
}
.btn-deny {
background: #f1f5f9;
color: #64748b;
}
.btn-deny:hover {
background: #e2e8f0;
color: #0f172a;
}
/* Map Controls - Follow Bus */
#follow-bus-button {
position: absolute;
top: 16px;
right: 16px;
z-index: 1000;
padding: 10px 18px;
background: rgba(255, 255, 255, 0.9);
border: 1px solid rgba(226, 232, 240, 0.8);
border-radius: 12px;
cursor: pointer;
font-size: 14px;
font-weight: 700;
color: #0f172a;
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}
#follow-bus-button.active {
color: white;
border-color: #059669;
}
#follow-bus-button:hover {
transform: scale(1.05);
}
</style>
<script src="js/supabase.min.js"></script>
<script src="js/supabase-client.js"></script>
<script src="js/session-protection.js"></script>
<script>protectRoute('student');</script>
</head>
<body>
<div id="offline-indicator" style="display:none; position:fixed; bottom:20px; left:50%; transform:translateX(-50%); background:#1A1A1A; color:white; padding:10px 20px; border-radius:20px; font-size:13px; font-weight:500; font-family:Inter,sans-serif; z-index:9999; box-shadow:0 4px 20px rgba(0,0,0,0.3); align-items:center; gap:8px;">
You are offline - showing cached data
</div>
<!-- NAVBAR -->
<nav class="navbar">
<div class="brand" onclick="window.location.href='student-dashboard.html'" style="cursor: pointer; display: flex; align-items: center; gap: 8px;">
<span style="font-size:18px;">←</span>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 462 244" role="img" aria-label="Where Is My Bus" width="36" height="36"><path fill-rule="evenodd" fill="currentColor" d="M406.66 132.0 L428.16 111.0 L445.38 91.0 L453.18 76.0 L455.31 68.0 L456.2 57.0 L455.31 48.0 L451.19 35.0 L441.0 20.37 L433.0 13.89 L425.0 9.72 L415.0 6.68 L405.0 5.83 L396.0 6.7 L386.0 9.66 L377.0 14.62 L369.0 21.38 L363.67 28.0 L358.74 37.0 L355.69 47.0 L354.6 60.0 L357.58 76.0 L365.85 92.0 L396.63 126.0 L404.0 132.24 L406.66 132.0 Z M320.22 238.0 L331.0 236.31 L342.0 232.2 L353.0 225.19 L361.33 217.0 L369.37 205.0 L400.82 145.0 L381.0 127.84 L357.0 171.82 L352.58 175.0 L340.17 199.0 L335.94 204.0 L327.0 209.23 L314.0 211.33 L303.0 209.34 L292.31 203.0 L284.6 193.0 L252.69 131.0 L278.0 82.24 L332.0 185.4 L347.66 160.0 L289.3 45.0 L281.21 34.0 L272.0 25.69 L257.0 17.88 L239.0 14.76 L223.0 16.62 L208.0 22.76 L197.33 31.0 L188.89 41.0 L159.0 97.67 L155.62 93.0 L129.37 41.0 L120.0 29.62 L109.0 21.59 L98.0 16.84 L86.0 14.65 L5.43 15.0 L103.76 206.0 L112.0 217.56 L123.0 227.27 L139.0 235.2 L158.0 238.15 L175.0 236.27 L191.0 229.34 L202.0 220.51 L210.27 210.0 L237.0 159.79 L260.65 205.0 L267.8 216.0 L273.38 222.0 L283.0 229.37 L296.0 235.36 L304.0 237.35 L320.22 238.0 Z M409.0 77.03 L403.0 77.3 L395.0 74.38 L388.82 68.0 L386.55 63.0 L385.72 55.0 L387.79 48.0 L394.0 40.71 L400.0 37.67 L407.0 36.95 L414.0 38.78 L421.35 45.0 L424.41 51.0 L425.21 59.0 L422.29 68.0 L416.0 74.38 L409.0 77.03 Z M118.0 175.46 L49.0 41.52 L83.0 41.34 L91.0 42.69 L100.53 48.0 L107.45 57.0 L142.95 127.0 L118.0 175.46 Z M163.0 211.01 L156.0 211.11 L147.0 209.17 L139.0 205.13 L135.46 201.0 L208.8 60.0 L217.32 49.0 L230.0 42.65 L241.0 41.89 L249.0 43.71 L255.0 46.67 L262.34 54.0 L188.33 195.0 L183.29 202.0 L178.0 206.28 L171.0 209.45 L163.0 211.01 Z"/></svg>
<span>BusTrack <em>Student Console</em></span>
</div>
<span class="bus-badge" id="assigned-bus-label">Loading...</span>
<button class="logout-btn" onclick="studentLogout()" style="margin-left: auto; margin-right: 15px; background: #2a2a2a; border: 1px solid #444; color: #fff; padding: 10px 16px; border-radius: 8px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 6px;"><i class="fas fa-sign-out-alt"></i> Logout</button>
</nav>
<script>
function studentLogout() {
localStorage.removeItem('userSession');
window.location.href = 'index.html';
}
</script>
<!-- STAT CARDS (Row 1: Speed, Duration, Position) -->
<div class="stats-grid">
<div class="stat-card">
<div class="stat-label">SPEED</div>
<div class="stat-value" id="speed-display">0 km/h</div>
</div>
<div class="stat-card">
<div class="stat-label">DURATION</div>
<div class="stat-value" id="trip-duration-display">00:00:00</div>
</div>
<div class="stat-card">
<div class="stat-label">CURRENT POSITION</div>
<div class="stat-value searching" id="location-display">Searching...</div>
</div>
</div>
<!-- ROAD ETA PANEL (Admin-set destination + student proximity) -->
<div style="display:grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap:14px; padding: 0 28px; margin-top:14px;">
<!-- CARD: Destination ETA -->
<div style="background:rgba(255,255,255,0.88); backdrop-filter:blur(16px); -webkit-backdrop-filter:blur(16px); border:1px solid rgba(226,232,240,0.9); border-radius:20px; padding:18px 22px; box-shadow:0 8px 20px -5px rgba(15,23,42,0.06); position:relative; overflow:hidden;">
<div style="position:absolute;top:0;left:0;right:0;height:4px;background:linear-gradient(90deg,#059669,#34d399);"></div>
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:6px;">
<span style="font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:.06em;color:#059669;display:flex;align-items:center;gap:5px;"><i class="fas fa-flag-checkered"></i> Bus to Destination</span>
<span id="road-source-badge" style="background:rgba(5,150,105,.1);color:#059669;font-size:10px;font-weight:800;padding:2px 7px;border-radius:10px;">ROAD</span>
</div>
<div id="road-eta-dest" style="font-size:26px;font-weight:800;color:#1e293b;letter-spacing:-.5px;margin-bottom:3px;">Loading...</div>
<div id="road-dist-dest" style="font-size:12px;color:#64748b;font-weight:600;"><span id="dest-name-display">—</span></div>
</div>
<!-- CARD: Bus Status -->
<div style="background:rgba(255,255,255,0.88); backdrop-filter:blur(16px); -webkit-backdrop-filter:blur(16px); border:1px solid rgba(226,232,240,0.9); border-radius:20px; padding:18px 22px; box-shadow:0 8px 20px -5px rgba(15,23,42,0.06); position:relative; overflow:hidden;">
<div style="position:absolute;top:0;left:0;right:0;height:4px;background:linear-gradient(90deg,#6366f1,#818cf8);"></div>
<div style="font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:.06em;color:#6366f1;margin-bottom:6px;display:flex;align-items:center;gap:5px;"><i class="fas fa-circle-info"></i> Bus Status</div>
<div style="display:flex;align-items:center;gap:10px;">
<div id="road-bus-status-dot" style="width:10px;height:10px;border-radius:50%;background:#10b981;box-shadow:0 0 8px #10b981;flex-shrink:0;"></div>
<div id="road-bus-status" style="font-size:20px;font-weight:800;color:#1e293b;">Connecting...</div>
</div>
<div style="display:flex;gap:16px;margin-top:10px;">
<div><div style="font-size:10px;color:#94a3b8;font-weight:700;text-transform:uppercase;">Current</div><div id="road-speed-display" style="font-size:15px;font-weight:800;color:#1e293b;">— km/h</div></div>
<div><div style="font-size:10px;color:#94a3b8;font-weight:700;text-transform:uppercase;">Average</div><div id="road-avg-speed" style="font-size:15px;font-weight:800;color:#1e293b;">— km/h</div></div>
<div><div style="font-size:10px;color:#94a3b8;font-weight:700;text-transform:uppercase;">Last GPS</div><div id="road-last-gps" style="font-size:15px;font-weight:800;color:#1e293b;">—</div></div>
</div>
</div>
<!-- CARD: Your Location vs Bus -->
<div style="background:rgba(255,255,255,0.88); backdrop-filter:blur(16px); -webkit-backdrop-filter:blur(16px); border:1px solid rgba(226,232,240,0.9); border-radius:20px; padding:18px 22px; box-shadow:0 8px 20px -5px rgba(15,23,42,0.06); position:relative; overflow:hidden;">
<div style="position:absolute;top:0;left:0;right:0;height:4px;background:linear-gradient(90deg,#4f46e5,#818cf8);"></div>
<div style="font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:.06em;color:#4f46e5;margin-bottom:6px;display:flex;align-items:center;gap:5px;"><i class="fas fa-person-walking"></i> Bus to You (Your Location)</div>
<div id="road-student-status" style="display:inline-block;font-size:14px;font-weight:800;padding:5px 14px;border-radius:20px;background:rgba(100,116,139,0.08);color:#64748b;margin-bottom:8px;">Allow Location</div>
<div id="road-dist-student" style="font-size:12px;color:#64748b;font-weight:600;">Share location for road distance to bus</div>
</div>
</div>
<!-- Hidden next stop for JS reference — not visible on page -->
<span id="next-stop-display" style="display:none;"></span>
<!-- TRIP STATUS BAR — matches driver console exactly -->
<div class="trip-status-bar" id="trip-status-bar">
<div class="status-dot-green"></div>
<span id="trip-status-text">Trip active — GPS tracking live</span>
</div>
<!-- MAP -->
<div class="map-wrapper" style="margin-top: 15px; position: relative;">
<button id="alert-nearby-btn" onclick="toggleNearbyAlert()" style="position: absolute; top: 16px; left: 16px; z-index: 1000; padding: 10px 18px; background: rgba(255, 255, 255, 0.9); border: 1px solid rgba(226, 232, 240, 0.8); border-radius: 12px; cursor: pointer; font-size: 14px; font-weight: 700; color: #0f172a; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: all 0.3s ease; box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05); display: flex; align-items: center; gap: 8px;">
<i class="fas fa-bell"></i> Alert when nearby
</button>
<div id="map"></div>
</div>
<!-- Optional Location Prompt -->
<div class="location-prompt-modal" id="locationPrompt">
<div class="location-prompt-card">
<h3>Enhance Live Tracking</h3>
<p>Allow location access for better route accuracy? This will show your position relative to the bus and improve timing estimates.</p>
<div class="prompt-btn-group">
<button class="btn-deny" id="btn-deny">Not Now</button>
<button class="btn-allow" id="btn-allow">Allow Access</button>
</div>
</div>
</div>
<script src="js/leaflet.js?v=12"></script>
<script src="js/supabase.min.js"></script>
<script src="js/supabase-client.js"></script>
<script src="js/haversine.js"></script>
<script src="js/routes.js"></script>
<script src="js/map.js?v=12"></script>
<script src="js/location.js"></script>
<script src="js/gps.js"></script>
<script src="js/timer.js"></script>
<script src="js/session-protection.js"></script>
<script src="js/road-eta.js"></script>
<script src="js/student-console.js"></script>
<script>
protectRoute('student');
const session = JSON.parse(localStorage.getItem('userSession'));
if (!session) window.location.href = 'index.html';
</script>
<script>
window.addEventListener('online', () => {
document.getElementById('offline-indicator').style.display = 'none';
});
window.addEventListener('offline', () => {
document.getElementById('offline-indicator').style.display = 'flex';
});
if (!navigator.onLine) {
document.getElementById('offline-indicator').style.display = 'flex';
}
</script>
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('./sw.js');
});
}
</script>
</body>
</html>