Module:NBA team standings: Difference between revisions

Content deleted Content added
No edit summary
Changed: – → ‍–‍ for home & road records to prevent line breaks
 
(15 intermediate revisions by 3 users not shown)
Line 17:
 
local highlight = "#CCFFCC"
local divleadermarksplitcolor = "*CCCCCC"
local divleadermark = " *"
 
local function get_division(division)
Line 43 ⟶ 44:
 
local function winpct(w, l)
local pct = '–'
if (w + l) > 0 then
returnpct = rnd(w / (w + l), 3):gsub('^0', '')
end
return '–'pct
end
 
Line 65 ⟶ 67:
local division = args['division']:lower()
-- division leader record
local dloffset = 8*((tonumber(args[division .. 'leader']) or 1) - 1)
local dlhw = tonumber(args[dloffset + 3])
local dlhl = tonumber(args[dloffset + 4])
Line 108 ⟶ 110:
if divname == division then
local rowcolor = nil
if teamabbr == args['team'] then
rowcolor = highlight
end
row = root:tag('tr'):css('background-color', rowcolor)
-- team name
row:tag('td'):css('text-align', 'left'):wikitext(team)
-- wins
row:tag('td'):wikitext(hw + rw)
Line 121 ⟶ 123:
row:tag('td'):wikitext(winpct(hw + rw, hl + rl))
-- gb
row:tag('td'):wikitext(gbformat(hw, hl, rw, rl, dlhw, dlhl, dlrw, dlrwdlrl))
-- home record
row:tag('td'):wikitext(hw .. '‍–‍' .. hl)
-- road record
row:tag('td'):wikitext(rw .. '‍–‍' .. rl)
-- div record
row:tag('td'):wikitext(divrecord)
Line 169 ⟶ 171:
-- rows
local pos = 1
local div1leader = tonumber(args[(args['div1name'] or args['div1name']):lower() .. 'leader'])
local div2leader = tonumber(args[(args['div2name'] or args['div2name']):lower() .. 'leader'])
local div3leader = tonumber(args[(args['div3name'] or args['div3name']):lower() .. 'leader'])
while args[(pos - 1)*8 + 1] or args[(pos - 1)*8 + 2] do
local offset = (pos - 1)*8
Line 187 ⟶ 189:
end
local rowcolor = nil
if teamabbr == args['team'] then
rowcolor = highlight
end
Line 194 ⟶ 196:
row:tag('th'):wikitext(pos)
-- team name
row:tag('td'):css('text-align', 'left'):wikitext(team)
-- wins
row:tag('td'):wikitext(hw + rw)
Line 202 ⟶ 204:
row:tag('td'):wikitext(winpct(hw + rw, hl + rl))
-- gb
row:tag('td'):wikitext(gbformat(hw, hl, rw, rl, clhw, clhl, clrw, clrwclrl))
-- played
row:tag('td'):wikitext(hw + hl + rw + rl)
if args['split' .. pos] then
root:tag('tr'):css('background-color', splitcolor):tag('td'):attr('colspan', 7)
end
pos = pos + 1
end