Module:MLB standings: Difference between revisions

Content deleted Content added
fix bug: allow for just one seed to be specified
add support for highlight parameter
Line 103:
end
end -- function parseSeeds()
 
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
 
function me.generateStandingsTable(frame)
Line 116 ⟶ 128:
if (frame.args.seeds ~= nil) then
parseSeeds(frame.args.seeds, seedInfo)
end
 
local teamsToHighlight = {}
if (frame.args.highlight ~= nil) then
parseHighlightArg(frame.args.highlight, teamsToHighlight)
end
 
Line 174 ⟶ 191:
 
local seedText = ''
local seedStylerowStyle = ''
local nameStyle = ''
if (seedInfo[teamInfo.name] ~= nil) then
seedText = '<sup>(' .. seedInfo[teamInfo.name] .. ')</sup> '
seedStylerowStyle = '| style="background:#CCFFCC"'
end
 
if (teamsToHighlight[teamInfo.name] ~= nil) then
rowStyle = ' style="background:#CCFFCC"'
nameStyle = '| style="font-weight:bold" '
end
 
table.insert(outputSeq,
'|-' .. seedStylerowStyle .. '\n' ..
nameStyle .. '| ' .. seedText .. '[[' .. year .. ' ' .. teamInfo.name .. ' season|' .. teamInfo.name .. ']]\
|| ' .. teamInfo.wins .. ' || ' .. teamInfo.losses .. '\
|| ' .. string.format('%.3f', teamInfo.wins / ( teamInfo.wins + teamInfo.losses )) .. '\