Content deleted Content added
add code to tolerate missing parameters |
No edit summary |
||
Line 125:
winLossOnlyNoNavbar = function(tableHeaderInfo)
return
'{| class="wikitable" width="
! width="66%" |' .. tableHeaderInfo.division .. '\
! width="10%" | [[Win (baseball)|W]]\
Line 132:
'
end, -- function generateTableHeader.winLossOnlyNoNavBar()
wildCard2012 = function(tableHeaderInfo)
return
'{| class="wikitable" width="375em" style="text-align:center;"\
! width="60%" |' .. tableHeaderInfo.division .. '\
! width="8%" | [[Win (baseball)|W]]\
! width="8%" | [[Loss (baseball)|L]]\
! width="12%" | [[Winning percentage|Pct.]]\
! width="12%" | [[Games behind|GB]]\
'
end, -- function generateTableHeader.wildCard2012
} -- generateTableHeader object
Line 155 ⟶ 166:
end, -- function generateTeamRow.winLossOnly
wildCard2012 = function(teamRowInfo, teamInfo)
return
'|-' .. teamRowInfo.rowStyle .. '\
|| ' .. teamRowInfo.seedText .. '[[' .. teamRowInfo.teamSeasonPage .. '|' .. teamInfo.name .. ']]\
|| ' .. teamInfo.wins .. ' || ' .. teamInfo.losses .. '\
|| ' .. teamRowInfo.winningPercentage .. '\
|| ' .. teamRowInfo.gamesBehind .. '\n'
end, -- function generateTeamRow.wildCard2012
} -- generateTeamRow object
Line 201 ⟶ 220:
if (outputArg == 'winLossOnlyNoNavbar') then
outputFormat = 'winLossOnlyNoNavbar'
fDisplayNavbar = false
end
if (outputArg == 'wildCard2012') then
outputFormat = 'wildCard2012'
fDisplayNavbar = false
end
Line 261 ⟶ 284:
local leadingHalfGames = nil;
if (outputFormat == 'default' or outputFormat == 'wildCard2012' ) then
local standingsLeaderIdx = 1;
if (outputFormat == 'wildCard2012' and #listOfTeams > 1) then
standingsLeaderIdx = 2;
end
local teamInfo = listOfTeams[standingsLeaderIdx]
end
for idx, teamInfo in ipairs(listOfTeams) do
Line 273 ⟶ 304:
}
if (outputFormat == 'default' or outputFormat == 'wildCard2012' ) then
local halfGamesBehind = leadingHalfGames - (teamInfo.wins - teamInfo.losses)
if (leadingHalfGames == nil) then▼
local
-- if games behind is negative, take the absolute value and prefix a +
-- character
if (halfGamesBehind < 0) then
halfGamesBehind = -halfGamesBehind
prefix = '+'
end
teamRowInfo.gamesBehind = '—'
else
▲ local halfGamesBehind = leadingHalfGames - (teamInfo.wins - teamInfo.losses)
teamRowInfo.gamesBehind = math.floor(halfGamesBehind / 2)
if (halfGamesBehind % 2 == 1) then
teamRowInfo.gamesBehind = '½'
else
teamRowInfo.gamesBehind = teamRowInfo.gamesBehind .. '½'
end
end
teamRowInfo.gamesBehind = prefix .. teamRowInfo.gamesBehind
end
end -- if (outputFormat == 'default')
|