pass all data into parseHint/parseWarning 💥

This commit is contained in:
Jannis R 2019-02-25 15:03:33 +01:00
parent b8496be1a3
commit 35e44d4c92
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
3 changed files with 14 additions and 13 deletions

View file

@ -22,15 +22,6 @@ const parseCommonData = (profile, opt, raw) => {
res.icons = []
if (Array.isArray(c.icoL)) res.icons = c.icoL.map(parseIcon)
res.hints = []
if (opt.remarks && Array.isArray(c.remL)) {
res.hints = c.remL.map(hint => profile.parseHint(profile, hint, res.icons))
}
res.warnings = []
if (opt.remarks && Array.isArray(c.himL)) {
res.warnings = c.himL.map(w => profile.parseWarning(profile, w, res.icons))
}
if (Array.isArray(c.prodL)) {
const parse = profile.parseLine(profile, opt, res)
res.lines = c.prodL.map(parse)
@ -50,6 +41,15 @@ const parseCommonData = (profile, opt, raw) => {
}
}
res.hints = []
if (opt.remarks && Array.isArray(c.remL)) {
res.hints = c.remL.map(hint => profile.parseHint(profile, hint, {...c, ...res}))
}
res.warnings = []
if (opt.remarks && Array.isArray(c.himL)) {
res.warnings = c.himL.map(w => profile.parseWarning(profile, w, {...c, ...res}))
}
res.polylines = []
if (opt.polylines && Array.isArray(c.polyL)) res.polylines = c.polyL

View file

@ -12,7 +12,8 @@ const codesByIcon = Object.assign(Object.create(null), {
// "tagL": [
// "RES_JNY_DTL" // only shown in journey detail
// ]
const parseHint = (profile, h, icons) => {
const parseHint = (profile, h, data) => {
const icons = data.icoL || []
// todo: C
const text = h.txtN && h.txtN.trim() || ''

View file

@ -9,9 +9,9 @@ const typesByIcon = Object.assign(Object.create(null), {
})
// todo: is passing in profile necessary?
const parseWarning = (profile, w, icons) => {
// todo: pass `d`/`d.common` in, parse `w.fLocX`/`w.tLocX`/`w.icoX`
// todo: hid, act, pub, lead, tckr, comp,
const parseWarning = (profile, w, data) => {
const icons = data.icoL || []
// todo: hid, act, pub, lead, tckr, icoX, fLocX, tLocX, prod, comp,
// todo: cat (1, 2), pubChL
// pubChL:
// [ { name: 'timetable',