Content deleted Content added
Undid revision 1300036746 by Pppery (talk) |
allow named colors to be used |
||
(One intermediate revision by the same user not shown) | |||
Line 7:
-- Helper functions --
local notblank = function (v) return (mw.text.trim(v or "") ~= "") end
local ifblank = function (v,
local ucfirst = function (s) return mw.ustring.upper(mw.ustring.sub(s,1,1)) .. mw.ustring.gsub(mw.ustring.sub(s,2), '_', ' ') end
Line 68:
if always or ( notblank(rargs[cellType .. '1']) or notblank(rargs[cellType .. '2']) or notblank(rargs[cellType .. '3']) ) then
output('|-')
output('! style="width:75px;text-align:left" |' .. (ifblank(rargs[cellType .. '_label'], title, ucfirst(cellType or ''))))
output(centeredCell(cellType .. '1'))
output(centeredCell(cellType .. '2'))
Line 110:
end
if notblank(rargs['color' .. i]) then
if (#color == 3 or #color == 6) and string.match(color, "^[0-9a-fA-F]*$") then
color = '#' .. color
end
image[i] = image[i] .. 'border-bottom: 6px solid ' .. color
elseif rargs.party_color ~= 'no' and notblank(rargs['party' .. i]) then
local color = mw.ustring.gsub(rargs['party' .. i], '^(%[%[%s*[^%]%[]*%]%]).*$', '%1')
Line 116 ⟶ 120:
color = fetch({[1] = color, [2] = 'color', error = 'NOTHERE'})
if color ~= 'NOTHERE' then
image[i] = image[i] .. 'border-bottom: 6px solid ' .. color
end
end
Line 209 ⟶ 213:
end
-- Final round --
threeCells('final_round
-- Primary or presidential --
if rtype == 'primary' or rtype == 'presidential' then
|