Module:Sports roster/default
Appearance
![]() | This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected. |
Usage
This submodule is used by Module:Sports roster when |style=
is undefined, or when |style=default
, or when the requested style submodule does not exist.
local pp = {}
-- Roster format
function pp.header(args, keys)
return ''
end
function pp.players_roster(args, players, keys)
local r = mw.html.create('tr').css('text-align', 'center')
for k,v in pairs(players) do
if keys['pos'] then
r:tag('td').wikitext(v['pos'] or '')
end
if keys['num'] then
r:tag('td').wikitext(v['num'] or '')
end
if keys['nat'] then
r:tag('td').wikitext(v['nat'] or '')
end
local link = v['link'] or v['name'] or ((v['first'] .. '') .. ' ' .. (v['last'] .. '') .. (v['dab'] and ' (' .. v['dab'] .. ')' or '')) or ''
local text = v['alt'] or v['name'] or ((v['last'] .. '') .. ', ' .. (v['first'] .. '')) or ''
if link:match('^[,%s]*$') then
if text:match('^[,%s]*$') then
text = ''
end
else
if text:match('^[,%s]*$') then
text = '[[' .. link .. ']]'
else
text = '[[' .. link .. '|' .. text .. ']]'
end
end
r:tag('td').css('text-align', 'left').wikitext(text)
if keys['ft'] or keys['in'] then
local h = ''
if v['ft'] and tonumber(v['ft']) then
local inches = 12*tonumber(v['ft']) + (tonumber(v['in']) or 0)
local cm = math.floor(2.54*inches + 0.5)
h = '<span data-sort-value="' .. inches .. '">'
.. tonumber(v['ft']) .. '\' ' .. (tonumber(v['in']) or 0) .. '"'
.. ' (' .. (cm / 100) .. 'm)</span>'
end
r:tag('td')
.css('text-align', 'right')
.css('white-space', 'nowrap')
.wikitext(h)
end
if keys['lbs'] then
local w = ''
if v['lbs'] and tonumber(v['lbs']) then
local kg = math.floor(0.45359237*tonumber(v['lbs']) + 0.5)
h = tonumber(v['lbs']) .. ' lb '
.. ' (' .. kg .. 'kg)'
end
r:tag('td')
.css('text-align', 'right')
.css('white-space', 'nowrap')
.wikitext(w)
end
if keys['DOB'] then
r:tag('td').wikitext(v['DOB'])
end
if keys['college'] or keys['school'] or keys['from'] then
if v['college'] or v['school'] then
r:tag('td').wikitext(v['college'] or v['school'])
elseif v['from'] then
r:tag('td').wikitext('[[' .. v['from'] .. ']]')
end
end
if keys['yrs'] then
r:tag('td').wikitext(v['yrs'])
end
end
return tostring(r)
end
function pp.coaches_roster(args, coaches)
return ''
end
function pp.staff_roster(args, staff)
return ''
end
function pp.footer(args, keys)
return ''
end
-- Navbox format
function pp.title(args, keys)
return args['title']
end
function pp.titlestyle(args, keys)
return args['titlestyle']
end
function pp.players_list(args, players, keys)
local r = ''
for k,v in pairs(players) do
r = r .. '\n*' .. (v['num'] or '') .. ' '
local link = v['link'] or v['name'] or ((v['first'] .. '') .. ' ' .. (v['last'] .. '') .. (v['dab'] and ' (' .. v['dab'] .. ')' or '')) or ''
local text = v['alt'] or v['name'] or ((v['last'] .. '') .. ', ' .. (v['first'] .. '')) or ''
if link:match('^[,%s]*$') then
if text:match('^[,%s]*$') then
text = ''
end
else
if text:match('^[,%s]*$') then
text = '[[' .. link .. ']]'
else
text = '[[' .. link .. '|' .. text .. ']]'
end
end
r = r .. text
end
return r
end
function pp.coaches_list(args, coaches)
return ''
end
function pp.below(args, keys)
return args['below']
end
function pp.belowstyle(args, keys)
return args['belowstyle']
end
return pp