local p =
local TNTT = require "Module:TNTTools"
local I18n = 'ComplForColorModules'
--local MoreOneNoData = "Found 2 legends of \"Value not assigned\" or \"Data not available\""--local FoundNLegendsExpectedN = "Found $1 legends, expected $2"--local Color = "Color"--local Legend = "legend"
local function I18nStr (S, ...) return TNTT.GetMsgP (I18n, S,)end
function p.ColorNameInvFromS0 (S) local IsInv = false local ColorName = local Params = if S ~= then for w in S:gmatch("([^_]+)") do table.insert(Params, w) end ColorName = Params[1] end local PN = table.getn(Params) if (PN
'i') then IsInv = true end return ColorName, IsInv, Paramsend
function p.ColorNameInv (args) local ColorName, IsInv, Params = p.ColorNameInvFromS0(args[1]) return ColorName, IsInv end
function p.GetLabels(Args, N, Pos) local Labels = local index = Pos while Args[index] do Labels[#Labels+1] = Args[index] index = index + 1 end local NLabels = #Labels local OutlineColor = Args['outline'] or if (NLabels ~= 0) and (NLabels ~= N) then local StartUnknown = (string.sub(Labels[1],1,2)
"--") if StartUnknown and EndUnknown then error (I18nStr ('MoreOneNoData')) elseif StartUnknown or EndUnknown then N = N + 1 end if (NLabels ~= 0) and (NLabels ~= N) then error (I18nStr ('FoundNLegendsExpectedN', tostring(NLabels), tostring(N))) end end return Labels, NLabels, OutlineColorend
function SColor (Color) if string.sub(Color,1,1)
function p.Box(Color,WriteColor) if WriteColor
'a' then WriteColor = Color..'ff' --Alpha channel end local TheBox = '
' if WriteColor ~= then TheBox = TheBox..' '..WriteColor..' ' end return TheBoxendfunction p.TextWithTooltip (Text, Tooltip) if Tooltip ~= then return '
'..Text..'' else return Text end endfunction p.LegendColor(Color, Text, Tooltip) if Text
function LegendCode(Color, Text, OutlineColor) local SOutlineColor = if OutlineColor ~= then SOutlineColor = '|outline='..OutlineColor end return ''end
function p.LegendText (AColors, Labels, NLabels, ColWidth, IsTemplate, OutlineColor) if ColWidth then ColWidth = mw.text.trim(ColWidth) if #ColWidth
'--' then table.insert(AColors, 1, Gray) Labels[1] = string.sub(Labels[1], 3, 1000) elseif string.sub(Labels[NLabels],1,2)
\n' if ColWidth then SCodes = SCodes .. require("Module:Template invocation").invocation("div col",{colwidth=ColWidth}) .. "\n" end SCodes = SCodes .. table.concat(Codes,"\n") if ColWidth and #ColWidth ~= 0 then SCodes = SCodes .. "\n{{div col end}}" end SCodes = SCodes .. "\n" return SShow..'\n'..SCodesend
return p