parse icons 💥

This commit is contained in:
Jannis R 2018-10-27 14:50:45 +02:00
parent 93814983da
commit 793457a7a8
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
3 changed files with 14 additions and 3 deletions

View file

@ -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)) {

View file

@ -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 {

View file

@ -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,