transit-departures-widget 2.2.0 → 2.3.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/CHANGELOG.md +16 -0
- package/README.md +17 -17
- package/config-sample.json +3 -1
- package/package.json +5 -4
- package/public/js/transit-departures-widget.js +25 -7
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.3.0] - 2024-04-22
|
|
9
|
+
|
|
10
|
+
## Fixed
|
|
11
|
+
|
|
12
|
+
- Better removing of last stoptime of trip
|
|
13
|
+
|
|
14
|
+
## [2.2.1] - 2024-04-08
|
|
15
|
+
|
|
16
|
+
## Fixed
|
|
17
|
+
|
|
18
|
+
- allow query param in config gtfsRtTripupdatesUrl
|
|
19
|
+
|
|
20
|
+
## Updated
|
|
21
|
+
|
|
22
|
+
- Dependency updates
|
|
23
|
+
|
|
8
24
|
## [2.2.0] - 2024-03-07
|
|
9
25
|
|
|
10
26
|
## Added
|
package/README.md
CHANGED
|
@@ -89,19 +89,19 @@ Copy `config-sample.json` to `config.json` and then add your projects configurat
|
|
|
89
89
|
|
|
90
90
|
cp config-sample.json config.json
|
|
91
91
|
|
|
92
|
-
| option | type | description
|
|
93
|
-
| --------------------------------------------------- | ------- |
|
|
94
|
-
| [`agency`](#agency) | object | Information about the GTFS and GTFS-RT to be used.
|
|
95
|
-
| [`beautify`](#beautify) | boolean | Whether or not to beautify the HTML output.
|
|
96
|
-
| [`
|
|
97
|
-
| [`locale`](#locale) | string | The 2-letter code of the language to use for the interface.
|
|
98
|
-
| [`noHead`](#nohead) | boolean | Whether or not to skip the header and footer of the HTML document.
|
|
99
|
-
| [`refreshIntervalSeconds`](#refreshIntervalSeconds) | integer | How often the widget should refresh departure data in seconds. Optional, defaults to 20 seconds.
|
|
100
|
-
| [`skipImport`](#skipimport) | boolean | Whether or not to skip importing GTFS data into SQLite.
|
|
101
|
-
| [`sqlitePath`](#sqlitepath) | string | A path to an SQLite database. Optional, defaults to using an in-memory database.
|
|
102
|
-
| [`startDate`](#startdate)
|
|
103
|
-
| [`templatePath`](#templatepath) | string | Path to custom pug template for rendering widget.
|
|
104
|
-
| [`timeFormat`](#timeFormat) | string | The format (12hour or 24hour) for the "as of" display.
|
|
92
|
+
| option | type | description |
|
|
93
|
+
| --------------------------------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
94
|
+
| [`agency`](#agency) | object | Information about the GTFS and GTFS-RT to be used. |
|
|
95
|
+
| [`beautify`](#beautify) | boolean | Whether or not to beautify the HTML output. |
|
|
96
|
+
| [`endDate`](#enddate) | string | A date in YYYYMMDD format to use to filter calendar.txt service. Optional, defaults to using all service in specified GTFS. |
|
|
97
|
+
| [`locale`](#locale) | string | The 2-letter code of the language to use for the interface. |
|
|
98
|
+
| [`noHead`](#nohead) | boolean | Whether or not to skip the header and footer of the HTML document. |
|
|
99
|
+
| [`refreshIntervalSeconds`](#refreshIntervalSeconds) | integer | How often the widget should refresh departure data in seconds. Optional, defaults to 20 seconds. |
|
|
100
|
+
| [`skipImport`](#skipimport) | boolean | Whether or not to skip importing GTFS data into SQLite. |
|
|
101
|
+
| [`sqlitePath`](#sqlitepath) | string | A path to an SQLite database. Optional, defaults to using an in-memory database. |
|
|
102
|
+
| [`startDate`](#startdate) | string | A date in YYYYMMDD format to use to filter calendar.txt service. Optional, defaults to using all service in specified GTFS. |
|
|
103
|
+
| [`templatePath`](#templatepath) | string | Path to custom pug template for rendering widget. |
|
|
104
|
+
| [`timeFormat`](#timeFormat) | string | The format (12hour or 24hour) for the "as of" display. |
|
|
105
105
|
|
|
106
106
|
### agency
|
|
107
107
|
|
|
@@ -161,10 +161,10 @@ Copy `config-sample.json` to `config.json` and then add your projects configurat
|
|
|
161
161
|
|
|
162
162
|
### endDate
|
|
163
163
|
|
|
164
|
-
{
|
|
164
|
+
{String} A date in YYYYMMDD format to use to filter service_ids in calendar.txt. Useful in combination with `startDate` configuration option. Optional, if not specified, all services in GTFS will be used.
|
|
165
165
|
|
|
166
166
|
```
|
|
167
|
-
"endDate": 20240401
|
|
167
|
+
"endDate": "20240401"
|
|
168
168
|
```
|
|
169
169
|
|
|
170
170
|
### locale
|
|
@@ -201,10 +201,10 @@ Copy `config-sample.json` to `config.json` and then add your projects configurat
|
|
|
201
201
|
|
|
202
202
|
### startDate
|
|
203
203
|
|
|
204
|
-
{
|
|
204
|
+
{String} A date in YYYYMMDD format to use to filter service_ids in calendar.txt. Useful in combination with `endDate` configuration option. Optional, if not specified, all services in GTFS will be used.
|
|
205
205
|
|
|
206
206
|
```
|
|
207
|
-
"startDate": 20240301
|
|
207
|
+
"startDate": "20240301"
|
|
208
208
|
```
|
|
209
209
|
|
|
210
210
|
### sqlitePath
|
package/config-sample.json
CHANGED
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
"gtfs_rt_tripupdates_url": "https://marintransit.net/gtfs-rt/tripupdates"
|
|
6
6
|
},
|
|
7
7
|
"beautify": true,
|
|
8
|
+
"endDate": "20240331",
|
|
8
9
|
"locale": "en",
|
|
9
10
|
"noHead": false,
|
|
10
11
|
"refreshIntervalSeconds": 20,
|
|
11
12
|
"templatePath": "views/widget",
|
|
12
|
-
"timeFormat": "12hour"
|
|
13
|
+
"timeFormat": "12hour",
|
|
14
|
+
"startDate": "20240301"
|
|
13
15
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "transit-departures-widget",
|
|
3
3
|
"description": "Build a realtime transit departures tool from GTFS and GTFS-Realtime.",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.3.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"transit",
|
|
7
7
|
"gtfs",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"repository": "git://github.com/BlinkTagInc/transit-departures-widget",
|
|
18
18
|
"contributors": [
|
|
19
|
-
"Wojciech Kulesza <wojciech.kulesza@goeuropa.eu>"
|
|
19
|
+
"Wojciech Kulesza <wojciech.kulesza@goeuropa.eu>",
|
|
20
|
+
"eMerzh"
|
|
20
21
|
],
|
|
21
22
|
"license": "MIT",
|
|
22
23
|
"scripts": {
|
|
@@ -30,8 +31,8 @@
|
|
|
30
31
|
"main": "index.js",
|
|
31
32
|
"dependencies": {
|
|
32
33
|
"copy-dir": "^1.3.0",
|
|
33
|
-
"express": "^4.
|
|
34
|
-
"gtfs": "^4.
|
|
34
|
+
"express": "^4.19.2",
|
|
35
|
+
"gtfs": "^4.10.2",
|
|
35
36
|
"i18n": "^0.15.1",
|
|
36
37
|
"js-beautify": "^1.15.1",
|
|
37
38
|
"lodash-es": "^4.17.21",
|
|
@@ -6,6 +6,7 @@ function setupTransitDeparturesWidget(routes, stops, config) {
|
|
|
6
6
|
let departuresTimeout
|
|
7
7
|
let initialStop
|
|
8
8
|
let selectedParameters
|
|
9
|
+
let url = new URL(config.gtfsRtTripupdatesUrl)
|
|
9
10
|
|
|
10
11
|
function updateUrlWithStop(stop) {
|
|
11
12
|
const url = new URL(window.location.origin + window.location.pathname)
|
|
@@ -15,7 +16,7 @@ function setupTransitDeparturesWidget(routes, stops, config) {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
async function fetchTripUpdates() {
|
|
18
|
-
|
|
19
|
+
url.searchParams.append('cacheBust', Date.now())
|
|
19
20
|
const response = await fetch(url)
|
|
20
21
|
if (response.ok) {
|
|
21
22
|
const bufferResponse = await response.arrayBuffer()
|
|
@@ -341,13 +342,30 @@ function setupTransitDeparturesWidget(routes, stops, config) {
|
|
|
341
342
|
}
|
|
342
343
|
|
|
343
344
|
function filterDepartures(departures, { selectedStops, direction, route }) {
|
|
344
|
-
// Remove departure information for last stoptime by stop_sequence if it has any
|
|
345
|
+
// Remove departure and arrival information for last stoptime by stop_sequence if it has any
|
|
345
346
|
const cleanedDepartures = departures.map((departure) => {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
347
|
+
if (departure?.trip_update?.stop_time_update?.length > 0) {
|
|
348
|
+
// Find index of largest stop_sequence
|
|
349
|
+
let largestStopSequence = 0
|
|
350
|
+
let largestStopSequenceIndex = 0
|
|
351
|
+
for (
|
|
352
|
+
let index = 0;
|
|
353
|
+
index < departure.trip_update.stop_time_update.length;
|
|
354
|
+
index++
|
|
355
|
+
) {
|
|
356
|
+
if (
|
|
357
|
+
departure.trip_update.stop_time_update[index].stop_sequence >
|
|
358
|
+
largestStopSequence
|
|
359
|
+
) {
|
|
360
|
+
largestStopSequence =
|
|
361
|
+
departure.trip_update.stop_time_update[index].stop_sequence
|
|
362
|
+
largestStopSequenceIndex = index
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
departure.trip_update.stop_time_update.splice(
|
|
366
|
+
largestStopSequenceIndex,
|
|
367
|
+
1,
|
|
368
|
+
)
|
|
351
369
|
}
|
|
352
370
|
|
|
353
371
|
return departure
|