-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.html
More file actions
209 lines (171 loc) · 4 KB
/
template.html
File metadata and controls
209 lines (171 loc) · 4 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{title}</title>
<style>
body {{
margin: 0;
padding: 20px;
background: #111;
color: #eee;
font-family: Arial, sans-serif;
}}
h1 {{
margin-bottom: 20px;
font-size: 2.2rem;
text-align: center;
color: #fff;
}}
.grid {{
display: grid;
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
grid-gap: 20px;
margin-top: 20px;
}}
.stop-card {{
background: #1b1b1b;
padding: 15px 20px;
border-radius: 8px;
box-shadow: 0 0 10px #000;
}}
.stop-title {{
font-size: 1.6rem;
margin-bottom: 10px;
color: #4da3ff;
}}
table {{
width: 100%;
border-collapse: collapse;
}}
th {{
text-align: left;
padding: 6px 0;
font-size: 1rem;
color: #bbb;
border-bottom: 1px solid #333;
}}
td {{
padding: 8px 0;
font-size: 1.2rem;
border-bottom: 1px solid #222;
}}
/* Bus column spacing */
td:nth-child(2), /* Line */
td:nth-child(3), /* Direction */
td:nth-child(4), /* Sched */
td:nth-child(5) {{ /* Exp */
padding-right: 20px !important;
}}
.on-time {{
color: #7CFC00;
}}
.delayed {{
color: #ff4444;
}}
/* Train cards */
.train-card {{
background: #00112b;
padding: 15px 20px;
border-radius: 8px;
box-shadow: 0 0 12px #000;
font-family: "DejaVu Sans Mono", "Consolas", monospace;
}}
.train-title {{
font-size: 1.6rem;
margin-bottom: 12px;
color: #ffdd00;
text-transform: uppercase;
letter-spacing: 1px;
}}
/* Train column spacing WITHOUT overriding colours */
.train-table td:nth-child(2),
.train-table td:nth-child(3),
.train-table td:nth-child(4) {{
padding-right: 20px !important;
color: inherit !important;
}}
/* Train status colours */
.train-on-time {{
color: #00ff66 !important;
}}
.train-delayed {{
color: #ff4444 !important;
}}
.train-due-soon {{
color: #ffdd00 !important;
}}
#live-clock {{
margin-top: 40px;
text-align: center;
font-size: 2.4rem;
color: #ffdd00;
font-family: "DejaVu Sans Mono", "Consolas", monospace;
}}
#last-updated {{
margin-top: 10px;
text-align: center;
font-size: 1.2rem;
color: #bbb;
font-family: "DejaVu Sans Mono", "Consolas", monospace;
}}
/* Force correct colours for train Exp column */
.train-table td.train-on-time {{
color: #00ff66 !important;
}}
.train-table td.train-due-soon {{
color: #ffdd00 !important;
}}
.train-table td.train-delayed {{
color: #ff4444 !important;
}}
</style>
</head>
<body>
<h1>{heading}</h1>
<div class="grid">
{content}
</div>
<div id="live-clock"></div>
<div id="last-updated">Last updated: {last_updated}</div>
<script>
let currentTime = null;
async function syncTime() {{
try {{
const res = await fetch("https://timeapi.io/api/Time/current/zone?timeZone=Europe/London");
const data = await res.json();
currentTime = new Date(
data.year,
data.month - 1,
data.day,
data.hour,
data.minute,
data.seconds
);
}} catch (e) {{
console.error("Time sync failed", e);
currentTime = new Date();
}}
}}
function updateClock() {{
if (!currentTime) return;
currentTime = new Date(currentTime.getTime() + 1000);
const hours = currentTime.getHours().toString().padStart(2, '0');
const minutes = currentTime.getMinutes().toString().padStart(2, '0');
const seconds = currentTime.getSeconds().toString().padStart(2, '0');
document.getElementById("live-clock").textContent =
hours + ":" + minutes + ":" + seconds;
}}
syncTime().then(() => {{
updateClock();
setInterval(updateClock, 1000);
}});
setInterval(syncTime, 10 * 60 * 1000);
// Auto-refresh the page every 60 seconds
setInterval(() => {{
location.reload();
}}, 60000);
</script>
</body>
</html>