Module:Infobox video game awards: Difference between revisions
Appearance
Content deleted Content added
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
local p = {} |
local p = {} |
||
local function |
local function award(builder, text) |
||
builder:tag('th') |
|||
return ' style="vertical-align: middle; text-align: center; background-color: #9F9;' .. (style or '') .. '" |' .. text |
|||
:css('vertical-align', 'middle') |
|||
:css('text-align', 'center') |
|||
:wikitext(text) |
|||
end |
end |
||
local function |
local function won(builder, text) |
||
builder:tag('td') |
|||
return ' style="vertical-align: middle; text-align: center; background-color: #FDD;' .. (style or '') .. '" |' .. text |
|||
:css('vertical-align', 'middle') |
|||
end |
|||
:css('text-align', 'center') |
|||
:css('background-color', '#9F9') |
|||
:wikitext(text) |
|||
end |
|||
local function |
local function nom(builder, text) |
||
builder:tag('td') |
|||
if args['award' .. i] == nil then return end |
|||
:css('vertical-align', 'middle') |
|||
local ret |
|||
:css('text-align', 'center') |
|||
:css('background-color', '#FDD') |
|||
:wikitext(text) |
|||
end |
|||
local function row(builder, args, i) |
|||
ret = |
|||
builder = builder:tag('tr') |
|||
'|- style="background-color: #ddddff;"' .. '\n' .. |
|||
award(builder, args['award' .. i]) |
|||
won(builder, args['award' .. i ..'W'] or 0) |
|||
nom(builder, args['award' .. i ..'N'] or 0) |
|||
return ret |
|||
end |
end |
||
Line 32: | Line 41: | ||
function p._main(args) |
function p._main(args) |
||
-- Main module code goes here. |
-- Main module code goes here. |
||
local ret, temp |
local ret, temp |
||
local totalW, totalN = 0, 0 |
local totalW, totalN = 0, 0 |
||
ret = |
|||
'{| class="infobox" style="width: 20em; font-size: 90%; vertical-align: middle;"\n' .. |
|||
'|+ style="font-size: 9pt; font-weight: bold;" | List of accolades<i>' .. (args.title and (' received by' .. args.title) or '') .. '</i>\n' |
|||
if args.image then |
|||
ret = ret .. '|-\n' |
|||
ret = ret .. '| colspan="3" style="text-align: center;" | ' .. args.image .. '\n' .. (args.caption and ('<div style="display: block;"/>' .. args.caption) or '') .. '\n' |
|||
end |
|||
-- Award list begin |
|||
for i = 1, 99 do |
for i = 1, 99 do |
||
if args['award' .. |
if args['award' ..i] then |
||
temp = |
temp = '' |
||
break |
|||
totalW = totalW + args['award' .. i ..'W'] |
|||
totalN = totalN + args['award' .. i ..'N'] |
|||
end |
end |
||
end |
end |
||
if temp |
if temp then |
||
temp = mw.html.create('table') |
|||
:attr('class', 'collapsible collapsed') |
|||
'|-\n' .. |
|||
:css('width', '100%') |
|||
'| colspan="3" |\n' .. |
|||
'{| class="collapsible collapsed" style="width: 100%;" |\n' .. |
|||
temp:tag('tr'):tag('th') |
|||
'! colspan=3 style="background-color: #D9E8FF; text-align: center;" | Accolades\n' .. |
|||
' |
:attr('colspan', '3') |
||
' |
:css('background-color', '#D9E8FF') |
||
' |
:css('text-align', 'center') |
||
:wikitext('Accolades') |
|||
'! style="text-align:center; background: #cceecc; text-size:0.9em; width: 5.8em; | Won\n' .. |
|||
'! style="text-align:center; background: #ffccdd; text-size:0.9em; width: 5.8em;"| Nominated\n' .. |
|||
temp:tag('tr') |
|||
:css('background-color', '#D9E8FF') |
|||
'|}\n' |
|||
:tag('th') |
|||
end |
|||
:wikitext('Award') |
|||
:css('text-align', 'center') |
|||
if args.totals ~= 'no' then |
|||
:done() |
|||
local totalW = args.awards or totalW |
|||
:tag('th') |
|||
local totalN = args.nominations or totalN |
|||
:css('background-color', '#cec') |
|||
ret = ret .. |
|||
:css('text-size', '0.9em') |
|||
'|- style="background:#d9e8ff; border-spacing: 4px 2px 2px;"\n' .. |
|||
:css('width', '5.8em') |
|||
'! style="text-align:center;" colspan="3"| <b>Total number of awards and nominations</b>\n' .. |
|||
:css('text-align', 'center') |
|||
'|- style="font-weight: bold;"\n' .. |
|||
:wikitext('Won') |
|||
:done() |
|||
'|' .. won(tostring(totalW), 'width: 6em;') .. '\n' .. |
|||
:tag('th') |
|||
'|' .. nom(tostring(totalN), 'width: 6em;') .. '\n' |
|||
:css('background-color', '#fcd') |
|||
:css('text-size', '0.9em') |
|||
:css('width', '5.8em') |
|||
:css('text-align', 'center') |
|||
:wikitext('Nominated') |
|||
:done() |
|||
for i = 1, 99 do |
|||
if args['award' .. i] then |
|||
row(temp, args, i) |
|||
totalW = totalW + (args['award' .. i ..'W'] or 0) |
|||
totalN = totalN + (args['award' .. i ..'N'] or 0) |
|||
end |
|||
end |
|||
end |
end |
||
-- Award list end |
|||
ret = mw.html.create('table') |
|||
:attr('class', 'infobox') |
|||
:css('width', '20em') |
|||
:css('font-size', '90%') |
|||
:css('vertical-align', 'align') |
|||
ret:tag('caption') |
|||
if args.refsect ~= 'no' then |
|||
:css('font-size', '9pt') |
|||
ret = ret .. |
|||
:wikitext('List of accolades<i>' .. (args.title and (' received by' .. args.title) or '') .. '</i>') |
|||
'|- style="background:#d9e8ff;"\n' .. |
|||
:done() |
|||
'| colspan="3" style="font-size: smaller; text-align:center;"| [[#References|Footnotes]]\n' .. |
|||
'|}' |
|||
if args.image then |
|||
ret:tag('tr'):tag('td') |
|||
:attr('colspan', '3') |
|||
:css('text-align', 'center') |
|||
:wikitext(args.image .. (args.caption and ('<div style="display: block;"/>' .. args.caption) or '')) |
|||
:done():done() |
|||
end |
end |
||
if temp then |
|||
ret:tag('tr'):tag('td') |
|||
:attr('colspan', '3') |
|||
:wikitext(tostring(temp)) |
|||
:done():done() |
|||
end |
|||
return ret |
return ret |
Revision as of 06:23, 6 January 2016
Implements Template:Infobox video game awards.
require('Module:No globals')
local getArgs = require('Module:Arguments').getArgs
local p = {}
local function award(builder, text)
builder:tag('th')
:css('vertical-align', 'middle')
:css('text-align', 'center')
:wikitext(text)
end
local function won(builder, text)
builder:tag('td')
:css('vertical-align', 'middle')
:css('text-align', 'center')
:css('background-color', '#9F9')
:wikitext(text)
end
local function nom(builder, text)
builder:tag('td')
:css('vertical-align', 'middle')
:css('text-align', 'center')
:css('background-color', '#FDD')
:wikitext(text)
end
local function row(builder, args, i)
builder = builder:tag('tr')
award(builder, args['award' .. i])
won(builder, args['award' .. i ..'W'] or 0)
nom(builder, args['award' .. i ..'N'] or 0)
end
function p.main(frame)
local args = getArgs(frame)
return p._main(args)
end
function p._main(args)
-- Main module code goes here.
local ret, temp
local totalW, totalN = 0, 0
-- Award list begin
for i = 1, 99 do
if args['award' ..i] then
temp = ''
break
end
end
if temp then
temp = mw.html.create('table')
:attr('class', 'collapsible collapsed')
:css('width', '100%')
temp:tag('tr'):tag('th')
:attr('colspan', '3')
:css('background-color', '#D9E8FF')
:css('text-align', 'center')
:wikitext('Accolades')
temp:tag('tr')
:css('background-color', '#D9E8FF')
:tag('th')
:wikitext('Award')
:css('text-align', 'center')
:done()
:tag('th')
:css('background-color', '#cec')
:css('text-size', '0.9em')
:css('width', '5.8em')
:css('text-align', 'center')
:wikitext('Won')
:done()
:tag('th')
:css('background-color', '#fcd')
:css('text-size', '0.9em')
:css('width', '5.8em')
:css('text-align', 'center')
:wikitext('Nominated')
:done()
for i = 1, 99 do
if args['award' .. i] then
row(temp, args, i)
totalW = totalW + (args['award' .. i ..'W'] or 0)
totalN = totalN + (args['award' .. i ..'N'] or 0)
end
end
end
-- Award list end
ret = mw.html.create('table')
:attr('class', 'infobox')
:css('width', '20em')
:css('font-size', '90%')
:css('vertical-align', 'align')
ret:tag('caption')
:css('font-size', '9pt')
:wikitext('List of accolades<i>' .. (args.title and (' received by' .. args.title) or '') .. '</i>')
:done()
if args.image then
ret:tag('tr'):tag('td')
:attr('colspan', '3')
:css('text-align', 'center')
:wikitext(args.image .. (args.caption and ('<div style="display: block;"/>' .. args.caption) or ''))
:done():done()
end
if temp then
ret:tag('tr'):tag('td')
:attr('colspan', '3')
:wikitext(tostring(temp))
:done():done()
end
return ret
end
return p