Модуль:Infobox
Перейти к навигации
Перейти к поиску
Для документации этого модуля может быть создана страница Модуль:Infobox/doc
local p = {}
function p.main(frame)
local args = frame:getParent().args
local wrapper = mw.html.create('div')
:css({
float = 'right',
clear = 'right',
margin = '0 0 1em 1em',
['max-width'] = '320px',
['font-size'] = '88%',
['line-height'] = '1.5em'
})
local tableEl = wrapper:tag('table')
:css({
width = '100%',
border = '1px solid #a2a9b1',
['border-collapse'] = 'collapse',
background = '#f8f9fa',
['font-size'] = '100%'
})
-- Заголовок
if args["имя"] and args["имя"] ~= "" then
tableEl:tag('tr')
:tag('th')
:attr('colspan', '2')
:css({
background = '#cee0f2',
['border-bottom'] = '1px solid #a2a9b1',
['font-size'] = '1.1em',
['text-align'] = 'center',
padding = '5px'
})
:wikitext(args["имя"])
end
-- Картинка
if args["файл"] and args["файл"] ~= "" then
tableEl:tag('tr')
:tag('td')
:attr('colspan', '2')
:css({
['text-align'] = 'center',
padding = '5px',
['border-bottom'] = '1px solid #a2a9b1'
})
:wikitext('[[Файл:' .. args["файл"] .. '|250x250px|center]]')
end
-- Описание
if args["описание"] and args["описание"] ~= "" then
tableEl:tag('tr')
:tag('td')
:attr('colspan', '2')
:css({
['text-align'] = 'center',
['font-size'] = '0.9em',
color = '#555',
padding = '3px 5px',
['border-bottom'] = '1px solid #a2a9b1'
})
:wikitext(args["описание"])
end
-- Параметры (1–40)
for i = 1, 40, 2 do
local key = args[tostring(i)]
local val = args[tostring(i + 1)]
if key and key ~= "" then
local row = tableEl:tag('tr')
if val and val ~= "" then
row:tag('th')
:css({
['text-align'] = 'right',
['font-weight'] = 'bold',
['vertical-align'] = 'top',
padding = '3px 5px',
['border-top'] = '1px solid #eaecf0',
width = '45%',
background = '#f8f9fa'
})
:wikitext(key)
row:tag('td')
:css({
['text-align'] = 'left',
['vertical-align'] = 'top',
padding = '3px 5px',
['border-top'] = '1px solid #eaecf0'
})
:wikitext(val)
else
row:tag('td')
:attr('colspan', '2')
:css({
['text-align'] = 'center',
['font-weight'] = 'bold',
padding = '4px 5px',
['border-top'] = '1px solid #a2a9b1',
background = '#dce5f4'
})
:wikitext(key)
end
end
end
return tostring(wrapper)
end
return p