Module:Sports table/sub

-- Subfunctions for this module that are called from the style moduleslocal ppp = {}function ppp.colhead(ttt,width,text)-- For individual column headerslocal head_stringif width=='auto' thenhead_string = '! scope="col" |'..text..'\n'elsehead_string = '! scope="col" width='..width..'|'..text..'\n'endttt.count = ttt.count+1table.insert(ttt.tab_text,head_string)return tttendfunction ppp.hth(frame,Args,full_table,hth_id_list,hth_local,notes_exist,team_list,team_code_ii,ii_start,ii_end,rand_val)-- For head-to-head noteslocal hth_string, hth_local_num, hth_id, k, hth_loc = '', nil, nil, nil, nil-- Check whether there is a head-to-head note or not, if so get text ready for it the same way as for the notesif hth_local and full_table then-- Set global check for notes to truenotes_exist = true-- Split the hth_local into a table if all the entries are validlocal multiref = 1local hth_local_table = mw.text.split(hth_local, '%s*,%s*')if (#hth_local_table > 1) thenfor k, hth_loc in ipairs(hth_local_table) domultiref = multiref * (Args['hth_' .. hth_loc] and 1 or 0)endelsemultiref = 0end-- Split failed, so make a single entry table with hth_local insideif multiref < 1 thenhth_local_table = { hth_local }endfor k,hth_loc in ipairs(hth_local_table) doif not Args['hth_'..hth_loc] then-- Option 1-- Now define the identifier for thishth_id = '"table_hth_'..team_code_ii..rand_val..'"' -- Add random end for unique ID if more tables are present on article (which might otherwise share an ID)hth_id_list[team_code_ii] = hth_id-- Call refn templatehth_string = hth_string .. frame:expandTemplate{ title = 'efn', args = { group='lower-alpha',  name=hth_id, hth_loc} }else -- Option 2hth_local_num = team_list[hth_loc] or -1if hth_id_list[hth_loc] or ((hth_local_num >= ii_start) and (hth_local_num <= ii_end)) then-- Option 2ahth_id = '"table_hth_'..hth_loc..rand_val..'"'hth_string = hth_string .. frame:extensionTag{ name = 'ref', args = { group = 'lower-alpha', name = hth_id} }else-- Option 2bhth_id = '"table_hth_'..hth_loc..rand_val..'"' -- Add random end for unique IDhth_id_list[hth_loc] = hth_id-- Call refn templatehth_string = hth_string .. frame:expandTemplate{ title = 'efn', args = { group='lower-alpha',  name=hth_id, Args['hth_'..hth_loc]} }endendendendreturn {str=hth_string, list=hth_id_list, notes_exist=notes_exist}endfunction ppp.status(Args, status_code)-- Declare status options-- -------------------------------------------------------------- NOTE: If you add to status_code, also add to status_called and status_letters!!-- Or functionality will be compromised-- ------------------------------------------------------------local status_called = {}local status_letters = (Args['status_order'] or '') .. 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'if type(status_code) ~= 'table' then status_code = {} endif #status_code < 1 thenstatus_code = {A='Advance to a further round', C='Champion', D='Disqualified', E='Eliminated', G='Guest', H='Host', O='Play-off winner', P='Promoted', Q='Qualified to the phase indicated',R='Relegated', T='Qualified, but not yet to the particular phase indicated'}end-- Status position (before or after read and default)local stat_pos_val = string.lower(Args['status_pos'] or '')local status_position = 'after' -- Default locationif stat_pos_val=='before' thenstatus_position = 'before'elseif stat_pos_val=='after' thenstatus_position = 'after'end-- Read in custom status optionsfor l in mw.text.gsplit(status_letters, '') dostatus_called[l] = falsestatus_code[l] = status_code[l] or '?'status_letters = mw.ustring.gsub(status_letters, '(' .. l ..'.-)' .. l, '%1')if Args['status_text_' .. l] thenstatus_code[l] = Args['status_text_' .. l]end endreturn {code=status_code, called=status_called, letters=status_letters, position=status_position}endreturn ppp