Module:Infobox: Difference between revisions

Ganaram inukshuk (talk | contribs)
m bugfix
Ganaram inukshuk (talk | contribs)
refactor
Line 60: Line 60:
local row = ""
local row = ""
if #row_content > 1 then
if #row_content > 1 then
local caption = row_content[1]
local lines = {}
local text    = row_content[2]
table.insert(lines, '|-')
row = row
table.insert(lines, '| style="text-align: right; padding-right: 0.25em;" | ' .. row_content[1])
.. '|-\n'
table.insert(lines, '| style="background-color: white; padding-left: 0.25em; font-weight: bold;" | ' .. row_content[2])
.. '| style="text-align: right; padding-right: 0.25em;" | ' .. caption .. '\n'
.. '| style="background-color: white; padding-left: 0.25em; font-weight: bold;" | ' .. text .. '\n'
row = table.concat(lines, "\n")
elseif #row_content == 1 then
elseif #row_content == 1 then
local text = row_content[1]
local lines = {}
row = row
table.insert(lines, '|-')
.. '|-\n'
table.insert(lines, '| colspan="2" style="text-align: center;" | ' .. row_content[1])
.. '| colspan="2" style="text-align: center;" | ' .. text .. '\n'
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"]
local debugg = yesno(args["debug"])
-- Start of infobox; outer div and start of table
-- Start of infobox; outer div and start of table
local infobox = '<div style="'
local lines = {}
.. 'border: 1px solid #999; '
.. 'margin: 0; '
table.insert(lines, [[<div style="'
.. 'margin-left: 1em; '
border: 1px solid #999;  
.. 'margin-bottom: 0.5em; '
margin: 0;  
.. 'padding: 0.5em; '
margin-left: 1em;  
.. 'background-color: #f0f0f0; '
margin-bottom: 0.5em;  
.. 'min-width: 15em; '
padding: 0.5em;  
.. 'float: right; '
background-color: #f0f0f0;  
.. 'max-width: 100%; '
min-width: 15em;  
.. 'overflow: auto;">\n'
float: right;  
max-width: 100%;  
overflow: auto;">]]
)
-- Infobox table, starting with table
table.insert(lines, '{| style="border-collapse: collapse; width: 100%;"')
.. '{| style="border-collapse: collapse; width: 100%;"\n'
table.insert(lines, '|+ style="font-size: 105%; font-weight: bold; text-align: center;" | ')
.. '|+ style="font-size: 105%; font-weight: bold; text-align: center;" | \n' .. p.infobox_header(title, adjacent_links) .. '\n'
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
infobox = infobox .. p.infobox_row(rows[i])
table.insert(lines, p.infobox_row(rows[i]))
end
end
infobox = infobox .. "|}</div>"
-- End of infobox
if debugg == true then
table.insert(lines, "|}</div>")
infobox = "<syntaxhighlight lang=\"wikitext\">" .. infobox .. "</syntaxhighlight>"
 
end
return table.concat(lines, "\n")
return infobox
end
end


Line 193: Line 194:
args["Rows"] = rows
args["Rows"] = rows
return p._infobox(args)
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