mirror of
				https://github.com/public-transport/db-vendo-client.git
				synced 2025-11-04 01:56:33 +02:00 
			
		
		
		
	parse icons 💥
This commit is contained in:
		
							parent
							
								
									93814983da
								
							
						
					
					
						commit
						793457a7a8
					
				
					 3 changed files with 14 additions and 3 deletions
				
			
		| 
						 | 
					@ -1,5 +1,16 @@
 | 
				
			||||||
'use strict'
 | 
					'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 parseCommonData = (profile, opt, raw) => {
 | 
				
			||||||
	const res = Object.assign({}, raw)
 | 
						const res = Object.assign({}, raw)
 | 
				
			||||||
	const c = raw.common || {}
 | 
						const c = raw.common || {}
 | 
				
			||||||
| 
						 | 
					@ -9,7 +20,7 @@ const parseCommonData = (profile, opt, raw) => {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	res.icons = []
 | 
						res.icons = []
 | 
				
			||||||
	if (Array.isArray(c.icoL)) res.icons = c.icoL
 | 
						if (Array.isArray(c.icoL)) res.icons = c.icoL.map(parseIcon)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	res.hints = []
 | 
						res.hints = []
 | 
				
			||||||
	if (opt.remarks && Array.isArray(c.remL)) {
 | 
						if (opt.remarks && Array.isArray(c.remL)) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +17,7 @@ const parseHint = (profile, h, icons) => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const text = h.txtN && h.txtN.trim() || ''
 | 
						const text = h.txtN && h.txtN.trim() || ''
 | 
				
			||||||
	const icon = 'number' === typeof h.icoX && icons[h.icoX] || null
 | 
						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') {
 | 
						if (h.type === 'M') {
 | 
				
			||||||
		return {
 | 
							return {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,7 +26,7 @@ const parseWarning = (profile, w, icons) => {
 | 
				
			||||||
	// tTime: '030000' } ]
 | 
						// tTime: '030000' } ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const icon = 'number' === typeof w.icoX && icons[w.icoX] || null
 | 
						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 = {
 | 
						const res = {
 | 
				
			||||||
		id: w.hid || null,
 | 
							id: w.hid || null,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue