gtfs-to-html 2.11.5 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/index.js +38 -29
- package/dist/app/index.js.map +1 -1
- package/dist/bin/gtfs-to-html.js +54 -8
- package/dist/bin/gtfs-to-html.js.map +1 -1
- package/dist/index.js +54 -8
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
- package/views/default/css/overview_styles.css +4 -2
- package/views/default/css/timetable_styles.css +24 -9
- package/views/default/formatting_functions.pug +1 -1
- package/views/default/js/system-map.js +143 -92
- package/views/default/js/timetable-alerts.js +68 -50
- package/views/default/js/timetable-map.js +264 -164
- package/views/default/js/timetable-menu.js +64 -40
- package/views/default/overview.pug +1 -1
- package/views/default/overview_full.pug +4 -6
- package/views/default/timetable_continuation_as.pug +1 -1
- package/views/default/timetable_continuation_from.pug +1 -1
- package/views/default/timetable_horizontal.pug +2 -2
- package/views/default/timetable_hourly.pug +1 -1
- package/views/default/timetable_map.pug +1 -1
- package/views/default/timetable_menu.pug +2 -2
- package/views/default/timetable_note_symbol.pug +1 -1
- package/views/default/timetable_stop_name.pug +1 -1
- package/views/default/timetable_stoptime.pug +7 -7
- package/views/default/timetable_vertical.pug +3 -3
- package/views/default/timetablepage.pug +8 -8
- package/views/default/timetablepage_full.pug +2 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* global
|
|
1
|
+
/* global anchorme, Pbf, FeedMessage, stopData, routeData, routeIds, tripIds, stopIds, gtfsRealtimeUrls */
|
|
2
2
|
/* eslint no-var: "off", prefer-arrow-callback: "off", no-unused-vars: "off" */
|
|
3
3
|
|
|
4
4
|
let gtfsRealtimeAlertsInterval;
|
|
@@ -27,9 +27,11 @@ function formatAlertAsHtml(
|
|
|
27
27
|
affectedRouteIdsInTimetable,
|
|
28
28
|
affectedStopsIdsInTimetable,
|
|
29
29
|
) {
|
|
30
|
-
const
|
|
30
|
+
const alertElement = document.createElement('div');
|
|
31
|
+
alertElement.classList.add('timetable-alert');
|
|
31
32
|
|
|
32
|
-
const
|
|
33
|
+
const routeList = document.createElement('div');
|
|
34
|
+
routeList.classList.add('route-list');
|
|
33
35
|
|
|
34
36
|
for (const routeId of affectedRouteIdsInTimetable) {
|
|
35
37
|
const route = routeData[routeId];
|
|
@@ -38,44 +40,41 @@ function formatAlertAsHtml(
|
|
|
38
40
|
continue;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
const routeSwatch = document.createElement('div');
|
|
44
|
+
routeSwatch.classList.add('route-color-swatch');
|
|
45
|
+
routeSwatch.style.backgroundColor = route.route_color || '#000000';
|
|
46
|
+
routeSwatch.style.color = route.route_text_color || '#FFFFFF';
|
|
47
|
+
routeSwatch.textContent = route.route_short_name;
|
|
48
|
+
routeList.appendChild(routeSwatch);
|
|
47
49
|
}
|
|
48
50
|
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
.append(
|
|
53
|
-
jQuery('<div>')
|
|
54
|
-
.addClass('alert-title')
|
|
55
|
-
.text(alert.alert.header_text.translation[0].text),
|
|
56
|
-
);
|
|
51
|
+
const alertHeader = document.createElement('div');
|
|
52
|
+
alertHeader.classList.add('alert-header');
|
|
53
|
+
alertHeader.appendChild(routeList);
|
|
57
54
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
55
|
+
const alertTitle = document.createElement('div');
|
|
56
|
+
alertTitle.classList.add('alert-title');
|
|
57
|
+
alertTitle.textContent = alert.alert.header_text.translation[0].text;
|
|
58
|
+
alertHeader.appendChild(alertTitle);
|
|
59
|
+
|
|
60
|
+
// Use anchorme to convert URLs to clickable links while using textContent to prevent XSS
|
|
61
|
+
const alertBody = document.createElement('div');
|
|
62
|
+
alertBody.classList.add('alert-body');
|
|
63
|
+
|
|
64
|
+
const tempDiv = document.createElement('div');
|
|
65
|
+
tempDiv.textContent = alert.alert.description_text.translation[0].text;
|
|
66
|
+
alertBody.innerHTML = anchorme(tempDiv.innerHTML);
|
|
68
67
|
|
|
69
68
|
if (alert.alert.url?.translation?.[0].text) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
const moreInfoLink = document.createElement('a');
|
|
70
|
+
moreInfoLink.href = alert.alert.url.translation[0].text;
|
|
71
|
+
moreInfoLink.classList.add('btn-blue', 'btn-sm', 'alert-more-info');
|
|
72
|
+
moreInfoLink.textContent = 'More Info';
|
|
73
|
+
alertBody.appendChild(moreInfoLink);
|
|
75
74
|
}
|
|
76
75
|
|
|
77
76
|
if (affectedStopsIdsInTimetable.length > 0) {
|
|
78
|
-
const
|
|
77
|
+
const stopList = document.createElement('ul');
|
|
79
78
|
|
|
80
79
|
for (const stopId of affectedStopsIdsInTimetable) {
|
|
81
80
|
const stop = stopData[stopId];
|
|
@@ -84,23 +83,26 @@ function formatAlertAsHtml(
|
|
|
84
83
|
continue;
|
|
85
84
|
}
|
|
86
85
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
const listItem = document.createElement('li');
|
|
87
|
+
const stopName = document.createElement('div');
|
|
88
|
+
stopName.classList.add('stop-name');
|
|
89
|
+
stopName.textContent = stop.stop_name;
|
|
90
|
+
listItem.appendChild(stopName);
|
|
91
|
+
stopList.appendChild(listItem);
|
|
90
92
|
}
|
|
91
93
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
.appendTo($alertBody);
|
|
94
|
+
const stopsAffectedText = document.createElement('div');
|
|
95
|
+
stopsAffectedText.classList.add('alert-label');
|
|
96
|
+
stopsAffectedText.textContent = 'Stops Affected:';
|
|
96
97
|
|
|
97
|
-
|
|
98
|
+
alertBody.appendChild(stopsAffectedText);
|
|
99
|
+
alertBody.appendChild(stopList);
|
|
98
100
|
}
|
|
99
101
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
alertElement.appendChild(alertHeader);
|
|
103
|
+
alertElement.appendChild(alertBody);
|
|
102
104
|
|
|
103
|
-
return
|
|
105
|
+
return alertElement;
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
async function updateAlerts() {
|
|
@@ -172,25 +174,41 @@ async function updateAlerts() {
|
|
|
172
174
|
}
|
|
173
175
|
|
|
174
176
|
// Remove previously posted GTFS-RT alerts
|
|
175
|
-
|
|
177
|
+
const existingAlerts = document.querySelectorAll(
|
|
178
|
+
'.timetable-alerts-list .timetable-alert',
|
|
179
|
+
);
|
|
180
|
+
existingAlerts.forEach((alert) => alert.remove());
|
|
176
181
|
|
|
177
182
|
if (formattedAlerts.length > 0) {
|
|
178
183
|
// Remove the empty message if present
|
|
179
|
-
|
|
184
|
+
const emptyMessage = document.querySelector('.timetable-alert-empty');
|
|
185
|
+
if (emptyMessage) {
|
|
186
|
+
emptyMessage.style.display = 'none';
|
|
187
|
+
}
|
|
180
188
|
|
|
189
|
+
const alertsList = document.querySelector('.timetable-alerts-list');
|
|
181
190
|
for (const alert of formattedAlerts) {
|
|
182
|
-
|
|
191
|
+
alertsList.appendChild(alert);
|
|
183
192
|
}
|
|
184
193
|
} else {
|
|
185
194
|
// Replace the empty message if present
|
|
186
|
-
|
|
195
|
+
const emptyMessage = document.querySelector('.timetable-alert-empty');
|
|
196
|
+
if (emptyMessage) {
|
|
197
|
+
emptyMessage.style.display = '';
|
|
198
|
+
}
|
|
187
199
|
}
|
|
188
200
|
} catch (error) {
|
|
189
201
|
console.error(error);
|
|
190
202
|
}
|
|
191
203
|
}
|
|
192
204
|
|
|
193
|
-
|
|
205
|
+
if (document.readyState === 'loading') {
|
|
206
|
+
document.addEventListener('DOMContentLoaded', initializeAlerts);
|
|
207
|
+
} else {
|
|
208
|
+
initializeAlerts();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function initializeAlerts() {
|
|
194
212
|
if (!gtfsRealtimeAlertsInterval && gtfsRealtimeUrls?.realtimeAlerts?.url) {
|
|
195
213
|
const alertUpdateInterval = 60 * 1000; // Every Minute
|
|
196
214
|
updateAlerts();
|
|
@@ -198,4 +216,4 @@ jQuery(() => {
|
|
|
198
216
|
updateAlerts();
|
|
199
217
|
}, alertUpdateInterval);
|
|
200
218
|
}
|
|
201
|
-
}
|
|
219
|
+
}
|