Content deleted Content added
Create sandbox version of Module:MLB standings |
add support for "wildCard" value for "output" parameter |
||
Line 86:
'
end, -- function generateTableHeader.wildCard2012
wildCard = function(tableHeaderInfo)
return
'{| class="wikitable" width="375em" style="text-align:center;"\
! width="60%" | ' .. tableHeaderInfo.navbarText .. 'Wild Card teams<br><small>(Top ' .. tableHeaderInfo.wildCardsPerLeague ..
' teams qualify for postseason)</small>\
! width="8%" | [[Win (baseball)|W]]\
! width="8%" | [[Loss (baseball)|L]]\
! width="12%" | [[Winning percentage|Pct.]]\
! width="12%" | [[Games behind|GB]]\
'
end, -- function generateTableHeader.wildCard
} -- generateTableHeader object
Line 117 ⟶ 130:
|| ' .. teamRowInfo.gamesBehind .. '\n'
end, -- function generateTeamRow.wildCard2012
wildCard = function(teamRowInfo, teamInfo)
return
'|-' .. teamRowInfo.rowStyle .. '\
|| ' .. teamRowInfo.seedText .. '[[' .. teamRowInfo.teamSeasonPage .. '|' .. teamInfo.name .. ']]\
|| ' .. teamInfo.wins .. ' || ' .. teamInfo.losses .. '\
|| ' .. teamRowInfo.winningPercentage .. '\
|| ' .. teamRowInfo.gamesBehind .. '\n'
end, -- function generateTeamRow.wildCard
} -- generateTeamRow object
Line 163 ⟶ 185:
end
end -- function parseTeamLinks
local function getWildCardsPerLeagueForYear(year)
if year == '' then
return 0
end
for idx, wildCardInfo in ipairs(mlbData.wildCardInfo) do
if wildCardInfo.startYear <= year and wildCardInfo.endYear >= year then
return wildCardInfo.wildCardsPerLeague;
end
end
-- year not found, thus no wild cards for specified year
return 0;
end -- function getWildCardsPerLeagueForYear
function me.generateStandingsTable(frame)
Line 190 ⟶ 225:
outputFormat = 'wildCard2012'
end
if (outputArg == 'wildCard') then
outputFormat = 'wildCard'
end
end
local year = tonumber(mw.text.trim(frame.args.year or ''))
local division = mw.text.trim(frame.args.division or '')
local divisionLink = mw.text.trim(frame.args.division_link or division)
local wildCardsPerLeague = getWildCardsPerLeagueForYear(year)
local seedInfo = {}
Line 238 ⟶ 277:
division = division,
divisionLink = divisionLink,
wildCardsPerLeague = wildCardsPerLeague,
}
Line 266 ⟶ 306:
local leadingHalfGames = nil;
if (fDisplayGamesBehind) then
local standingsLeaderIdx = 1
if (outputFormat == 'wildCard2012' and #listOfTeams > 1) then
standingsLeaderIdx = 2
end
if (outputFormat == 'wildCard' and #listOfTeams >= wildCardsPerLeague) then
standingsLeaderIdx = wildCardsPerLeague
end
local teamInfo = listOfTeams[standingsLeaderIdx]
leadingHalfGames = (teamInfo.wins - teamInfo.losses)
|