From 0775a27d1d2e33bc4b537402ce070cdaaf79d7d9 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Fri, 1 Jun 2018 11:12:54 +0200 Subject: [PATCH] WIP parse remarks --- parse/remark.js | 85 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-) diff --git a/parse/remark.js b/parse/remark.js index 0b8c7a52..46ce80ff 100644 --- a/parse/remark.js +++ b/parse/remark.js @@ -1,8 +1,91 @@ 'use strict' +const hints = Object.assign(Object.create(null), { + fb: { + type: 'hint', + code: 'bicycle-con', + text: 'bicycles conveyed' + }, + k2: { + type: 'hint', + code: '2nd-class-only', + text: '2. class only' + }, + eh: { + type: 'hint', + code: 'boarding-ramp', + text: 'vehicle-mounted boarding ramp available' + }, + wv: { + type: 'hint', + code: 'wifi', + text: 'WiFi available' + }, + sn: { + type: 'hint', + code: 'snacks', + text: 'snacks available for purchase' + }, + bf: { + type: 'hint', + code: 'barrier-free', + text: 'barrier-free' + }, + bt: { + type: 'hint', + code: 'on-board-bistro', + text: 'Bordbistro available' + }, + br: { + type: 'hint', + code: 'on-board-restaurant', + text: 'Bordrestaurant available' + }, + ki: { + type: 'hint', + code: 'childrens-area', + text: `children's area available` + }, + ls: { + type: 'hint', + code: 'power-sockets', + text: 'power sockets available' + }, + ev: { + type: 'hint', + code: 'replacement-service', + text: 'replacement service' + }, + kl: { + type: 'hint', + code: 'air-conditioned', + text: 'air-conditioned vehicle' + } +}) + // todo: is passing in profile necessary? const parseRemark = (profile, r) => { - return null // todo + // todo: U "stop cancelled"? + // todo: P "journey cancelled", `r.sIdx`? + // todo: C + if (t.type === 'L') { + return { + type: 'status', + code: 'alternative-trip', + text: r.txtN, + journeyId: r.jid + } + } + if (t.type === 'A') return hints[r.code && r.code.trim()] || null + if (t.type === 'R') { + // todo: how can we identify the individual types? + return { + type: 'status', + code: r.code, + text: r.txtN || '' + } + } + return null } module.exports = parseRemark