More actions
No edit summary Tag: Reverted |
No edit summary Tag: Manual revert |
||
(19 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
--- Simple infobox module | --- Simple infobox module | ||
local p = {} | local p = {} | ||
--- Main function | --- Main function | ||
function p.infobox( frame ) | function p.infobox( frame ) | ||
Line 12: | Line 12: | ||
local infobox = mw.html.create('table'):addClass('infobox') | local infobox = mw.html.create('table'):addClass('infobox') | ||
--top infobox ads | |||
local div = mw.html.create('div') | |||
div:attr('id', 'Ads-InfoboxTop') | |||
infobox:node(div) | |||
-- Title | |||
local title = args.title | |||
if not title or title == '' then title = mw.title.getCurrentTitle().text end | |||
infobox:tag('tr'):tag('th'):addClass('infobox-title'):attr('scope','col'):attr('colspan',2):wikitext(title) | |||
-- Image | -- Image | ||
local image = args.image | local image = args.image | ||
Line 20: | Line 30: | ||
image = 'File:' .. image | image = 'File:' .. image | ||
end | end | ||
image = '[[' .. image .. '|' .. (' | image = '[[' .. image .. '|' .. ('300px') .. ']]' | ||
end | end | ||
local imgcell = infobox:tag('tr'):tag('td'):addClass('infobox-image') | local imgcell = infobox:tag('tr'):tag('td'):addClass('infobox-image') | ||
Line 29: | Line 39: | ||
end | end | ||
end | end | ||
-- Description | -- Description | ||
local description = args.description | local description = args.description |
Latest revision as of 12:51, 27 Mayıs 2023
Documentation for this module may be created at Module:Infobox/doc
--- Simple infobox module local p = {} --- Main function function p.infobox( frame ) local args if frame == mw.getCurrentFrame() then args = frame:getParent().args else args = frame end local infobox = mw.html.create('table'):addClass('infobox') --top infobox ads local div = mw.html.create('div') div:attr('id', 'Ads-InfoboxTop') infobox:node(div) -- Title local title = args.title if not title or title == '' then title = mw.title.getCurrentTitle().text end infobox:tag('tr'):tag('th'):addClass('infobox-title'):attr('scope','col'):attr('colspan',2):wikitext(title) -- Image local image = args.image if image and image ~= '' then if image:sub(1,2) ~= '[[' then if not image:find(':') then image = 'File:' .. image end image = '[[' .. image .. '|' .. ('300px') .. ']]' end local imgcell = infobox:tag('tr'):tag('td'):addClass('infobox-image') :attr('colspan',2):wikitext(image) local caption = args.imagecaption if caption and caption ~= '' then imgcell:wikitext("<br />''" .. caption .. "''") end end -- Description local description = args.description if not description or description == '' then description = mw.title.getCurrentTitle().text end -- Rows for i = 1, 30 do local header = args['header' .. i]; if header == '' then header = nil end local label = args['label' .. i]; if label == '' then label = nil end local data = args['data' .. i]; if data == '' then data = nil end if header then infobox:tag('tr') :tag('th'):addClass('infobox-header'):attr('scope','col'):attr('colspan',2):wikitext(header) end if data then if label then infobox:tag('tr') :tag('th'):attr('scope','row'):addClass('infobox-label'):wikitext(label):done() :tag('td'):addClass('infobox-data'):wikitext(data) else infobox:tag('tr') :tag('td'):addClass('infobox-data'):attr('colspan',2) :css('text-align','center'):wikitext(data) end end end -- Below local below = args.below if below and below ~= '' then infobox:tag('tr'):tag('td'):addClass('infobox-below'):attr('colspan',2):wikitext(below) end return infobox end return p