Module:Infobox iceberg
Documentation for this module may be created at Module:Infobox iceberg/doc
local p = {}
local COLOR_BORDER = '#3d6e85'
local COLOR_HEADER_BG = '#102a38'
local COLOR_HEADER_TEXT = '#ffffff'
local COLOR_LABEL_BG = '#1d4f66'
local COLOR_LABEL_TEXT = '#ffffff'
local COLOR_ACCENT = '#1d4f66'
local function addRow(tbl, label, value)
if value and value ~= '' then
local row = tbl:tag('tr')
row:tag('th')
:css('background', COLOR_LABEL_BG)
:css('color', COLOR_LABEL_TEXT)
:css('text-align', 'left')
:css('padding', '3px 6px')
:css('width', '35%')
:wikitext(label)
row:tag('td')
:css('padding', '3px 6px')
:wikitext(value)
end
end
function p.main(frame)
local args = frame:getParent() and frame:getParent().args or frame.args
local name = args.name
if not name or name == '' then
name = mw.title.getCurrentTitle().text
end
local image = args.image
local imgwidth = args.imgwidth
if not imgwidth or imgwidth == '' then
imgwidth = '250px'
end
local caption = args.caption
local iceberg = args.iceberg
local level = args.level
local itype = args.type
local timeframe = args.timeframe
local status = args.status
local source = args.source
local related = args.related
local summary = args.summary
local category = args.category
local root = mw.html.create('table')
:addClass('infobox iceberg-infobox')
:css('width', '300px')
:css('max-width', '100%')
:css('border', '1px solid ' .. COLOR_BORDER)
:css('border-radius', '2px')
:css('font-size', '90%')
:css('line-height', '1.4em')
:css('float', 'right')
:css('clear', 'right')
:css('margin', '0 0 1em 1em')
root:tag('tr'):tag('th')
:attr('colspan', '2')
:css('background', COLOR_HEADER_BG)
:css('color', COLOR_HEADER_TEXT)
:css('text-align', 'center')
:css('font-size', '120%')
:css('padding', '6px')
:wikitext(name)
if image and image ~= '' then
local imgWikitext = string.format('[[File:%s|%s|alt=%s]]', image, imgwidth, name)
root:tag('tr'):tag('td')
:attr('colspan', '2')
:css('text-align', 'center')
:css('padding', '4px')
:wikitext(imgWikitext)
end
if caption and caption ~= '' then
root:tag('tr'):tag('td')
:attr('colspan', '2')
:css('text-align', 'center')
:css('font-size', '85%')
:css('font-style', 'italic')
:css('padding', '2px 6px')
:css('opacity', '0.8')
:wikitext(caption)
end
addRow(root, 'Iceberg', iceberg)
addRow(root, 'Level', level)
addRow(root, 'Type', itype)
addRow(root, 'Timeframe', timeframe)
addRow(root, 'Status', status)
addRow(root, 'Source', source)
addRow(root, 'Related', related)
if summary and summary ~= '' then
root:tag('tr'):tag('td')
:attr('colspan', '2')
:css('border-left', '3px solid ' .. COLOR_ACCENT)
:css('font-size', '85%')
:css('font-style', 'italic')
:css('padding', '5px 6px')
:wikitext(summary)
end
local out = tostring(root)
if category and category ~= '' then
out = out .. string.format('[[Category:%s]]', category)
end
return out
end
return p