From 35e44d4c92e4e61be6bf6a118ffa1e651bc30058 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Mon, 25 Feb 2019 15:03:33 +0100 Subject: [PATCH] pass all data into parseHint/parseWarning :boom: --- parse/common.js | 18 +++++++++--------- parse/hint.js | 3 ++- parse/warning.js | 6 +++--- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/parse/common.js b/parse/common.js index 8e7f1a08..5be75405 100644 --- a/parse/common.js +++ b/parse/common.js @@ -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 diff --git a/parse/hint.js b/parse/hint.js index 07623984..7f2cac57 100644 --- a/parse/hint.js +++ b/parse/hint.js @@ -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() || '' diff --git a/parse/warning.js b/parse/warning.js index 6fc3994c..f4162052 100644 --- a/parse/warning.js +++ b/parse/warning.js @@ -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',