Module:Infobox iceberg: Difference between revisions
Jump to navigation
Jump to search
Chaymeleon (talk | contribs) Created page with "local p = {} local function addRow(tbl, label, value) if value and value ~= '' then local row = tbl:tag('tr') row:tag('th') :css('background', '#1d4f66') :css('color', '#fff') :css('text-align', 'left') :css('padding', '3px') :wikitext(label) row:tag('td') :css('background', '#fff') :css('padding', '3px') :wikitext(value) end end function p...." |
Chaymeleon (talk | contribs) No edit summary |
||
| Line 1: | Line 1: | ||
local p = {} | 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) | local function addRow(tbl, label, value) | ||
if value and value ~= '' then | if value and value ~= '' then | ||
local row = tbl:tag('tr') | local row = tbl:tag('tr') | ||
row:tag('th') | row:tag('th') | ||
:css('background', | :css('background', COLOR_LABEL_BG) | ||
:css('color', | :css('color', COLOR_LABEL_TEXT) | ||
:css('text-align', 'left') | :css('text-align', 'left') | ||
:css('padding', '3px') | :css('padding', '3px 6px') | ||
:css('width', '35%') | |||
:wikitext(label) | :wikitext(label) | ||
row:tag('td') | row:tag('td') | ||
:css('padding', '3px 6px') | |||
:css('padding', '3px') | |||
:wikitext(value) | :wikitext(value) | ||
end | end | ||
end | end | ||
function p.main(frame) | function p.main(frame) | ||
local args = frame:getParent() and frame:getParent().args or frame.args | local args = frame:getParent() and frame:getParent().args or frame.args | ||
local name | local name = args.name | ||
if not name or name == '' then | if not name or name == '' then | ||
name = mw.title.getCurrentTitle().text | name = mw.title.getCurrentTitle().text | ||
end | end | ||
local image | local image = args.image | ||
local imgwidth | local imgwidth = args.imgwidth | ||
if not imgwidth or imgwidth == '' then | if not imgwidth or imgwidth == '' then | ||
imgwidth = '250px' | imgwidth = '250px' | ||
| Line 39: | Line 46: | ||
local summary = args.summary | local summary = args.summary | ||
local category = args.category | local category = args.category | ||
local root = mw.html.create('table') | local root = mw.html.create('table') | ||
:addClass('infobox iceberg-infobox') | :addClass('infobox iceberg-infobox') | ||
:css('width', '300px') | :css('width', '300px') | ||
:css('border', '1px solid | :css('max-width', '100%') | ||
:css(' | :css('border', '1px solid ' .. COLOR_BORDER) | ||
:css('border-radius', '2px') | |||
:css('font-size', '90%') | :css('font-size', '90%') | ||
:css('line-height', '1.4em') | :css('line-height', '1.4em') | ||
:css('float', 'right') | |||
:css('clear', 'right') | |||
:css('margin', '0 0 1em 1em') | |||
root:tag('tr'):tag('th') | root:tag('tr'):tag('th') | ||
:attr('colspan', '2') | :attr('colspan', '2') | ||
:css('background', | :css('background', COLOR_HEADER_BG) | ||
:css('color', | :css('color', COLOR_HEADER_TEXT) | ||
:css('text-align', 'center') | :css('text-align', 'center') | ||
:css('font-size', '120%') | :css('font-size', '120%') | ||
:css('padding', '6px') | :css('padding', '6px') | ||
:wikitext(name) | :wikitext(name) | ||
if image and image ~= '' then | if image and image ~= '' then | ||
local imgWikitext = string.format('[[File:%s|%s|alt=%s]]', image, imgwidth, name) | local imgWikitext = string.format('[[File:%s|%s|alt=%s]]', image, imgwidth, name) | ||
| Line 63: | Line 74: | ||
:css('text-align', 'center') | :css('text-align', 'center') | ||
:css('padding', '4px') | :css('padding', '4px') | ||
:wikitext(imgWikitext) | :wikitext(imgWikitext) | ||
end | end | ||
if caption and caption ~= '' then | if caption and caption ~= '' then | ||
root:tag('tr'):tag('td') | root:tag('tr'):tag('td') | ||
| Line 73: | Line 83: | ||
:css('font-size', '85%') | :css('font-size', '85%') | ||
:css('font-style', 'italic') | :css('font-style', 'italic') | ||
:css('padding', '2px | :css('padding', '2px 6px') | ||
:css(' | :css('opacity', '0.8') | ||
:wikitext(caption) | :wikitext(caption) | ||
end | end | ||
addRow(root, 'Iceberg', iceberg) | addRow(root, 'Iceberg', iceberg) | ||
addRow(root, 'Level', level) | addRow(root, 'Level', level) | ||
| Line 85: | Line 95: | ||
addRow(root, 'Source', source) | addRow(root, 'Source', source) | ||
addRow(root, 'Related', related) | addRow(root, 'Related', related) | ||
if summary and summary ~= '' then | if summary and summary ~= '' then | ||
root:tag('tr'):tag('td') | root:tag('tr'):tag('td') | ||
:attr('colspan', '2') | :attr('colspan', '2') | ||
:css(' | :css('border-left', '3px solid ' .. COLOR_ACCENT) | ||
:css('font-size', '85%') | :css('font-size', '85%') | ||
:css('padding', '5px') | :css('font-style', 'italic') | ||
:css('padding', '5px 6px') | |||
:wikitext(summary) | :wikitext(summary) | ||
end | end | ||
local out = tostring(root) | local out = tostring(root) | ||
if category and category ~= '' then | if category and category ~= '' then | ||
| Line 101: | Line 112: | ||
return out | return out | ||
end | end | ||
return p | return p | ||
Latest revision as of 13:33, 19 June 2026
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