Module:Infobox: Difference between revisions
m bugfix |
refactor |
||
| Line 60: | Line 60: | ||
local row = "" | local row = "" | ||
if #row_content > 1 then | if #row_content > 1 then | ||
local | local lines = {} | ||
table.insert(lines, '|-') | |||
table.insert(lines, '| style="text-align: right; padding-right: 0.25em;" | ' .. row_content[1]) | |||
table.insert(lines, '| style="background-color: white; padding-left: 0.25em; font-weight: bold;" | ' .. row_content[2]) | |||
row = table.concat(lines, "\n") | |||
elseif #row_content == 1 then | elseif #row_content == 1 then | ||
local | local lines = {} | ||
table.insert(lines, '|-') | |||
table.insert(lines, '| colspan="2" style="text-align: center;" | ' .. row_content[1]) | |||
row = table.concat(lines, "\n") | |||
end | end | ||
return row | return row | ||
| Line 84: | Line 85: | ||
local adjacent_links = args["Adjacent Links"] | local adjacent_links = args["Adjacent Links"] | ||
local rows = args["Rows"] | local rows = args["Rows"] | ||
-- Start of infobox; outer div and start of table | -- Start of infobox; outer div and start of table | ||
local | local lines = {} | ||
table.insert(lines, [[<div style="' | |||
border: 1px solid #999; | |||
margin: 0; | |||
margin-left: 1em; | |||
margin-bottom: 0.5em; | |||
padding: 0.5em; | |||
background-color: #f0f0f0; | |||
min-width: 15em; | |||
float: right; | |||
max-width: 100%; | |||
overflow: auto;">]] | |||
) | |||
table.insert(lines, '{| style="border-collapse: collapse; width: 100%;"') | |||
table.insert(lines, '|+ style="font-size: 105%; font-weight: bold; text-align: center;" | ') | |||
table.insert(lines, p.infobox_header(title, adjacent_links)) | |||
-- For loop for populating entries | -- For loop for populating entries | ||
for i = 1, #rows do | for i = 1, #rows do | ||
table.insert(lines, p.infobox_row(rows[i])) | |||
end | end | ||
infobox | -- End of infobox | ||
table.insert(lines, "|}</div>") | |||
return table.concat(lines, "\n") | |||
end | end | ||
| Line 193: | Line 194: | ||
args["Rows"] = rows | args["Rows"] = rows | ||
local result = p._infobox(args) | |||
local debugg = yesno(args["debug"]) | |||
if debugg == true then | |||
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" | |||
end | |||
return result | |||
end | end | ||