Module:Sandbox/ChaoticShadow/InfoboxBuilder: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 17: | Line 17: | ||
name = '', |
name = '', |
||
headerColors = { |
headerColors = { |
||
text = '', |
text = '#000', |
||
bg = '' |
bg = 'transparent' |
||
}, |
}, |
||
params = {}, |
params = {}, |
||
paramnames = {}, |
paramnames = {}, |
||
args = {}, |
args = {}, |
||
infobox = mw.html.create('table'):addClass('infobox') |
infobox = mw.html.create('table'):addClass('infobox'), |
||
finished = false |
|||
}, InfoboxBuilder) |
}, InfoboxBuilder) |
||
Line 234: | Line 235: | ||
--- Adds an image, or switchable images |
--- Adds an image, or switchable images |
||
-- @param ... { { tag, content, title }, ... } |
-- @param ... { { tag, content, title }, ... } |
||
-- tag "artd" or "td" |
-- tag "artd" or "td" Whether or not an it is based off a parameter |
||
-- content string The |
-- content string The content or the parameter name |
||
-- title string or nil The |
-- title string or nil The title, if using switchable images |
||
-- @return self |
-- @return self |
||
-- The current object |
-- The current object |
||
Line 277: | Line 278: | ||
-- @param ... { { tag, content, hide, attr, colspan, rowspan, css }, ... } |
-- @param ... { { tag, content, hide, attr, colspan, rowspan, css }, ... } |
||
-- tag "th", "td", "argth", "argtd" |
-- tag "th", "td", "argth", "argtd" |
||
-- |
-- A string containing one of the above, "th" or |
||
-- "td" uses content as the wikitext, "argth" or |
|||
⚫ | |||
-- "argtd" uses content as the parameter name |
|||
⚫ | |||
-- to produce the suitable content |
|||
⚫ | |||
-- |
-- content string Content to be used as wikitext or a parameter |
||
-- name |
|||
⚫ | |||
⚫ | |||
⚫ | |||
-- css {...} or nil The css of the cell in table form |
|||
-- @return self |
-- @return self |
||
-- The current object |
-- The current object |
||
Line 315: | Line 321: | ||
end |
end |
||
--- Creates the 30-col layout |
|||
function InfoboxBuilder:addSpacer() |
function InfoboxBuilder:addSpacer() |
||
local spacer = self.infobox:tag('tr') |
local spacer = self.infobox:tag('tr') |
||
Line 324: | Line 331: | ||
end |
end |
||
--- Adds links to the bottom of the infobox |
|||
function InfoboxBuilder:addLinks() |
function InfoboxBuilder:addLinks() |
||
if not finished then |
|||
local links = { |
|||
⚫ | |||
"[[Template |
"[[Template:%s|View]]", |
||
⚫ | |||
⚫ | |||
} |
|||
self:addHeader{ |
|||
content = string.format(links[1], self.name) .. |
content = string.format(links[1], self.name) .. |
||
" • " .. |
" • " .. |
||
string.format(links[2], self.name) |
string.format(links[2], self.name) |
||
} |
|||
} |
|||
end |
|||
end |
end |
||
--- Generates the infobox |
|||
-- @return string |
|||
-- The html of the infobox |
|||
function InfoboxBuilder:tostring() |
function InfoboxBuilder:tostring() |
||
if not finished then |
|||
self:addLinks() |
|||
end |
|||
⚫ | |||
return tostring(self.infobox) |
return tostring(self.infobox) |
||
end |
end |