mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
parseCommon: resolve icon references
This commit is contained in:
parent
3eae7ab169
commit
0cc17ee780
3 changed files with 8 additions and 8 deletions
|
@ -24,7 +24,10 @@ const parseCommonData = (profile, opt, res) => {
|
|||
}
|
||||
|
||||
res.icons = []
|
||||
if (Array.isArray(c.icoL)) res.icons = c.icoL.map(parseIcon)
|
||||
if (Array.isArray(c.icoL)) {
|
||||
res.icons = c.icoL.map(parseIcon)
|
||||
resolveIdxRefs(res, '**.icoX', res.icons, 'icon')
|
||||
}
|
||||
|
||||
res.lines = []
|
||||
if (Array.isArray(c.prodL)) {
|
||||
|
|
|
@ -12,12 +12,11 @@ const codesByIcon = Object.assign(Object.create(null), {
|
|||
// "tagL": [
|
||||
// "RES_JNY_DTL" // only shown in journey detail
|
||||
// ]
|
||||
const parseHint = (profile, h, data) => {
|
||||
const icons = data.icoL || []
|
||||
const parseHint = (profile, h, _) => {
|
||||
// todo: C
|
||||
|
||||
const text = h.txtN && h.txtN.trim() || ''
|
||||
const icon = 'number' === typeof h.icoX && icons[h.icoX] || null
|
||||
const icon = h.icon || null
|
||||
const code = h.code || (icon && icon.type && codesByIcon[icon.type]) || null
|
||||
|
||||
if (h.type === 'M') {
|
||||
|
|
|
@ -11,8 +11,7 @@ const typesByIcon = Object.assign(Object.create(null), {
|
|||
|
||||
const parseMsgEdge = (profile, data) => (e) => {
|
||||
const res = omit(e, ['icoX', 'fLocX', 'tLocX'])
|
||||
const icons = data.icoL || []
|
||||
res.icon = 'number' === typeof e.icoX && icons[e.icoX] || null
|
||||
res.icon = e.icon || null
|
||||
res.fromLoc = 'number' === typeof e.fLocX && data.locations[e.fLocX] || null
|
||||
res.toLoc = 'number' === typeof e.tLocX && data.locations[e.tLocX] || null
|
||||
return res
|
||||
|
@ -28,7 +27,6 @@ const parseMsgEvent = (profile, data) => (e) => {
|
|||
}
|
||||
|
||||
const parseWarning = (profile, w, data) => {
|
||||
const icons = data.icoL || []
|
||||
// todo: act, pub, lead, tckr, prod, comp,
|
||||
// todo: cat (1, 2), pubChL, rRefL, impactL
|
||||
// pubChL:
|
||||
|
@ -48,7 +46,7 @@ const parseWarning = (profile, w, data) => {
|
|||
// tDate: '20190225',
|
||||
// tTime: '120000' }
|
||||
|
||||
const icon = 'number' === typeof w.icoX && icons[w.icoX] || null
|
||||
const icon = w.icon || null
|
||||
const type = icon && icon.type && typesByIcon[icon.type] || 'warning'
|
||||
|
||||
const res = {
|
||||
|
|
Loading…
Add table
Reference in a new issue