606
edits
m |
m Tag: Undo |
||
| Line 43: | Line 43: | ||
return box | return box | ||
end | end | ||
if header then | if header then | ||
box:tag('div') | box:tag('div') | ||
| Line 50: | Line 50: | ||
:done() | :done() | ||
end | end | ||
local function createDataRow(label, value, defaultValue) | local function createDataRow(label, value, defaultValue) | ||
if not value and not defaultValue then | |||
return nil | |||
end | end | ||
local dataRow = mw.html.create('div') | |||
dataRow:addClass('infobox-data-section') | |||
if label then | |||
dataRow:tag('span') | |||
:addClass('infobox-label') | |||
:wikitext(label) | |||
:done() | |||
:tag('span') | |||
:addClass('infobox-data') | |||
:wikitext(value or defaultValue) | |||
else | else | ||
dataRow:tag('span') | |||
local | :addClass('infobox-data') | ||
:wikitext(value or defaultValue) | |||
end | |||
return dataRow | |||
end | |||
local rowClass = 'infobox-row' | |||
if columnCount then | |||
rowClass = rowClass .. ' data-rows-' .. columnCount | |||
end | |||
local rowContainer = mw.html.create('div') | |||
rowContainer:addClass(rowClass) | |||
for _, item in ipairs(data) do | |||
local dataRow = createDataRow(item.label, item.value, item.defaultValue) | |||
if dataRow then | |||
rowContainer:node(dataRow) | |||
end | end | ||
end | end | ||
box:node(rowContainer) | |||
return box | return box | ||
end | end | ||
| Line 225: | Line 216: | ||
for resource, amount in pairs(buildingData.construction) do | for resource, amount in pairs(buildingData.construction) do | ||
local resourceIcon = i.icon(resource, amount, nil, com.firstUpper({resource}), 'en') | local resourceIcon = i.icon(resource, amount, nil, com.firstUpper({resource}), 'en') | ||
table.insert(constructionData, { label = resourceIcon | table.insert(constructionData, { label = resourceIcon }) | ||
end | end | ||
edits