Module:Sandbox/B2project/NHL Standings: Difference between revisions

Content deleted Content added
No edit summary
Undid revision 724794965 by B2project (talk)
Line 120:
} -- readTeamInfo object
 
local ppgenerateTableHeader = {}
default = function(tableHeaderInfo)
return
'{| class="wikitable" width="515em" style="text-align:center;"\
! width="50%" |' .. tableHeaderInfo.navbarText .. '[[' .. tableHeaderInfo.divisionLink
.. '|' .. tableHeaderInfo.division .. ']]\
! width="7%" | [[Win (baseball)|W]]\
! width="7%" | [[Loss (baseball)|L]]\
! width="9%" | [[Winning percentage|Pct.]]\
! width="7%" | [[Games behind|GB]]\
! width="10%" | [[Home (sports)|Home]]\
! width="10%" | [[Road (sports)|Road]]\
'
end, -- function generateTableHeader.default()
 
winLossOnly = function(tableHeaderInfo)
function pp.header(t,Args,p_sub,pos_label,group_col,VTE_text,full_table,results_header_txt)
return
-- Load relevant modules
'{| class="wikitable" width="380em" style="text-align:center;"\
local yesno = require('Module:Yesno')
! width="66%" | ' .. tableHeaderInfo.navbarText .. tableHeaderInfo.division .. '\
! width="10%" | [[Win (baseball)|W]]\
-- Create table header
! width="10%" | [[Loss (baseball)|L]]\
-- Pre stuff
! width="14%" | [[Winning percentage|Pct.]]\
local team_width = Args['teamwidth'] or '190'
'
local sort_text = ''
end, -- function generateTableHeader.winLossOnlyNoNavBar()
local sort_table_val = Args['sortable_table'] or 'no'
 
if yesno(sort_table_val) then sort_text = 'sortable' end
wildCard2012 = function(tableHeaderInfo)
table.insert(t,'{|class="wikitable '..sort_text..'" style="text-align:center;"\n') -- Open table
return
'{| class="wikitable" width="375em" style="text-align:center;"\
-- Custom header options
! width="60%" | ' .. tableHeaderInfo.navbarText .. 'Wild Card teams<br><small>(Top 2 qualify for 1-game playoff)</small>\
-- Table header
! width="8%" | [[Win (baseball)|W]]\
local table_header = Args['table_header']
! width="8%" | [[Loss (baseball)|L]]\
if table_header then
! width="12%" | [[Winning percentage|Pct.]]\
table.insert(t,'|+'..table_header..'\n')
! width="12%" | [[Games behind|GB]]\
end
'
--Column headers
end, -- function generateTableHeader.wildCard2012
local pld_head_text = Args['pld_header'] or '<abbr title="Played">Pld</abbr>'
} -- generateTableHeader object
local OTloss_head_text = Args['OTloss_header'] or '<abbr title="Lost in overtime">OTL</abbr>'
local tiebr_head_text = Args['tiebr_header'] or '<abbr title="Tiebreaker">TBR</abbr>'
local group_head_text = Args['group_header'] or '<abbr title="Group">Grp</abbr>'
-- Use points instead of goals for/against
local for_against_style = Args['for_against_style'] or 'goals'
local fa_letter, fa_word_sing, fa_word_plur
-- First convert to lower case if it is a string
for_against_style = string.lower(for_against_style)
if for_against_style=='g' or for_against_style=='goal' or for_against_style=='goals' then
fa_letter = 'G'
fa_word_sing = 'Goal'
fa_word_plur = 'Goals'
elseif for_against_style=='p' or for_against_style=='point' or for_against_style=='points' then
fa_letter = 'P'
fa_word_sing = 'Point'
fa_word_plur = 'Points'
else
fa_letter = 'G'
fa_word_sing = 'Goal'
fa_word_plur = 'Goals'
end
-- Whether to use goal ratio (goal average) instead
local use_ratio_val = Args['use_goal_ratio'] or 'no'
local do_ratio = false
-- True if exist, false otherwise
if yesno(use_ratio_val) then do_ratio = true end
-- Whether to use tiebreak
local use_tiebr_val = Args['use_tiebreak'] or 'yes'
local do_tiebr = false
if yesno(use_tiebr_val) then do_tiebr = true end
-- Ties and OTL
local use_tieOTL_val = Args['use_ties'] or 'no'
local do_ties = false
if yesno(use_tieOTL_val) then do_ties = true end
-- Initialize
local tt = {}
tt.count = 0 -- Up by one after every call
tt.tab_text = t -- Actual text
-- Actual headers
tt = p_sub.colhead(tt,32,pos_label) -- Position col
-- Add group header
if full_table and group_col then
tt = p_sub.colhead(tt,32,group_head_text) -- Group/division col
end
tt = p_sub.colhead(tt,team_width,'Team'..VTE_text) -- Team col
tt = p_sub.colhead(tt,32,pld_head_text) -- Matches played col
if full_table then
tt = p_sub.colhead(tt,32,'<abbr title="Won">W</abbr>') -- Win col
tt = p_sub.colhead(tt,32,'<abbr title="Lost">L</abbr>') -- Loss col
if do_ties then
tt = p_sub.colhead(tt,32,'<abbr title="Ties">T</abbr>') -- Ties
end
tt = p_sub.colhead(tt,32,OTloss_head_text)
if do_tiebr then
tt = p_sub.colhead(tt,32,tiebr_head_text)
end
tt = p_sub.colhead(tt,32,'<abbr title="'..fa_word_plur..' for">'..fa_letter..'F</abbr>') -- For col
tt = p_sub.colhead(tt,32,'<abbr title="'..fa_word_plur..' against">'..fa_letter..'A</abbr>') -- Against col
if not do_ratio then
tt = p_sub.colhead(tt,32,'<abbr title="'..fa_word_sing..' difference">'..fa_letter..'D</abbr>') -- Difference col
else
tt = p_sub.colhead(tt,36,'<abbr title="'..fa_word_sing..' ratio">'..fa_letter..'R</abbr>') -- Ratio col
end
end
tt = p_sub.colhead(tt,32,'<abbr title="Points">Pts</abbr>') -- Points col
if full_table then
tt.count = tt.count+1
table.insert(tt.tab_text,results_header_txt)
end
return tt
end
 
local generateTeamRow = {