Module:MLB standings: Difference between revisions

Content deleted Content added
more support for single wild card team in text for table header
remove fixed table width; adjust column percentages; move table title to table caption
Line 54:
default = function(tableHeaderInfo)
return
'{| class="wikitable" width="535em" style="text-align:center;"\
!|+ width="50%" |' .. tableHeaderInfo.navbarText .. '[[' .. tableHeaderInfo.divisionLink
.. '|' .. tableHeaderInfo.division .. ']]\
|- \
! width="7%" | [[Win (baseball)|W]]\
! width="751%" | [[LossTeam (baseball)|L]]\
! width="76%" | [[Win (baseball)|W]]\
! width="6%" | [[Loss (baseball)|L]]\
! width="9%" | [[Winning percentage|Pct.]]\
! width="78%" | [[Games behind|GB]]\
! width="10%" | [[Home (sports)|Home]]\
! width="10%" | [[Road (sports)|Road]]\
Line 68 ⟶ 70:
winLossOnly = function(tableHeaderInfo)
return
'{| class="wikitable" width="390em" style="text-align:center;"\
! width="66%" |+ ' .. tableHeaderInfo.navbarText .. tableHeaderInfo.division .. '\
|- \
! width="66%" | Team\
! width="10%" | [[Win (baseball)|W]]\
! width="10%" | [[Loss (baseball)|L]]\
Line 78 ⟶ 82:
wildCard2012 = function(tableHeaderInfo)
return
'{| class="wikitable" width="390em" style="text-align:center;"\
! width="60%" |+ ' .. tableHeaderInfo.navbarText .. 'Wild Card teams<br><small>(Top 2 teams qualify for postseason)</small>\
|- \
! width="64%" | Team \
! width="8%" | [[Win (baseball)|W]]\
! width="8%" | [[Loss (baseball)|L]]\
! width="1210%" | [[Winning percentage|Pct.]]\
! width="1210%" | [[Games behind|GB]]\
'
end, -- function generateTableHeader.wildCard2012
Line 95 ⟶ 101:
end
return
'{| class="wikitable" width="390em" style="text-align:center;"\
! width="60%" |+ ' .. tableHeaderInfo.navbarText .. 'Wild Card ' .. teamText .. '<br><small>(Top ' .. numberOfTeamsText ..
' for postseason)</small>\
|- \
! width="64%" | Team \
! width="8%" | [[Win (baseball)|W]]\
! width="8%" | [[Loss (baseball)|L]]\
! width="1210%" | [[Winning percentage|Pct.]]\
! width="1210%" | [[Games behind|GB]]\
'
end, -- function generateTableHeader.wildCard
Line 115 ⟶ 123:
|| ' .. teamRowInfo.winningPercentage .. '\
|| ' .. teamRowInfo.gamesBehind .. '\
|| ' .. teamInfo.homeWins .. '&zwj;&zwj;' .. teamInfo.homeLosses ..'\
|| ' .. teamInfo.roadWins .. '&zwj;&zwj;' .. teamInfo.roadLosses .. '\n'
 
end, -- function generateTeamRow.default()
Line 325 ⟶ 333:
 
for idx, teamInfo in ipairs(listOfTeams) do
local winningPercentage = string.format(
'%.3f', teamInfo.wins / ( teamInfo.wins + teamInfo.losses )
),
winningPercentage = string.gsub(winningPercentage, '^0', '')
local teamRowInfo = {
teamSeasonPage = year .. ' ' .. teamInfo.teamLink .. ' season',
winningPercentage = string.format(winningPercentage,
'%.3f', teamInfo.wins / ( teamInfo.wins + teamInfo.losses )
),
gamesBehind = '',
seedText = '',
Line 362 ⟶ 372:
 
if (seedInfo[teamInfo.name] ~= nil) then
teamRowInfo.seedText = '<sup>(' .. seedInfo[teamInfo.name] .. ')</sup> &nbsp;'
teamRowInfo.rowStyle = ' style="background:#CCFFCC"'
end