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.
@@ -1,62 +1,86 @@
1
- /* global jQuery */
2
- /* eslint no-unused-vars: "off" */
1
+ /* global toggleMap */
3
2
 
4
3
  function showSelectedTimetable() {
5
- if (jQuery('.timetable').length === 1) {
6
- showTimetable(jQuery('.timetable').data('timetable-id'));
7
- return false;
4
+ const timetables = document.querySelectorAll('.timetable');
5
+
6
+ if (timetables.length === 1) {
7
+ showTimetable(timetables[0].dataset.timetableId);
8
+ return;
8
9
  }
9
10
 
10
- jQuery('#day_list_selector input[name="dayList"]').each((index, element) => {
11
- jQuery(element)
12
- .parents('label')
13
- .toggleClass('btn-blue', jQuery(element).is(':checked'));
14
- jQuery(element)
15
- .parents('label')
16
- .toggleClass('btn-gray', jQuery(element).is(':not(:checked)'));
17
- });
11
+ document
12
+ .querySelectorAll('#day_list_selector input[name="dayList"]')
13
+ .forEach((element) => {
14
+ const label = element.closest('label');
15
+ if (label) {
16
+ label.classList.toggle('btn-blue', element.checked);
17
+ label.classList.toggle('btn-gray', !element.checked);
18
+ }
19
+ });
18
20
 
19
- jQuery('#direction_name_selector input[name="directionId"]').each(
20
- (index, element) => {
21
- jQuery(element)
22
- .parents('label')
23
- .toggleClass('btn-blue', jQuery(element).is(':checked'));
24
- jQuery(element)
25
- .parents('label')
26
- .toggleClass('btn-gray', jQuery(element).is(':not(:checked)'));
27
- },
28
- );
21
+ document
22
+ .querySelectorAll('#direction_name_selector input[name="directionId"]')
23
+ .forEach((element) => {
24
+ const label = element.closest('label');
25
+ if (label) {
26
+ label.classList.toggle('btn-blue', element.checked);
27
+ label.classList.toggle('btn-gray', !element.checked);
28
+ }
29
+ });
29
30
 
30
- const dayList = jQuery(
31
+ const dayListInput = document.querySelector(
31
32
  '#day_list_selector input[name="dayList"]:checked',
32
- ).val();
33
+ );
34
+ const dayList = dayListInput ? dayListInput.value : null;
33
35
 
34
- const directionId = jQuery(
36
+ const directionIdInput = document.querySelector(
35
37
  '#direction_name_selector input[name="directionId"]:checked',
36
- ).val();
38
+ );
39
+ const directionId = directionIdInput ? directionIdInput.value : null;
37
40
 
38
- jQuery('.timetable').hide();
41
+ timetables.forEach((timetable) => {
42
+ timetable.style.display = 'none';
43
+ });
39
44
 
40
- const id = jQuery(
45
+ const selectedTimetable = document.querySelector(
41
46
  `.timetable[data-day-list="${dayList}"][data-direction-id="${directionId}"]`,
42
- ).data('timetable-id');
47
+ );
43
48
 
44
- showTimetable(id);
49
+ if (selectedTimetable) {
50
+ const id = selectedTimetable.dataset.timetableId;
51
+ showTimetable(id);
52
+ }
45
53
  }
46
54
 
47
55
  function showTimetable(id) {
48
- jQuery(`#timetable_id_${id}`).show();
49
- toggleMap(id);
56
+ const timetable = document.querySelector(
57
+ `.timetable[data-timetable-id="${id}"]`,
58
+ );
59
+ if (timetable) {
60
+ timetable.style.display = 'block';
61
+ }
62
+ // Check if toggleMap is defined
63
+ if (typeof toggleMap === 'function') {
64
+ toggleMap(id);
65
+ }
50
66
  }
51
67
 
52
- jQuery(() => {
68
+ document.addEventListener('DOMContentLoaded', () => {
53
69
  showSelectedTimetable();
54
70
 
55
- jQuery('#day_list_selector input[name="dayList"]').change(() => {
56
- showSelectedTimetable();
57
- });
71
+ document
72
+ .querySelectorAll('#day_list_selector input[name="dayList"]')
73
+ .forEach((input) => {
74
+ input.addEventListener('change', () => {
75
+ showSelectedTimetable();
76
+ });
77
+ });
58
78
 
59
- jQuery('#direction_name_selector input[name="directionId"]').change(() => {
60
- showSelectedTimetable();
61
- });
79
+ document
80
+ .querySelectorAll('#direction_name_selector input[name="directionId"]')
81
+ .forEach((input) => {
82
+ input.addEventListener('change', () => {
83
+ showSelectedTimetable();
84
+ });
85
+ });
62
86
  });
@@ -10,7 +10,7 @@ include formatting_functions.pug
10
10
  each timetablePage in sortTimetablePages(timetablePageGroup.timetablePages)
11
11
  if config.allowEmptyTimetables || timetablePage.consolidatedTimetables.length > 0
12
12
  - const timetableRoutes = _.uniqBy(_.flatMap(timetablePage.consolidatedTimetables, timetable => timetable.routes), 'route_id')
13
- a.timetable-page-link(href=`${timetablePage.relativePath}` data-route-ids=`${timetableRoutes.map((route) => route.route_id).join(',')}`)
13
+ a.timetable-page-link(href=timetablePage.relativePath data-route-ids=timetableRoutes.map((route) => route.route_id).join(','))
14
14
  each route in timetableRoutes
15
15
  .route-color-swatch-large(style=`background-color: ${formatRouteColor(route)}; color: ${formatRouteTextColor(route)};`)= route.route_short_name || ''
16
16
  div
@@ -4,13 +4,11 @@ block content
4
4
 
5
5
  block extraHeader
6
6
  if config.showMap
7
- script(src="https://unpkg.com/jquery@3.7.1/dist/jquery.min.js" crossorigin="anonymous")
8
- script(src="https://unpkg.com/lodash@4.17.21/lodash.min.js" crossorigin="anonymous")
9
- script(src="https://unpkg.com/maplibre-gl@^5.7.0/dist/maplibre-gl.js")
10
- script(src="https://unpkg.com/@maplibre/maplibre-gl-geocoder@1.9.0/dist/maplibre-gl-geocoder.js")
7
+ script(src=`${config.assetPath}js/maplibre-gl.js`)
8
+ script(src=`${config.assetPath}js/maplibre-gl-geocoder.js`)
11
9
  script(src=`${config.assetPath}js/system-map.js`)
12
10
 
13
- link(href="https://unpkg.com/maplibre-gl@^5.7.0/dist/maplibre-gl.css" rel="stylesheet")
14
- link(href="https://unpkg.com/@maplibre/maplibre-gl-geocoder@1.9.0/dist/maplibre-gl-geocoder.css" rel="stylesheet")
11
+ link(href=`${config.assetPath}css/maplibre-gl.css` rel="stylesheet")
12
+ link(href=`${config.assetPath}css/maplibre-gl-geocoder.css` rel="stylesheet")
15
13
 
16
14
  link(rel="stylesheet" href=`${config.assetPath}css/overview_styles.css`)
@@ -2,6 +2,6 @@
2
2
  td.run-footer(style=routeColorCss)
3
3
  if trip.continues_as_route
4
4
  if trip.continues_as_route.route.route_url
5
- a.continues-as-route(href=`${trip.continues_as_route.route.route_url}` style=routeColorCss data-trip-id=trip.continues_as_route.trip_id)= trip.continues_as_route.route.route_short_name
5
+ a.continues-as-route(href=trip.continues_as_route.route.route_url style=routeColorCss data-trip-id=trip.continues_as_route.trip_id)= trip.continues_as_route.route.route_short_name
6
6
  else
7
7
  .continues-as-route(data-trip-id=trip.continues_as_route.trip_id)= trip.continues_as_route.route.route_short_name
@@ -2,6 +2,6 @@
2
2
  td.run-footer(style=routeColorCss)
3
3
  if trip.continues_from_route
4
4
  if trip.continues_from_route.route.route_url
5
- a.continues-from-route(href=`${trip.continues_from_route.route.route_url}` style=routeColorCss data-trip-id=trip.continues_from_route.trip_id)= trip.continues_from_route.route.route_short_name
5
+ a.continues-from-route(href=trip.continues_from_route.route.route_url style=routeColorCss data-trip-id=trip.continues_from_route.trip_id)= trip.continues_from_route.route.route_short_name
6
6
  else
7
7
  .continues-from-route(data-trip-id=trip.continues_from_route.trip_id)= trip.continues_from_route.route.route_short_name
@@ -4,7 +4,7 @@
4
4
  colgroup
5
5
  col
6
6
  each trip, idx in timetable.orderedTrips
7
- col(id=`trip_id_${formatHtmlId(trip.trip_id)}` class=`run_${idx} ${(trip.trip_short_name) ? 'trip_short_name_' + trip.trip_short_name : ''}`)
7
+ col(class=`run_${idx} ${(trip.trip_short_name) ? 'trip_short_name_' + trip.trip_short_name : ''}` data-trip-id=trip.trip_id)
8
8
  thead
9
9
  tr
10
10
  th.stop-header(scope="col") Stop
@@ -29,7 +29,7 @@
29
29
  th(scope="row" colspan=`${stop.trips.length + 1}`)= stop.stop_city
30
30
  - previousCity = stop.stop_city
31
31
 
32
- tr.stop-row(id=`stop_id_${formatHtmlId(stop.stop_id)}` data-stop-id=`${stop.stop_id}` data-is-timepoint=`${stop.is_timepoint}`)
32
+ tr.stop-row(data-stop-id=stop.stop_id data-is-timepoint=stop.is_timepoint.toString())
33
33
  th.stop-name-container(scope="row")
34
34
  include timetable_stop_name.pug
35
35
 
@@ -17,7 +17,7 @@
17
17
  th(scope="row" colspan="2")= stop.stop_city
18
18
  - previousCity = stop.stop_city
19
19
 
20
- tr.stop-row(id=`stop_id_${formatHtmlId(stop.stop_id)}` data-stop-id=`${stop.stop_id}`)
20
+ tr.stop-row(data-stop-id=stop.stop_id)
21
21
  th.stop-name-container(scope="row")
22
22
  include timetable_stop_name.pug
23
23
 
@@ -1,5 +1,5 @@
1
1
  .map-container
2
- .map(id=`map_timetable_id_${formatHtmlId(timetable.timetable_id)}`)
2
+ .map(data-timetable-id=timetable.timetable_id)
3
3
  .map-legend
4
4
  .legend-item
5
5
  .legend-icon
@@ -5,7 +5,7 @@ if timetablePage.consolidatedTimetables.length > 1
5
5
  - const showDayList = timetablePageHasDifferentDays(timetablePage);
6
6
  each timetable in timetablePage.consolidatedTimetables
7
7
  li
8
- a(href=`#timetable_id_${formatHtmlId(timetable.timetable_id)}`)
8
+ a(href=`#${cssEscape(`timetable_id_${timetable.timetable_id}`)}`)
9
9
  if showTimetableLabel
10
10
  span= timetable.timetable_label
11
11
  if showTimetableLabel && showDayList
@@ -27,7 +27,7 @@ if timetablePage.consolidatedTimetables.length > 1
27
27
  div
28
28
  h3= dayList
29
29
  each timetable in group
30
- a.btn-blue(href=`#timetable_id_${formatHtmlId(timetable.timetable_id)}`)= timetable.timetable_label
30
+ a.btn-blue(href=`#${cssEscape(`timetable_id_${timetable.timetable_id}`)}`)= timetable.timetable_label
31
31
 
32
32
  if config.menuType === 'radio'
33
33
  .timetable-radio-menu
@@ -1,4 +1,4 @@
1
- a(href=`#note-${timetable.timetable_id}-${note.note_id}` class=`timetable-note-${note.note_id}`).symbol
1
+ a(href=`#${cssEscape(`note-${timetable.timetable_id}-${note.note_id}`)}` data-note-id=note.note_id).symbol
2
2
  if timetable.routes.length <= 1 && timetable.orientation === 'vertical'
3
3
  span= note.symbol
4
4
  else
@@ -1,7 +1,7 @@
1
1
  - const stopName = `${stop.stop_name}${stop.type === 'arrival' ? ' (Arrival)' : stop.type === 'departure' ? ' (Departure)' : ''}`;
2
2
 
3
3
  if config.linkStopUrls && stop.stop_url
4
- a.stop-name(href=`${stop.stop_url}`)= stopName
4
+ a.stop-name(href=stop.stop_url)= stopName
5
5
  each note in getNotesForStop(timetable.notes, stop)
6
6
  include timetable_note_symbol.pug
7
7
  else
@@ -1,17 +1,17 @@
1
- td.stop-time(class=`${stoptime.classes.join(' ')}`)
1
+ td.stop-time(class=stoptime.classes.join(' '))
2
2
  if config.showStoptimesForRequestStops || (!stoptime.requestDropoff && !stoptime.requestPickup)
3
3
  span.stop-time-text!= stoptime.formatted_time
4
4
  if stoptime.skipped && timetable.noServiceSymbol !== null
5
- a(href=`#note-${timetable.timetable_id}-no-service`).symbol= timetable.noServiceSymbol
5
+ a(href=`#${cssEscape(`note-${timetable.timetable_id}-no-service`)}`).symbol= timetable.noServiceSymbol
6
6
  if stoptime.interpolated && timetable.interpolatedStopSymbol !== null
7
- a(href=`#note-${timetable.timetable_id}-interpolated-stop`).symbol= timetable.interpolatedStopSymbol
7
+ a(href=`#${cssEscape(`note-${timetable.timetable_id}-interpolated-stop`)}`).symbol= timetable.interpolatedStopSymbol
8
8
  if stoptime.requestPickup && timetable.requestPickupSymbol !== null
9
- a(href=`#note-${timetable.timetable_id}-request-pickup`).symbol= timetable.requestPickupSymbol
9
+ a(href=`#${cssEscape(`note-${timetable.timetable_id}-request-pickup`)}`).symbol= timetable.requestPickupSymbol
10
10
  if stoptime.noPickup && timetable.noPickupSymbol !== null
11
- a(href=`#note-${timetable.timetable_id}-no-pickup`).symbol= timetable.noPickupSymbol
11
+ a(href=`#${cssEscape(`note-${timetable.timetable_id}-no-pickup`)}`).symbol= timetable.noPickupSymbol
12
12
  if stoptime.requestDropoff && timetable.requestDropoffSymbol !== null
13
- a(href=`#note-${timetable.timetable_id}-request-dropoff`).symbol= timetable.requestDropoffSymbol
13
+ a(href=`#${cssEscape(`note-${timetable.timetable_id}-request-dropoff`)}`).symbol= timetable.requestDropoffSymbol
14
14
  if stoptime.noDropoff && timetable.noDropoffSymbol !== null
15
- a(href=`#note-${timetable.timetable_id}-no-dropoff`).symbol= timetable.noDropoffSymbol
15
+ a(href=`#${cssEscape(`note-${timetable.timetable_id}-no-dropoff`)}`).symbol= timetable.noDropoffSymbol
16
16
  each note in getNotesForStoptime(timetable.notes, stoptime)
17
17
  include timetable_note_symbol.pug
@@ -15,7 +15,7 @@
15
15
  if timetable.has_continues_from_route
16
16
  col
17
17
  each stop, idx in timetable.stops
18
- col(id=`stop_id_${formatHtmlId(stop.stop_id)}` class=`stop-${idx}` data-stop-id=`${stop.stop_id}` data-is-timepoint=`${stop.is_timepoint}`)
18
+ col(class=`stop-${idx}` data-stop-id=stop.stop_id data-is-timepoint=stop.is_timepoint.toString())
19
19
  if timetable.has_continues_as_route
20
20
  col
21
21
  thead
@@ -45,12 +45,12 @@
45
45
  if timetable.has_continues_from_route
46
46
  td
47
47
 
48
- td.trip-frequency(colspan=`${columnCount}`)!= formatFrequencyWarning(timetable.frequencies)
48
+ td.trip-frequency(colspan=columnCount)!= formatFrequencyWarning(timetable.frequencies)
49
49
 
50
50
  if timetable.has_continues_as_route
51
51
  td
52
52
  each trip, idx in timetable.orderedTrips
53
- tr.trip-row(id=`trip_id_${formatHtmlId(trip.trip_id)}`)
53
+ tr.trip-row(data-trip-id=trip.trip_id)
54
54
  if timetableHasTripNotes || timetable.routes.length > 1
55
55
  td.trip-notes
56
56
  .trip-name= formatTripName(trip, idx, timetable)
@@ -21,7 +21,7 @@ include formatting_functions.pug
21
21
  | There are no service alerts at this time.
22
22
 
23
23
  each timetable in timetablePage.consolidatedTimetables
24
- .timetable(id=`timetable_id_${formatHtmlId(timetable.timetable_id)}` data-day-list=timetable.dayList data-direction-name=timetable.direction_name || timetable.timetable_label data-timetable-id=`${formatHtmlId(timetable.timetable_id)}` data-direction-id=timetable.direction_id data-route-id=timetable.route_ids.join('_'))
24
+ .timetable(id=cssEscape(`timetable_id_${timetable.timetable_id}`) data-day-list=timetable.dayList data-direction-name=timetable.direction_name || timetable.timetable_label data-timetable-id=timetable.timetable_id data-direction-id=timetable.direction_id data-route-id=timetable.route_ids.join('_'))
25
25
  if config.showRouteTitle
26
26
  .timetable-label
27
27
  h2= `${timetable.timetable_label} | ${timetable.dayListLong}`
@@ -43,19 +43,19 @@ include formatting_functions.pug
43
43
  if hasNotesOrNotices(timetable)
44
44
  .notes
45
45
  if timetable.requestPickupSymbolUsed
46
- .note(id=`note-${timetable.timetable_id}-request-pickup`)= `${config.requestPickupSymbol} = ${config.requestPickupText}`
46
+ .note(id=cssEscape(`note-${timetable.timetable_id}-request-pickup`))= `${config.requestPickupSymbol} = ${config.requestPickupText}`
47
47
  if timetable.noPickupSymbolUsed
48
- .note(id=`note-${timetable.timetable_id}-no-pickup`)= `${config.noPickupSymbol} = ${config.noPickupText}`
48
+ .note(id=cssEscape(`note-${timetable.timetable_id}-no-pickup`))= `${config.noPickupSymbol} = ${config.noPickupText}`
49
49
  if timetable.requestDropoffSymbolUsed
50
- .note(id=`note-${timetable.timetable_id}-request-dropoff`)= `${config.requestDropoffSymbol} = ${config.requestDropoffText}`
50
+ .note(id=cssEscape(`note-${timetable.timetable_id}-request-dropoff`))= `${config.requestDropoffSymbol} = ${config.requestDropoffText}`
51
51
  if timetable.noDropoffSymbolUsed
52
- .note(id=`note-${timetable.timetable_id}-no-dropoff`)= `${config.noDropoffSymbol} = ${config.noDropoffText}`
52
+ .note(id=cssEscape(`note-${timetable.timetable_id}-no-dropoff`))= `${config.noDropoffSymbol} = ${config.noDropoffText}`
53
53
  if timetable.noServiceSymbolUsed
54
- .note(id=`note-${timetable.timetable_id}-no-service`)= `${config.noServiceSymbol} = ${config.noServiceText}`
54
+ .note(id=cssEscape(`note-${timetable.timetable_id}-no-service`))= `${config.noServiceSymbol} = ${config.noServiceText}`
55
55
  if timetable.interpolatedStopSymbolUsed
56
- .note(id=`note-${timetable.timetable_id}-interpolated-stop`)= `${config.interpolatedStopSymbol} = ${config.interpolatedStopText}`
56
+ .note(id=cssEscape(`note-${timetable.timetable_id}-interpolated-stop`))= `${config.interpolatedStopSymbol} = ${config.interpolatedStopText}`
57
57
  each note in _.uniqBy(timetable.notes, 'note_id')
58
- .note(id=`note-${timetable.timetable_id}-${note.note_id}`)
58
+ .note(id=cssEscape(`note-${timetable.timetable_id}-${note.note_id}`))
59
59
  span= note.symbol
60
60
  span &nbsp;=&nbsp;
61
61
  span!= md(note.note)
@@ -3,8 +3,6 @@ block content
3
3
  include timetablepage.pug
4
4
 
5
5
  block extraHeader
6
- script(src="https://unpkg.com/jquery@3.7.1/dist/jquery.min.js" crossorigin="anonymous")
7
-
8
6
  if config.menuType === 'radio'
9
7
  script(src=`${config.assetPath}js/timetable-menu.js`)
10
8
 
@@ -13,8 +11,8 @@ block extraHeader
13
11
  script(src=`${config.assetPath}js/gtfs-realtime.browser.proto.js`)
14
12
 
15
13
  if config.showMap
16
- link(href="https://unpkg.com/maplibre-gl@^5.7.0/dist/maplibre-gl.css" rel="stylesheet")
17
- script(src="https://unpkg.com/maplibre-gl@^5.7.0/dist/maplibre-gl.js")
14
+ link(href=`${config.assetPath}css/maplibre-gl.css` rel="stylesheet")
15
+ script(src=`${config.assetPath}js/maplibre-gl.js`)
18
16
  script(src=`${config.assetPath}js/timetable-map.js`)
19
17
 
20
18
  if config.hasGtfsRealtimeAlerts