Module:Sandbox/B2project/NHL Standings: Difference between revisions

Content deleted Content added
Created page with '-- Style for football tables local pp = {} function pp.header(t,Args,p_sub,pos_label,group_col,VTE_text,full_table,results_header_txt) -- Load relevant module...'
 
No edit summary
 
(332 intermediate revisions by the same user not shown)
Line 1:
-- This module copies content from Template:MLB_standings; see the history of that page
-- Style for football tables
-- for attribution. 6/15/16
local pp = {}
 
local me = { }
function pp.header(t,Args,p_sub,pos_label,group_col,VTE_text,full_table,results_header_txt)
 
-- Load relevant modules
local nhlData
local yesno = require('Module:Yesno')
 
-- if mw.loadData() not supported, use require() instead
-- Create table header
if mw.loadData then
-- Pre stuff
nhlData = mw.loadData('Module:Sandbox/B2project/NHL Standings/data')
local team_width = Args['teamwidth'] or '190'
else
local sort_text = ''
nhlData = require('Module:Sandbox/B2project/NHL Standings/data')
local sort_table_val = Args['sortable_table'] or 'no'
if yesno(sort_table_val) then sort_text = 'sortable' end
table.insert(t,'{|class="wikitable '..sort_text..'" style="text-align:center;"\n') -- Open table
-- Custom header options
-- Table header
local table_header = Args['table_header']
if table_header then
table.insert(t,'|+'..table_header..'\n')
end
--Column headers
local pld_head_text = Args['pld_header'] or '<abbr title="Played">Pld</abbr>'
local OTloss_head_text = Args['OTloss_header'] or '<abbr title="Lost in overtime">OTL</abbr>'
local tiebr_head_text = Args['tiebr_header'] or '<abbr title="Tiebreaker">TBR</abbr>'
local group_head_text = Args['group_header'] or '<abbr title="Group">Grp</abbr>'
-- Use points instead of goals for/against
local for_against_style = Args['for_against_style'] or 'goals'
local fa_letter, fa_word_sing, fa_word_plur
-- First convert to lower case if it is a string
for_against_style = string.lower(for_against_style)
if for_against_style=='g' or for_against_style=='goal' or for_against_style=='goals' then
fa_letter = 'G'
fa_word_sing = 'Goal'
fa_word_plur = 'Goals'
elseif for_against_style=='p' or for_against_style=='point' or for_against_style=='points' then
fa_letter = 'P'
fa_word_sing = 'Point'
fa_word_plur = 'Points'
else
fa_letter = 'G'
fa_word_sing = 'Goal'
fa_word_plur = 'Goals'
end
-- Whether to use goal ratio (goal average) instead
local use_ratio_val = Args['use_goal_ratio'] or 'no'
local do_ratio = false
-- True if exist, false otherwise
if yesno(use_ratio_val) then do_ratio = true end
-- Whether to use tiebreak
local use_tiebr_val = Args['use_tiebreak'] or 'yes'
local do_tiebr = false
if yesno(use_tiebr_val) then do_tiebr = true end
-- Ties and OTL
local use_tieOTL_val = Args['use_ties'] or 'no'
local do_ties = false
if yesno(use_tieOTL_val) then do_ties = true end
-- Initialize
local tt = {}
tt.count = 0 -- Up by one after every call
tt.tab_text = t -- Actual text
-- Actual headers
tt = p_sub.colhead(tt,32,pos_label) -- Position col
-- Add group header
if full_table and group_col then
tt = p_sub.colhead(tt,32,group_head_text) -- Group/division col
end
tt = p_sub.colhead(tt,team_width,'Team'..VTE_text) -- Team col
tt = p_sub.colhead(tt,32,pld_head_text) -- Matches played col
if full_table then
tt = p_sub.colhead(tt,32,'<abbr title="Won">W</abbr>') -- Win col
tt = p_sub.colhead(tt,32,'<abbr title="Lost">L</abbr>') -- Loss col
if do_ties then
tt = p_sub.colhead(tt,32,'<abbr title="Ties">T</abbr>') -- Ties
end
tt = p_sub.colhead(tt,32,OTloss_head_text)
if do_tiebr then
tt = p_sub.colhead(tt,32,tiebr_head_text)
end
tt = p_sub.colhead(tt,32,'<abbr title="'..fa_word_plur..' for">'..fa_letter..'F</abbr>') -- For col
tt = p_sub.colhead(tt,32,'<abbr title="'..fa_word_plur..' against">'..fa_letter..'A</abbr>') -- Against col
if not do_ratio then
tt = p_sub.colhead(tt,32,'<abbr title="'..fa_word_sing..' difference">'..fa_letter..'D</abbr>') -- Difference col
else
tt = p_sub.colhead(tt,36,'<abbr title="'..fa_word_sing..' ratio">'..fa_letter..'R</abbr>') -- Ratio col
end
end
tt = p_sub.colhead(tt,32,'<abbr title="Points">Pts</abbr>') -- Points col
if full_table then
tt.count = tt.count+1
table.insert(tt.tab_text,results_header_txt)
end
return tt
end
 
local Navbar = require('Module:Navbar')
function pp.row(frame,t,Args,p_sub,notes_exist,hth_id_list,full_table,rand_val,team_list,team_code_ii,ii_start,ii_end,ii_fw,bg_col,N_teams,ii,ii_show)
 
-- Build the inner parts of individual rows
-- Temporary workaround for missing mw.text utility functions
mw.text = mw.text or {}
-- Sub-module usage
 
local mm = require('Module:Math')
if (mw.text.trim == nil) then
local yesno = require('Module:Yesno')
mw.text.trim = function(s)
if (s == nil) then
-- Get custom/default options for in table
return ''
local win_points = tonumber(Args['winpoints']) or 2
end
local loss_points = tonumber(Args['losspoints']) or 0
return mw.ustring.match(s, "^%s*(.-)%s*$")
local OTloss_points = tonumber(Args['OTlosspoints']) or 1
end
local ties_points = tonumber(Args['tiepoints']) or 1
-- Get some input
local wins = tonumber(Args['win_'..team_code_ii]) or 0
local losses = tonumber(Args['loss_'..team_code_ii]) or 0
local OTlosses = tonumber(Args['OTloss_'..team_code_ii]) or 0
local ties = tonumber(Args['ties_'..team_code_ii]) or 0
local tiebr_val = tonumber(Args['tiebr_'..team_code_ii]) or 0
local gfor = tonumber(Args['gf_'..team_code_ii]) or tonumber(Args['pf_'..team_code_ii]) or 0
local gaig = tonumber(Args['ga_'..team_code_ii]) or tonumber(Args['pa_'..team_code_ii]) or 0
local s_pts = tonumber(Args['adjust_points_'..team_code_ii]) or tonumber(Args['startpoints_'..team_code_ii]) or 0
local hth_local = Args['hth_'..team_code_ii] or nil
-- Then calculate some values
local matches = wins + losses + OTlosses + ties
local points = win_points*wins + loss_points*losses + OTloss_points*OTlosses + s_pts + ties_points*ties
-- Comparison of for against
local gcomp
-- Whether to use goal ratio (goal average) instead
local use_ratio_val = Args['use_goal_ratio'] or 'no'
local skip_sign
if yesno(use_ratio_val) then
-- Now it is the goal ratio/goal average
if gaig == 0 then
gcomp = '&mdash;'
else
gcomp = mm._precision_format(gfor / gaig, 3)
end
else
-- It's goal difference
gcomp = gfor - gaig
-- Formatting with signs
if gcomp>0 then
gcomp='+'..gcomp
elseif gcomp < 0 then
gcomp='&minus;'..-gcomp
end
end
 
if (mw.text.gsplit == nil) then
-- Whether to use tiebreak
mw.text.gsplit = function( text, pattern, plain )
local use_tiebr_val = Args['use_tiebreak'] or 'yes'
local s, l = 1, mw.ustring.len( text )
local do_tiebr = false
return function ()
if yesno(use_tiebr_val) then do_tiebr = true end
if s then
local e, n = mw.ustring.find( text, pattern, s, plain )
local ret
if not e then
ret = mw.ustring.sub( text, s )
s = nil
elseif n < e then
-- Empty separator!
ret = mw.ustring.sub( text, s, e )
if e < l then
s = e + 1
else
s = nil
end
else
ret = e > s and mw.ustring.sub( text, s, e - 1 ) or ''
s = n + 1
end
return ret
end
end, nil, nil
end
end
 
if (mw.text.split == nil) then
mw.text.split = function ( text, pattern, plain )
local ret = {}
for m in mw.text.gsplit( text, pattern, plain ) do
ret[#ret+1] = m
end
return ret
end
end
 
local defaultOutputForInput = {
default = 'default',
current = 'current',
winsloss = 'winsloss',
WLT = 'WLT',
}
 
local readTeamInfo = {
default = function(args, currentIdx, returnData)
if (args[currentIdx] == nil or
args[currentIdx+1] == nil or
args[currentIdx+2] == nil or
args[currentIdx+3] == nil or
args[currentIdx+4] == nil or
args[currentIdx+5] == nil or
args[currentIdx+6] == nil or
args[currentIdx+7] == nil ) then
return nil
end
teamInfo = {
name = mw.text.trim(args[currentIdx]),
wins = tonumber(mw.text.trim(args[currentIdx+1])),
losses = tonumber(mw.text.trim(args[currentIdx+2])),
ties = tonumber(mw.text.trim(args[currentIdx+3])),
otlosses = tonumber(mw.text.trim(args[currentIdx+4])),
row = tonumber(mw.text.trim(args[currentIdx+5])),
gf = tonumber(mw.text.trim(args[currentIdx+6])),
ga = tonumber(mw.text.trim(args[currentIdx+7])),
winpoints = 2,
tiepoints = 1,
otlpoints = 1,
points = '',
gamesplayed = '',
}
returnData.cIndicesRead = 8
teamInfo.gamesplayed = teamInfo.wins + teamInfo.losses + teamInfo.ties + teamInfo.otlosses
teamInfo.points = (teamInfo.winpoints*teamInfo.wins)+(teamInfo.tiepoints*teamInfo.ties)+(teamInfo.otlpoints*teamInfo.otlosses)
 
return teamInfo
end, -- function readTeamInfo.default()
current = function(args, currentIdx, returnData)
if (args[currentIdx] == nil or
args[currentIdx+1] == nil or
args[currentIdx+2] == nil or
args[currentIdx+3] == nil or
args[currentIdx+4] == nil or
args[currentIdx+5] == nil or
args[currentIdx+6] == nil ) then
return nil
end
teamInfo = {
name = mw.text.trim(args[currentIdx]),
wins = tonumber(mw.text.trim(args[currentIdx+1])),
losses = tonumber(mw.text.trim(args[currentIdx+2])),
otlosses = tonumber(mw.text.trim(args[currentIdx+3])),
row = tonumber(mw.text.trim(args[currentIdx+4])),
gf = tonumber(mw.text.trim(args[currentIdx+5])),
ga = tonumber(mw.text.trim(args[currentIdx+6])),
winpoints = 2,
otlpoints = 1,
points = '',
gamesplayed = '',
}
returnData.cIndicesRead = 7
teamInfo.gamesplayed = teamInfo.wins + teamInfo.losses + teamInfo.otlosses
teamInfo.points = (teamInfo.winpoints*teamInfo.wins)+(teamInfo.otlpoints*teamInfo.otlosses)
 
return teamInfo
end, -- function readTeamInfo.default()
winsloss = function(args, currentIdx, returnData)
if (args[currentIdx] == nil or
args[currentIdx+1] == nil or
args[currentIdx+2] == nil or
args[currentIdx+3] == nil or
args[currentIdx+4] == nil ) then
return nil
end
teamInfo = {
name = mw.text.trim(args[currentIdx]),
wins = tonumber(mw.text.trim(args[currentIdx+1])),
losses = tonumber(mw.text.trim(args[currentIdx+2])),
gf = tonumber(mw.text.trim(args[currentIdx+3])),
ga = tonumber(mw.text.trim(args[currentIdx+4])),
winpoints = 2,
points = '',
gamesplayed = '',
}
returnData.cIndicesRead = 5
teamInfo.gamesplayed = teamInfo.wins + teamInfo.losses
teamInfo.points = (teamInfo.winpoints*teamInfo.wins)
 
return teamInfo
end, -- function readTeamInfo.default()
WLT = function(args, currentIdx, returnData)
if (args[currentIdx] == nil or
args[currentIdx+1] == nil or
args[currentIdx+2] == nil or
args[currentIdx+3] == nil or
args[currentIdx+4] == nil or
args[currentIdx+5] == nil ) then
return nil
end
teamInfo = {
name = mw.text.trim(args[currentIdx]),
wins = tonumber(mw.text.trim(args[currentIdx+1])),
losses = tonumber(mw.text.trim(args[currentIdx+2])),
ties = tonumber(mw.text.trim(args[currentIdx+3])),
gf = tonumber(mw.text.trim(args[currentIdx+4])),
ga = tonumber(mw.text.trim(args[currentIdx+5])),
winpoints = 2,
tiepoints = 1,
points = '',
gamesplayed = '',
}
returnData.cIndicesRead = 6
teamInfo.gamesplayed = teamInfo.wins + teamInfo.losses + teamInfo.ties
teamInfo.points = (teamInfo.winpoints*teamInfo.wins) + (teamInfo.tiepoints*teamInfo.ties)
 
return teamInfo
end, -- function readTeamInfo.default()
 
} -- readTeamInfo object
 
local generateTableHeader = {
default = function(tableHeaderInfo)
return
'{| class="wikitable sortable" width="" style="text-align:center;"\
|+ [[' .. tableHeaderInfo.divisionLink.. '|' .. tableHeaderInfo.division .. ']]' ..tableHeaderInfo.source.. '\
! width=32 | <abbr title="Position">Pos</abbr>\
! width=190 | Team ' .. tableHeaderInfo.navbarText .. '\
! width=32 | <abbr title="Games played">GP</abbr>\
! width=32 | <abbr title="Won">W</abbr>\
! width=32 | <abbr title="Lost">L</abbr>\
! width=32 | <abbr title="Ties">T</abbr>\
! width=32 | <abbr title="Lost in overtime">OTL</abbr>\
! width=32 | <abbr title="Regulation + Overtime wins">ROW</abbr>\
! width=32 | <abbr title="Goals for">GF</abbr>\
! width=32 | <abbr title="Goals for">GA</abbr>\
! width=32 | <abbr title="Goal difference">GD</abbr>\
! width=32 | <abbr title="Points">Pts</abbr>\
'
end, -- function generateTableHeader.default()
 
current = function(tableHeaderInfo)
return
'{| class="wikitable sortable" width="" style="text-align:center;"\
|+ [[' .. tableHeaderInfo.divisionLink.. '|' .. tableHeaderInfo.division .. ']]\
! width=32 | <abbr title="Position">Pos</abbr>\
! width=190 | Team ' .. tableHeaderInfo.navbarText .. '\
! width=32 | <abbr title="Games played">GP</abbr>\
! width=32 | <abbr title="Won">W</abbr>\
! width=32 | <abbr title="Lost">L</abbr>\
! width=32 | <abbr title="Lost in overtime">OTL</abbr>\
! width=32 | <abbr title="Regulation + Overtime wins">ROW</abbr>\
! width=32 | <abbr title="Goals for">GF</abbr>\
! width=32 | <abbr title="Goals for">GA</abbr>\
! width=32 | <abbr title="Goal difference">GD</abbr>\
! width=32 | <abbr title="Points">Pts</abbr>\
'
end,
 
winsloss = function(tableHeaderInfo)
return
'{| class="wikitable sortable" width="" style="text-align:center;"\
|+ [[' .. tableHeaderInfo.divisionLink.. '|' .. tableHeaderInfo.division .. ']]\
! width=32 | <abbr title="Position">Pos</abbr>\
! width=190 | Team ' .. tableHeaderInfo.navbarText .. '\
! width=32 | <abbr title="Games played">GP</abbr>\
! width=32 | <abbr title="Won">W</abbr>\
! width=32 | <abbr title="Lost">L</abbr>\
! width=32 | <abbr title="Goals for">GF</abbr>\
! width=32 | <abbr title="Goals for">GA</abbr>\
! width=32 | <abbr title="Goal difference">GD</abbr>\
! width=32 | <abbr title="Points">Pts</abbr>\
'
end, -- function generateTableHeader.winloss()
 
WLT = function(tableHeaderInfo)
return
'{| class="wikitable sortable" width="" style="text-align:center;"\
|+ [[' .. tableHeaderInfo.divisionLink.. '|' .. tableHeaderInfo.division .. ']]\
! width=32 | <abbr title="Position">Pos</abbr>\
! width=190 | Team ' .. tableHeaderInfo.navbarText .. '\
! width=32 | <abbr title="Games played">GP</abbr>\
! width=32 | <abbr title="Won">W</abbr>\
! width=32 | <abbr title="Lost">L</abbr>\
! width=32 | <abbr title="Ties">T</abbr>\
! width=32 | <abbr title="Goals for">GF</abbr>\
! width=32 | <abbr title="Goals for">GA</abbr>\
! width=32 | <abbr title="Goal difference">GD</abbr>\
! width=32 | <abbr title="Points">Pts</abbr>\
'
end, -- function generateTableHeader.WLT()
} -- generateTableHeader object
-- Ties and OTL
 
local use_tieOTL_val = Args['use_ties'] or 'no'
local do_tiesgenerateTeamRow = false{
default = function(teamRowInfo, teamInfo)
if yesno(use_tieOTL_val) then do_ties = true end
return
'|-' .. teamRowInfo.rowStyle .. '\
-- Some local vars
|| ' .. teamRowInfo.position ..'\
local hth_string
| style="text-align:left;" | ' .. teamRowInfo.statusText .. '[[' .. teamRowInfo.teamSeasonPage .. '|' .. teamInfo.name .. ']]\
local tt_return = p_sub.hth(frame,Args,full_table,hth_id_list,hth_local,notes_exist,team_list,team_code_ii,ii_start,ii_end,rand_val)
|| ' .. teamInfo.gamesplayed .. '\
hth_string = tt_return.str
|| ' .. teamInfo.wins .. '\
hth_id_list = tt_return.list
|| ' .. teamInfo.losses .. '\
notes_exist = tt_return.notes_exist
|| ' .. teamInfo.ties ..'\
|| ' .. teamInfo.otlosses ..'\
-- Row building
|| ' .. teamInfo.row ..'\
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..matches..'\n') -- Played
|| ' .. teamInfo.gf .. '\
if full_table then
|| ' .. teamInfo.ga .. '\
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..wins..'\n') -- Won
|| ' .. teamRowInfo.goaldiff ..'\
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..losses..'\n') -- Lost
| style="font-weight:bold;" | ' .. teamInfo.points ..'\n'
if do_ties then
 
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..ties..'\n') -- Ties
end, -- function generateTeamRow.default()
end
 
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..OTlosses..'\n') -- Lost in OT
current = function(teamRowInfo, teamInfo)
if do_tiebr then
return
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..tiebr_val..'\n') -- Tiebreaker value
'|-' .. teamRowInfo.rowStyle .. '\
end
|| ' .. teamRowInfo.position ..'\
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..gfor..'\n') -- GF
| style="text-align:left;" | ' .. teamRowInfo.statusText .. '[[' .. teamRowInfo.teamSeasonPage .. '|' .. teamInfo.name .. ']]\
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..gaig..'\n') -- GA
|| ' .. teamInfo.gamesplayed .. '\
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..gcomp..'\n') -- Goal comparison
|| ' .. teamInfo.wins .. '\
|| ' .. teamInfo.losses .. '\
|| ' .. teamInfo.otlosses ..'\
|| ' .. teamInfo.row ..'\
|| ' .. teamInfo.gf .. '\
|| ' .. teamInfo.ga .. '\
|| ' .. teamRowInfo.goaldiff ..'\
| style="font-weight:bold;" | ' .. teamInfo.points ..'\n'
 
end,
 
winsloss = function(teamRowInfo, teamInfo)
return
'|-' .. teamRowInfo.rowStyle .. '\
|| ' .. teamRowInfo.position ..'\
| style="text-align:left;" | ' .. teamRowInfo.statusText .. '[[' .. teamRowInfo.teamSeasonPage .. '|' .. teamInfo.name .. ']]\
|| ' .. teamInfo.gamesplayed .. '\
|| ' .. teamInfo.wins .. '\
|| ' .. teamInfo.losses .. '\
|| ' .. teamInfo.gf .. '\
|| ' .. teamInfo.ga .. '\
|| ' .. teamRowInfo.goaldiff ..'\
| style="font-weight:bold;" | ' .. teamInfo.points ..'\n'
 
end, -- function generateTeamRow.default()
 
WLT = function(teamRowInfo, teamInfo)
return
'|-' .. teamRowInfo.rowStyle .. '\
|| ' .. teamRowInfo.position ..'\
| style="text-align:left;" | ' .. teamRowInfo.statusText .. '[[' .. teamRowInfo.teamSeasonPage .. '|' .. teamInfo.name .. ']]\
|| ' .. teamInfo.gamesplayed .. '\
|| ' .. teamInfo.wins .. '\
|| ' .. teamInfo.losses .. '\
|| ' .. teamInfo.ties .. '\
|| ' .. teamInfo.gf .. '\
|| ' .. teamInfo.ga .. '\
|| ' .. teamRowInfo.goaldiff ..'\
| style="font-weight:bold;" | ' .. teamInfo.points ..'\n'
 
end, -- function generateTeamRow.default()
 
} -- generateTeamRow object
 
local function parsestatus_list(status_listArg, status_list)
local statusList = mw.text.split(status_listArg, '%s*,%s*')
if (#statusList == 0) then
return
end
 
for idx, status in ipairs(statusList) do
local statusData = mw.text.split(status, '%s*:%s*')
if (#statusData >= 2) then
local statusNumber = mw.text.trim(statusData[1])
local team = mw.text.trim(statusData[2])
status_list[statusNumber] = team
status_list[team] = statusNumber
end
end
end -- function parsestatus_list()
 
local function parseHighlightArg(highlightArg, teamsToHighlight)
local teamList = mw.text.split(highlightArg, '%s*,%s*')
if (#teamList == 0) then
return
end
 
for idx, team in ipairs(teamList) do
teamsToHighlight[mw.text.trim(team)] = true
end
 
end -- function parseHighlightArg
 
local function parseTeamLinks(teamLinksArg, linkForTeam)
local teamList = mw.text.split(teamLinksArg, '%s*,%s*')
if (#teamList == 0) then
return
end
 
for idx, teamLinkInfo in ipairs(teamList) do
local teamData = mw.text.split(teamLinkInfo, '%s*:%s*')
if (#teamData >= 2) then
local team = mw.text.trim(teamData[1])
local teamLink = mw.text.trim(teamData[2])
linkForTeam[team] = teamLink
end
end
end -- function parseTeamLinks
 
function me.generateStandingsTable(frame)
local inputFormat = 'default'
if (frame.args.input ~= nil) then
local inputArg = mw.text.trim(frame.args.input)
if (inputArg == 'current') then
inputFormat = 'current'
end
if (inputArg == 'winsloss') then
inputFormat = 'winsloss'
end
if (inputArg == 'WLT') then
inputFormat = 'WLT'
end
end
 
local templateName = nil
if (frame.args.template_name ~= nil) then
templateName = frame.args.template_name
end
 
local outputFormat = defaultOutputForInput[inputFormat]
local fDisplayNavbar = true
local fDisplayTies = true
if (frame.args.output ~= nil) then
local outputArg = mw.text.trim(frame.args.output)
if (outputArg == 'current') then
outputFormat = 'current'
fDisplayTies = false
end
if (outputArg == 'winsloss') then
outputFormat = 'winsloss'
end
if (outputArg == 'WLT') then
outputFormat = 'WLT'
end
end
-- Add &minus; for negative point totals
local year = mw.text.trim(frame.args.year or '')
table.insert(t,'| style="font-weight: bold;'..bg_col..'" | ')
local division = mw.text.trim(frame.args.division or '')
if points<0 then
local divisionLink = mw.text.trim(frame.args.division_link or division)
table.insert(t,'&minus;'..-points..hth_string)
local source = mw.text.trim(frame.args.source or '')
 
local statusInfo = {}
if (frame.args.status_list ~= nil) then
parsestatus_list(frame.args.status_list, statusInfo)
end
 
local teamsToHighlight = {}
if (frame.args.highlight ~= nil) then
parseHighlightArg(frame.args.highlight, teamsToHighlight)
end
 
local linkForTeam = {}
if (frame.args.team_links ~= nil) then
parseTeamLinks(frame.args.team_links, linkForTeam)
end
 
local listOfTeams = {};
local currentArgIdx = 1;
 
while (frame.args[currentArgIdx] ~= nil) do
local returnData = { }
local teamInfo = readTeamInfo[inputFormat](frame.args, currentArgIdx, returnData);
if (teamInfo == nil) then
break
end
if (linkForTeam[teamInfo.name] ~= nil) then
teamInfo.teamLink = linkForTeam[teamInfo.name]
else
teamInfo.teamLink = teamInfo.name
end
table.insert(listOfTeams, teamInfo)
currentArgIdx = currentArgIdx + returnData.cIndicesRead
end
 
if (#listOfTeams == 0) then
return ''
end
 
local outputBuffer = { }
local t_footer = { }
 
local tableHeaderInfo = {
division = division,
divisionLink = divisionLink,
source = source,
}
 
if (fDisplayNavbar) then
local divisionForNavbox = division
if (nhlData.abbreviationForDivision[division] ~= nil) then
divisionForNavbox = nhlData.abbreviationForDivision[division]
end
 
local standingsPage
if (templateName ~= nil) then
standingsPage = templateName
else
standingsPage = year .. ' ' .. divisionForNavbox .. ' standings'
end
tableHeaderInfo.navbarText =
Navbar.navbar({
standingsPage,
mini = 1,
style = 'float:right;',
})
end
 
table.insert(outputBuffer,
generateTableHeader[outputFormat](tableHeaderInfo)
)
 
local leadingHalfGames = nil;
 
for idx, teamInfo in ipairs(listOfTeams) do
local teamRowInfo = {
teamSeasonPage = year .. ' ' .. teamInfo.teamLink .. ' season',
statusText = '',
rowStyle = '',
position = idx,
goaldiff = '',
winpoints = 2,
tiepoints = 1,
otlpoints = 1,
}
teamRowInfo.goaldiff = teamInfo.gf - teamInfo.ga
if teamRowInfo.goaldiff>0 then
teamRowInfo.goaldiff='<span style="color:green">+'..teamRowInfo.goaldiff..'</span>'
elseif teamRowInfo.goaldiff<0 then
teamRowInfo.goaldiff=teamRowInfo.goaldiff*-1
teamRowInfo.goaldiff='<span style="color:red">&minus;'..teamRowInfo.goaldiff..'</span>'
end
if (statusInfo[teamInfo.name] ~= nil) then
teamRowInfo.statusText = '<span style="font-weight:bold">' .. string.lower(statusInfo[teamInfo.name]) .. ' –</span> '
--teamRowInfo.rowStyle = ' style="background:#CCFFCC"'
end
 
if (teamsToHighlight[teamInfo.name]) then
teamRowInfo.rowStyle = ' style="background:#CCFFCC;font-weight:bold;"'
end
 
table.insert(outputBuffer,
generateTeamRow[outputFormat](teamRowInfo, teamInfo)
)
 
end -- end of looping over listOfTeams
 
table.insert(outputBuffer, '|}\n')
local update = mw.text.trim(frame.args.update or 'unknown')
local start_date = mw.text.trim(frame.args.start_date or 'unknown')
--local source = mw.text.trim(frame.args.source or '')
if (source ~= nil) then
source = source
else
source = ''
table.insert(t,points..hth_string)
end
table.insert(t,'\n')
return {t=t, notes_exist=notes_exist, hth_id_list=hth_id_list}
end
function pp.status(Args)
-- Declare status options
-- ------------------------------------------------------------
-- NOTE: If you add to status_code, also add to status_called and status_letters!!
-- Or functionality will be compromised
-- ------------------------------------------------------------
local status_code, status_called = {}
status_code = { E='Eliminated from playoff contention', P='Clinched Presidents Trophy',
X='Clinched playoff spot', Y='Clinched division', Z='Clinched conference'}
status_called = {E=false, P=false, X=false, Y=false, Z=false}
local status_letters = 'EPXYZ'
local matches_text = mw.text.trim(frame.args.matches_text or 'games')
-- Status position (before or after read and default)
if string.lower(update)=='complete' then
local stat_pos_val = Args['status_pos'] or ''
table.insert(t_footer,'Final standings.'..tableHeaderInfo.source..'')
local status_position = 'before' -- Default ___location
elseif update=='' then
stat_pos_val = string.lower(stat_pos_val)
-- Empty
if stat_pos_val=='before' then
table.insert(t_footer,'Source'..tableHeaderInfo.source..'')
status_position = 'before'
elseif stat_pos_valupdate=='afterfuture' then
-- Future start date
status_position = 'after'
table.insert(t_footer,'First '..matches_text..' will be played on '..start_date..'. ')
else
table.insert(t_footer,'Updated to '..matches_text..' played on '..update..'.'..tableHeaderInfo.source..'')
end
return table.concat(outputBuffer), table.concat(t_footer)
return {code=status_code, called=status_called, letters=status_letters, position=status_position}
 
end
end -- function me.generateStandingsTable()
 
function me.generateStandingsTable_fromTemplate(frame)
return me.generateStandingsTable(frame:getParent())
end -- function me.generateStandingsTable_fromTemplate()
 
return ppme