mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
departures/arrivals: add line option
This commit is contained in:
parent
53e10f73b7
commit
e6bc8c6f86
3 changed files with 10 additions and 3 deletions
|
@ -26,6 +26,7 @@ With `opt`, you can override the default options, which look like this:
|
||||||
// todo: products
|
// todo: products
|
||||||
when: new Date(),
|
when: new Date(),
|
||||||
direction: null, // only show departures heading to this station
|
direction: null, // only show departures heading to this station
|
||||||
|
line: null, // filter by line ID
|
||||||
duration: 10, // show departures for the next n minutes
|
duration: 10, // show departures for the next n minutes
|
||||||
results: null, // max. number of results; `null` means "whatever HAFAS wants"
|
results: null, // max. number of results; `null` means "whatever HAFAS wants"
|
||||||
subStops: true, // parse & expose sub-stops of stations?
|
subStops: true, // parse & expose sub-stops of stations?
|
||||||
|
|
|
@ -3,15 +3,20 @@
|
||||||
const formatStationBoardReq = (ctx, station, type) => {
|
const formatStationBoardReq = (ctx, station, type) => {
|
||||||
const {profile, opt} = ctx
|
const {profile, opt} = ctx
|
||||||
|
|
||||||
|
const jnyFltrL = [
|
||||||
|
profile.formatProductsFilter(ctx, opt.products || {})
|
||||||
|
]
|
||||||
|
if (opt.line !== null) {
|
||||||
|
jnyFltrL.push({type: 'LINEID', mode: 'INC', value: opt.line})
|
||||||
|
}
|
||||||
|
|
||||||
const req = {
|
const req = {
|
||||||
type,
|
type,
|
||||||
date: profile.formatDate(profile, opt.when),
|
date: profile.formatDate(profile, opt.when),
|
||||||
time: profile.formatTime(profile, opt.when),
|
time: profile.formatTime(profile, opt.when),
|
||||||
stbLoc: station,
|
stbLoc: station,
|
||||||
dirLoc: opt.direction ? profile.formatStation(opt.direction) : null,
|
dirLoc: opt.direction ? profile.formatStation(opt.direction) : null,
|
||||||
jnyFltrL: [
|
jnyFltrL,
|
||||||
profile.formatProductsFilter(ctx, opt.products || {})
|
|
||||||
],
|
|
||||||
dur: opt.duration
|
dur: opt.duration
|
||||||
}
|
}
|
||||||
if (opt.results !== null) {
|
if (opt.results !== null) {
|
||||||
|
|
1
index.js
1
index.js
|
@ -56,6 +56,7 @@ const createClient = (profile, userAgent, opt = {}) => {
|
||||||
opt = Object.assign({
|
opt = Object.assign({
|
||||||
// todo: for arrivals(), this is actually a station it *has already* stopped by
|
// todo: for arrivals(), this is actually a station it *has already* stopped by
|
||||||
direction: null, // only show departures stopping by this station
|
direction: null, // only show departures stopping by this station
|
||||||
|
line: null, // filter by line ID
|
||||||
duration: 10, // show departures for the next n minutes
|
duration: 10, // show departures for the next n minutes
|
||||||
results: null, // max. number of results; `null` means "whatever HAFAS wants"
|
results: null, // max. number of results; `null` means "whatever HAFAS wants"
|
||||||
subStops: true, // parse & expose sub-stops of stations?
|
subStops: true, // parse & expose sub-stops of stations?
|
||||||
|
|
Loading…
Add table
Reference in a new issue