parse more hints

This commit is contained in:
Jannis R 2018-06-11 18:41:53 +02:00
parent d3d23140fd
commit 3556130f6b
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5

View file

@ -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