Module:Sandbox/ChaoticShadow/InfoboxBuilder: Difference between revisions
no edit summary
No edit summary |
No edit summary |
||
Line 20:
bg = 'transparent'
},
params = {
{ name = 'text color' }
},
paramnames = { 'bg color', 'text color' },
args = {},
final_args = {},
Line 131 ⟶ 134:
end
local
local colors = color_table[
if colors == nil then
Line 145 ⟶ 148:
--- Sets the infobox params
-- @param ... {{ name, func, default, should_hide }, ...}
-- name string
-- The name of the parameter, not nil, cannot be duplicate
Line 163 ⟶ 166:
end
if self.paramnames[v.name] then
error("name cannot be
end
Line 184 ⟶ 187:
function InfoboxBuilder:setArgs(args)
for k,v in pairs(args) do
if v ~= '' then
self.args[k] = v
end
end
if self.args['bg color'] then
self:setHeaderBackgroundColor(self.args['bg color'])
end
if self.args['text color'] then
self:setHeaderTextColor(self.args['text color'])
end
Line 200 ⟶ 212:
end
if self.final_args[param] then
local content = '?'▼
end
local current_param = self.params[param]
if
error(string.format("No such param: %s", param))
end
local
if
return
end
if
content =
elseif
content =
else
content =
end
Line 301 ⟶ 317:
local t = {}
for _,v in ipairs(actual_args) do
table.insert(t, v.title ..
end
content = mw.getCurrentFrame():callParserFunction({
name = '#tag',
args = { 'tabber', table.concat(t,
})
end
Line 331 ⟶ 347:
-- @return self
-- The current object
function InfoboxBuilder:addRow(should_hide, ...)
local _row = self.infobox:tag('tr')▼
local argt = ...
local actual_values = {}
for i, v in ipairs(argt) do▼
if v.tag == 'argth' or v.tag == 'argtd' then
table.insert(actual_values, self:getContent(v.content))
end
end
-- if should_hide and #actual_values > 0 then
-- return self
-- end
▲ local _row = self.infobox:tag('tr')
for i,v in ipairs(argt) do
local _cell = _row:tag(tagmap[v.tag] or 'td')
:attr('colspan', 30 / #argt)
|