Module

TypeToColor

From Halal Explorer

[view] [edit] [history] [purge] Documentation

This template converts a "type" value to a color, using the supported icon set. It is used in Template:marker and Template:listing.

type css3 color name
see #Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted   
do #Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted   
buy #Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted   
eat #Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted   
drink #Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted   
sleep #Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted   
listing #Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted   
city #Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted   
go #Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted   
other #Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted   
view #Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted   
vicinity #Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted   
around #Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted   
gold #Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted   
lime #Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted   
red #Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted   
silver #Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted   

Examples:

input output comment
#{{#invoke:TypeToColor|convert|sleep}} #Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted type to color
#{{#invoke:TypeToColor|convert|red}} #Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted color to color
#{{#invoke:TypeToColor|convert|wrong}} #Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted wrong to default
#{{#invoke:TypeToColor|convert|}} #Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted no to default

Script error: Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted

local p = {}

function p.convert( frame )
	return p.convertImpl(frame.args[1])
end

function p.convertImpl(type)
	type = type:lower()
	local types = {
		['do'] = '808080',
		around = '800080',
		buy = '008080',
		city = '0000FF',
		drink = '000000',
		eat = 'D2691E',
		go = 'A52A2A',
		listing = '228B22',
		other = '228B22',
		see = '4682B4',
		sleep = '000080',
		vicinity = '800000',
		view = '4169E1',

		launchsite = 'FF8C00',
	}

	local result = types[type]
	if result then
		return result
	end
	
	-- Deprecated usage - trace it
	types = {
		black = '000000',
		blue = '0000FF',
		brown = 'A52A2A',
		chocolate = 'D2691E',
		forestgreen = '228B22',
		gold = 'FFD700',
		gray = '808080',
		grey = '808080',
		lime = 'BFFF00',
		magenta = 'FF00FF',
		maroon = '800000',
		mediumaquamarine = '66CDAA',
		navy = '000080',
		orange = 'FFA500',
		plum = 'DDA0DD',
		purple = '800080',
		red = 'FF0000',
		royalblue = '4169E1',
		silver = 'C0C0C0',
		steelblue = '4682B4',
		teal = '008080',
	}

	local result = types[type]
	if result then
		return result --  .. '[[category:Fixme TypeToColor]]'
	end

	return 'C0C0C0' -- .. '[[category:Fixme TypeToColor Unknown]]'
end

return p