Difference between revisions of "Module:ConvCSS"

From "PTTLink Wiki"
Jump to navigation Jump to search
Mediawiki>Sarang
m (+color)
 
m (1 revision imported)
 

Latest revision as of 07:59, 24 January 2022

Documentation for this module may be created at Module:ConvCSS/doc

--

-- This function converts a CSS color name to its hexadecimal color code
--

local p = {}

function p.main ( frame )
	local args = frame.args
	local inp = ''
	if  args then
        inp   =  args[1] or 'global'
	elseif  frame then
         inp  =  frame or 'local'
	end	
	local out  =  '';
	if  mw.ustring.sub ( inp, 1, 1 ) == '#' then
		return inp
	end
	local  css  =  ( string.lower ( inp ) );
	if     css == 'aliceblue'		then out = '#f0f8ff'
	elseif css == 'antiquewhite'	then out = '#faebd7'
	elseif css == 'aqua'			then out = '#0ff'
	elseif css == 'aquamarine'		then out = '#7fffd4'
	elseif css == 'azure'			then out = '#f0ffff'
	elseif css == 'azure_css'		then out = '#f0ffff'
	elseif css == 'beige'			then out = '#f5f5dc'
	elseif css == 'bisque'			then out = '#ffe4c4'
	elseif css == 'black'			then out = '#000'
	elseif css == 'blanchedalmond'	then out = '#ffebcd'
	elseif css == 'blue'			then out = '#00f'
	elseif css == 'blueviolet'		then out = '#8a2be2'
	elseif css == 'brown'			then out = '#a52a2a'
	elseif css == 'burlywood'		then out = '#deb887'
	elseif css == 'cadetblue'		then out = '#5f9ea0'
	elseif css == 'chartreuse'		then out = '#7fff00'
	elseif css == 'chocolate'		then out = '#d2691e'
	elseif css == 'coral'			then out = '#ff7f50'
	elseif css == 'cornflowerblue'	then out = '#6495ed'
	elseif css == 'cornsilk'		then out = '#fff8dc'
	elseif css == 'crimson'			then out = '#dc143c'
	elseif css == 'cyan'			then out = '#00ffff'
	elseif css == 'darkblue'		then out = '#00008b'
	elseif css == 'darkcyan'		then out = '#008b8b'
	elseif css == 'darkgoldenrod'	then out = '#b8860b'
	elseif css == 'darkgray'		then out = '#a9a9a9'
	elseif css == 'darkgreen'		then out = '#006400'
	elseif css == 'darkgrey'		then out = '#a9a9a9'
	elseif css == 'darkkhaki'		then out = '#bdb76b'
	elseif css == 'darkmagenta'		then out = '#8b008b'
	elseif css == 'darkolivegreen'	then out = '#556b2f'
	elseif css == 'darkorange'		then out = '#ff8c00'
	elseif css == 'darkorchid'		then out = '#9932cc'
	elseif css == 'darkred'			then out = '#8b0000'
	elseif css == 'darksalmon'		then out = '#e9967a'
	elseif css == 'darkseagreen'	then out = '#8fbc8f'
	elseif css == 'darkslateblue'	then out = '#483d8b'
	elseif css == 'darkslategray'	then out = '#2f4f4f'
	elseif css == 'darkslategrey'	then out = '#2f4f4f'
	elseif css == 'darkturquoise'	then out = '#00ced1'
	elseif css == 'darkviolet'		then out = '#9400d3'
	elseif css == 'deeppink'		then out = '#ff1493'
	elseif css == 'deepskyblue'		then out = '#00bfff'
	elseif css == 'dimgray'			then out = '#696969'
	elseif css == 'dimgrey'			then out = '#696969'
	elseif css == 'dodgerblue'		then out = '#1e90ff'
	elseif css == 'firebrick'		then out = '#b22222'
	elseif css == 'floralwhite'		then out = '#fffaf0'
	elseif css == 'forestgreen'		then out = '#228b22'
	elseif css == 'fuchsia'			then out = '#f0f'
	elseif css == 'gainsboro'		then out = '#dcdcdc'
	elseif css == 'ghostwhite'		then out = '#f8f8ff'
	elseif css == 'gold'			then out = '#ffd700'
	elseif css == 'goldenrod'		then out = '#daa520'
	elseif css == 'gray'			then out = '#808080'
	elseif css == 'green'			then out = '#008000'
	elseif css == 'greenyellow'		then out = '#adff2f'
	elseif css == 'grey'			then out = '#808080'
	elseif css == 'honeydew'		then out = '#f0fff0'
	elseif css == 'hotpink'			then out = '#ff69b4'
	elseif css == 'indianred'		then out = '#cd5c5c'
	elseif css == 'indigo'			then out = '#4b0082'
	elseif css == 'invisible'		then out = 'none'
	elseif css == 'ivory'			then out = '#fffff0'
	elseif css == 'khaki'			then out = '#f0e68c'
	elseif css == 'lavender'		then out = '#e6e6fa'
	elseif css == 'lavenderblush'	then out = '#fff0f5'
	elseif css == 'lawngreen'		then out = '#7cfc00'
	elseif css == 'lemonchiffon'	then out = '#fffacd'
	elseif css == 'lightblue'		then out = '#add8e6'
	elseif css == 'lightcoral'		then out = '#f08080'
	elseif css == 'lightcyan'		then out = '#e0ffff'
	elseif css == 'lightgoldenrodyellow' then out = '#fafad2'
	elseif css == 'lightgray'		then out = '#d3d3d3'
	elseif css == 'lightgreen'		then out = '#90ee90'
	elseif css == 'lightgrey'		then out = '#d3d3d3'
	elseif css == 'lightpink'		then out = '#ffb6c1'
	elseif css == 'lightsalmon'		then out = '#ffa07a'
	elseif css == 'lightseagreen'	then out = '#20b2aa'
	elseif css == 'lightskyblue'	then out = '#87cefa'
	elseif css == 'lightslategray'	then out = '#789'
	elseif css == 'lightslategrey'	then out = '#789'
	elseif css == 'lightsteelblue'	then out = '#b0c4de'
	elseif css == 'lightyellow'		then out = '#ffffe0'
	elseif css == 'lime'			then out = '#0f0'
	elseif css == 'limegreen'		then out = '#32cd32'
	elseif css == 'linen'			then out = '#faf0e6'
	elseif css == 'magenta'			then out = '#f0f'
	elseif css == 'maroon'			then out = '#800000'
	elseif css == 'mediumaquamarine' then out = '#66cdaa'
	elseif css == 'mediumblue'		then out = '#0000cd'
	elseif css == 'mediumorchid'	then out = '#ba55d3'
	elseif css == 'mediumpurple'	then out = '#9370db'
	elseif css == 'mediumseagreen'	then out = '#3cb371'
	elseif css == 'mediumslateblue'	then out = '#7b68ee'
	elseif css == 'mediumspringgreen' then out = '#00fa9a'
	elseif css == 'mediumturquoise'	then out = '#48d1cc'
	elseif css == 'mediumvioletred'	then out = '#c71585'
	elseif css == 'midnightblue'	then out = '#191970'
	elseif css == 'mintcream'		then out = '#f5fffa'
	elseif css == 'mistyrose'		then out = '#ffe4e1'
	elseif css == 'moccasin'		then out = '#ffe4b5'
	elseif css == 'navajowhite'		then out = '#ffdead'
	elseif css == 'navy'			then out = '#000080'
	elseif css == 'oldlace'			then out = '#fdf5e6'
	elseif css == 'olive'			then out = '#808000'
	elseif css == 'olivedrab'		then out = '#6b8e23'
	elseif css == 'orange'			then out = '#ffa500'
	elseif css == 'orangered'		then out = '#ff4500'
	elseif css == 'orchid'			then out = '#da70d6'
	elseif css == 'palegoldenrod'	then out = '#eee8aa'
	elseif css == 'palegreen'		then out = '#98fb98'
	elseif css == 'paleturquoise'	then out = '#afeeee'
	elseif css == 'palevioletred'	then out = '#db7093'
	elseif css == 'papayawhip'		then out = '#ffefd5'
	elseif css == 'peachpuff'		then out = '#ffdab9'
	elseif css == 'peru'			then out = '#cd853f'
	elseif css == 'pink'			then out = '#ffc0cb'
	elseif css == 'plum'			then out = '#dda0dd'
	elseif css == 'powderblue'		then out = '#b0e0e6'
	elseif css == 'purple'			then out = '#800080'
	elseif css == 'rebeccapurple'	then out = '#639'
	elseif css == 'red'				then out = '#f00'
	elseif css == 'rosybrown'		then out = '#bc8f8f'
	elseif css == 'royalblue'		then out = '#4169e1'
	elseif css == 'saddlebrown'		then out = '#8b4513'
	elseif css == 'salmon'			then out = '#fa8072'
	elseif css == 'sandybrown'		then out = '#f4a460'
	elseif css == 'seagreen'		then out = '#2e8b57'
	elseif css == 'seashell'		then out = '#fff5ee'
	elseif css == 'sienna'			then out = '#a0522d'
	elseif css == 'silver'			then out = '#c0c0c0'
	elseif css == 'skyblue'			then out = '#87ceeb'
	elseif css == 'slateblue'		then out = '#6a5acd'
	elseif css == 'slategray'		then out = '#708090'
	elseif css == 'slategrey'		then out = '#708090'
	elseif css == 'snow'			then out = '#fffafa'
	elseif css == 'springgreen'		then out = '#00ff7f'
	elseif css == 'steelblue'		then out = '#4682b4'
	elseif css == 'tan'				then out = '#d2b48c'
	elseif css == 'teal'			then out = '#008080'
	elseif css == 'thistle'			then out = '#d8bfd8'
	elseif css == 'tomato'			then out = '#ff6347'
	elseif css == 'transparent'		then out = 'none'
	elseif css == 'turquoise'		then out = '#40e0d0'
	elseif css == 'violet'			then out = '#ee82ee'
	elseif css == 'wheat'			then out = '#f5deb3'
	elseif css == 'white'			then out = '#fff'
	elseif css == 'whitesmoke'		then out = '#f5f5f5'
	elseif css == 'yellow'			then out = '#ff0'
	elseif css == 'yellowgreen'		then out = '#9acd32'
--  + wikimedia colors: blue, green, red, white		
	elseif css == 'wmb'				then out = '#069'
	elseif css == 'wmg'				then out = '#396'
	elseif css == 'wmr'				then out = '#900'
	elseif css == 'wmw'				then out = '#FFF'
--  + wikimedia grey (different shades)		
	elseif css == 'wm0'				then out = '#000'
	elseif css == 'wm3'				then out = '#333'
	elseif css == 'wm6'				then out = '#666'
	elseif css == 'wm9'				then out = '#999'
	elseif css == 'wmc'				then out = '#CCC'
	elseif css == 'wmf'				then out = '#FFF'
	else   return inp
	end
	return ( string.upper ( out ) )
end
	
return p;