From 793457a7a84fbadaca179c1e36c07ff91bcedfd2 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Sat, 27 Oct 2018 14:50:45 +0200 Subject: [PATCH] parse icons :boom: --- parse/common.js | 13 ++++++++++++- parse/hint.js | 2 +- parse/warning.js | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/parse/common.js b/parse/common.js index b1381e26..8e7f1a08 100644 --- a/parse/common.js +++ b/parse/common.js @@ -1,5 +1,16 @@ 'use strict' +// todo: move to separate file +const parseIcon = (i) => { + const res = { + type: i.res || null, + title: i.text || null + } + if (i.fg) res.fgColor = i.fg + if (i.bg) res.bgColor = i.bg + return res +} + const parseCommonData = (profile, opt, raw) => { const res = Object.assign({}, raw) const c = raw.common || {} @@ -9,7 +20,7 @@ const parseCommonData = (profile, opt, raw) => { } res.icons = [] - if (Array.isArray(c.icoL)) res.icons = c.icoL + if (Array.isArray(c.icoL)) res.icons = c.icoL.map(parseIcon) res.hints = [] if (opt.remarks && Array.isArray(c.remL)) { diff --git a/parse/hint.js b/parse/hint.js index 04fb5905..dadd2b50 100644 --- a/parse/hint.js +++ b/parse/hint.js @@ -17,7 +17,7 @@ const parseHint = (profile, h, icons) => { const text = h.txtN && h.txtN.trim() || '' const icon = 'number' === typeof h.icoX && icons[h.icoX] || null - const code = h.code || (icon && icon.res && codesByIcon[icon.res]) || null + const code = h.code || (icon && icon.type && codesByIcon[icon.type]) || null if (h.type === 'M') { return { diff --git a/parse/warning.js b/parse/warning.js index 27ac9713..6fc3994c 100644 --- a/parse/warning.js +++ b/parse/warning.js @@ -26,7 +26,7 @@ const parseWarning = (profile, w, icons) => { // tTime: '030000' } ] const icon = 'number' === typeof w.icoX && icons[w.icoX] || null - const type = icon && icon.res && typesByIcon[icon.res] || 'warning' + const type = icon && icon.type && typesByIcon[icon.type] || 'warning' const res = { id: w.hid || null,