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

Content deleted Content added
No edit summary
No edit summary
 
(16 intermediate revisions by the same user not shown)
Line 5:
 
local nhlData
 
local function firstnonblank(s1,s2)
if ( s1 and s1:match( '^%s*(.-)%s*$' ) ~= '' ) then
return s1
elseif ( s2 and s2:match( '^%s*(.-)%s*$' ) ~= '' ) then
return s2
end
return nil
end
 
-- if mw.loadData() not supported, use require() instead
Line 231 ⟶ 222:
return
'{| class="wikitable sortable" width="" style="text-align:center;"\
|+ [[' .. tableHeaderInfo.divisionLink.. '|' .. tableHeaderInfo.division .. ']]' ..tableHeaderInfo.source.. '\
! width=32 | <abbr title="Position">Pos</abbr>\
! width=190 | Team ' .. tableHeaderInfo.navbarText .. '\
Line 437 ⟶ 428:
local divisionLink = mw.text.trim(frame.args.division_link or division)
local source = mw.text.trim(frame.args.source or '')
local Args = frame.args
-- local Pargs = frame:getParent().args
local team_list = {}
local jj, jjj
local yesno = require('Module:Yesno')
local p_style = require('Module:Sandbox/B2project/Style')
local t_status = p_style.status(frame.args)
 
local statusInfo = {}
Line 507 ⟶ 491:
standingsPage,
mini = 1,
style = 'float:leftright;',
})
Line 568 ⟶ 552:
local matches_text = mw.text.trim(frame.args.matches_text or 'games')
if string.lower(update)=='complete' then
table.insert(t_footer,'Final standings.'..tableHeaderInfo.source..'')
elseif update=='' then
-- Empty
Line 577 ⟶ 561:
else
table.insert(t_footer,'Updated to '..matches_text..' played on '..update..'.'..tableHeaderInfo.source..'')
end
-- Stack footer or not
local stack_footer_val = firstnonblank(frame:getParent().args[stack_footer], Args[stack_footer]) or 'no'
local footer_break = false
if yesno(stack_footer_val) then footer_break = true end
-- Variable for linebreak
local stack_string = '<br>'
if footer_break and (not (string.lower(update)=='complete')) then table.insert(t_footer,stack_string) end
local status_exist = false
local status_string = ''
local curr_letter
for jjj = 1,mw.ustring.len(t_status.letters) do
curr_letter = mw.ustring.upper(mw.ustring.sub(t_status.letters,jjj,jjj))
if t_status.called[curr_letter] then
if (footer_break and status_exist) then
status_string = status_string..stack_string
end
if t_status.position == 'before' then
status_string = status_string..'<span style="font-weight:bold">'..string.lower(curr_letter)..' &ndash;</span> '..t_status.code[curr_letter]..'; '
else
status_string = status_string..'<span style="font-weight:bold">('..curr_letter..')</span> '..t_status.code[curr_letter]..'; '
end
status_exist = true
end
end
-- Now end it with a point instead (if it contains entries the '; ' needs to be removed)
if status_exist then
status_string = '<br>'..mw.ustring.sub(status_string,1,mw.ustring.len(status_string)-2)..'.'
table.insert(t_footer,status_string)
end