Module:Sports table/WDL: Difference between revisions

Content deleted Content added
Undid revision 967676631 by Frietjes (talk) (moving to main)
optional digitpad for 1993 Football League First Division play-off Final, should do nothing if not specified
Line 206:
return tt
end
 
-- Numeric alignment
local function num_align(num, digits)
if tonumber(digits) and tonumber(num) then
local n = tonumber(num)
digits = tonumber(digits)
if digits == 1 then
if n >= 0 and n < 10 then
return '<span style="visibility:hidden;color:transparent;">0</span>' .. num
end
elseif digits == 2 then
if n >= 0 and n < 10 then
return '<span style="visibility:hidden;color:transparent;">00</span>' .. num
elseif n >= 10 and n < 100 then
return '<span style="visibility:hidden;color:transparent;">0</span>' .. num
end
end
end
return num
end
 
Line 214 ⟶ 234:
local mm = require('Module:Math')
local yesno = require('Module:Yesno')
 
-- Get custom/default options for in table
local show_win = yesno(Args['show_win'] or 'yes')
Line 223 ⟶ 243:
local loss_points = tonumber(Args['losspoints']) or (show_draw and 0 or 1)
local rw_points = tonumber(Args['rwpoints']) or 1
local digits = Args['digitpad']
-- Order of draws and losses --
Line 313 ⟶ 334:
-- Formatting with signs
if gcomp>0 then
gcomp='+'..num_align(gcomp,digits)
elseif gcomp < 0 then
gcomp='&minus;'..-num_align(gcomp,digits)
end
end
Line 337 ⟶ 358:
if GB_num >0 then
-- Indicates trailing GB_team
GB_text = num_align(GB_num,digits)
elseif GB_num == 0 then
-- Equal, do nothing to get dash
else
-- Ahead of GB team, should be noted by plus (instead of minus that comes from formula)
GB_text = '+'..num_align(-GB_num,digits)
end
end
Line 406 ⟶ 427:
-- Add &minus; for negative point totals
if points<0 then
table.insert(t,'| style="font-weight: bold;'..bg_col..'" | &minus;'..num_align(-points,digits)..hth_string..'\n')
else
table.insert(t,'| style="font-weight: bold;'..bg_col..'" | '..num_align(points,digits)..hth_string..'\n')
end
end
Line 432 ⟶ 453:
end
if show_win then
table.insert(t,'| style="'..win_fw..bg_col..'" |'..num_align(wins,digits)..win_string..'\n') -- Won
end
if loss_first then
if show_loss then
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..num_align(losses,digits)..'\n') -- Lost
end
if show_draw then
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..num_align(draws,digits)..'\n') -- Drawn
end
else
if show_draw then
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..num_align(draws,digits)..'\n') -- Drawn
end
if show_loss then
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..num_align(losses,digits)..'\n') -- Lost
end
end
Line 458 ⟶ 479:
if not hide_for_against then
if not yesno(Args['hide_for_against_columns'] or 'no') then
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..num_align(gfor,digits)..'\n') -- GF
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..num_align(gaig,digits)..'\n') -- GA
end
if gcomp then
Line 472 ⟶ 493:
if show_bonus_points then
if s_pts < 0 then
table.insert(t,'| style="'..bg_col..'" | &minus;'..num_align(-s_pts,digits)..'\n')
else
table.insert(t,'| style="'..bg_col..'" | '..num_align(s_pts,digits)..'\n')
end
end
Line 481 ⟶ 502:
-- Add &minus; for negative point totals
if points<0 then
table.insert(t,'| style="font-weight: bold;'..bg_col..'" | &minus;'..num_align(-points,digits)..hth_string..'\n')
else
table.insert(t,'| style="font-weight: bold;'..bg_col..'" | '..num_align(points,digits)..hth_string..'\n')
end
end