mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
parse more hints
This commit is contained in:
parent
d3d23140fd
commit
3556130f6b
1 changed files with 29 additions and 5 deletions
|
@ -75,23 +75,47 @@ const hints = Object.assign(Object.create(null), {
|
||||||
|
|
||||||
// todo: is passing in profile necessary?
|
// todo: is passing in profile necessary?
|
||||||
const parseHint = (profile, h) => {
|
const parseHint = (profile, h) => {
|
||||||
// todo: U "stop cancelled"?
|
|
||||||
// todo: C
|
// todo: C
|
||||||
|
// todo: D code: '', txtN: 'Fire services operating close to the tracks'
|
||||||
|
|
||||||
|
const text = h.txtN && h.txtN.trim() || ''
|
||||||
|
|
||||||
// todo: find sth more reliable than this
|
// todo: find sth more reliable than this
|
||||||
if (h.type === 'P' && h.txtN.toLowerCase().trim() === 'journey cancelled') {
|
if (h.type === 'P' && text.toLowerCase() === 'journey cancelled') {
|
||||||
return {
|
return {
|
||||||
type: 'status',
|
type: 'status',
|
||||||
code: 'journey-cancelled',
|
code: 'journey-cancelled',
|
||||||
text: h.txtN
|
text
|
||||||
// todo: `h.sIdx`
|
// todo: `h.sIdx`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (h.type === 'U' && text.toLowerCase() === 'stop cancelled') {
|
||||||
|
return {
|
||||||
|
type: 'status',
|
||||||
|
code: 'stop-cancelled',
|
||||||
|
text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// todo:
|
||||||
|
// {
|
||||||
|
// "type": "U",
|
||||||
|
// "code": "",
|
||||||
|
// "icoX": 3,
|
||||||
|
// "txtN": "entrance and exit not possible"
|
||||||
|
// }
|
||||||
|
if (h.type === 'U') {
|
||||||
|
return {
|
||||||
|
type: 'status',
|
||||||
|
code: null, // todo
|
||||||
|
text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (h.type === 'L') {
|
if (h.type === 'L') {
|
||||||
return {
|
return {
|
||||||
type: 'status',
|
type: 'status',
|
||||||
code: 'alternative-trip',
|
code: 'alternative-trip',
|
||||||
text: h.txtN,
|
text,
|
||||||
journeyId: h.jid
|
journeyId: h.jid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +127,7 @@ const parseHint = (profile, h) => {
|
||||||
return {
|
return {
|
||||||
type: 'status',
|
type: 'status',
|
||||||
code: h.code,
|
code: h.code,
|
||||||
text: h.txtN || ''
|
text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
|
|
Loading…
Add table
Reference in a new issue