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.headings(args, keys)
local h = mw.html.create('tr')
if keys['pos'] then
h:tag('th'):wikitext('Pos.')
end
if keys['num'] then
h:tag('th'):wikitext('#')
end
if keys['nat'] then
h:tag('th'):wikitext('Nat.')
end
h:tag('th'):wikitext('Name')
if keys['ft'] or keys['in'] then
h:tag('th'):wikitext('Height')
end
if keys['lbs'] then
h:tag('th'):wikitext('Weight')
end
if keys['DOB'] then
h:tag('th'):tag('abbr'):attr('title', 'Date of birth'):wikitext('DOB')
end
if keys['college'] or keys['school'] or keys['from'] then
h:tag('th'):wikitext('From')
end
if keys['yrs'] then
h:tag('th'):wikitext('Yrs')
end
return tostring(h)
end
function pp.players_roster(args, players, keys)
local tracking = ''
local res = mw.html.create('')
for k,v in ipairs(players) do
local r = res:tag('tr'):css('text-align', 'center')
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
r:tag('td'):css('text-align', 'left'):wikitext(v['name'] or '')
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)
w = 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(res) .. tracking
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 ipairs(players) do
r = r .. '\n*' .. (v['num'] or '') .. ' ' .. (v['name'] or '')
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