Module:Sandbox/McVahl/sometest

-- Module to build tables for basketball roster statistics -- See documentation for details

local p = {}

local function get_header(rtable, row)

end

local function isHigh(args, mm, ptr, j, limit, col) local tocheck = tonumber(args[ptr] or 0) local nums = {} for i = 2, limit, col do		table.insert(nums, tonumber(args[i + j] or 0)) end return mm._max(nums) == tocheck end

-- Main function function p.main(frame) local getArgs = require('Module:Arguments').getArgs local mMath = require('Module:Math') local mColorp = require('Module:Sports color') local mColorc = require('Module:College color') local yesno = require('Module:Yesno') local args = getArgs(frame, { parentFirst = true }) local show_pos = yesno(args['show_pos'] or 'y') local limit = 300 local col = show_pos and 10 or 9 local color1, color2 if not args[1] then frame.args[1] = args['team'] end if mColorp.check(frame) == 'known' then color1 = mColorp.colorcell(frame) color2 = mColorp.colorcell2(frame) elseif mColorc.check(frame) == 'known' then color1 = mColorc.header1(frame) color2 = mColorc.header2(frame) end local rtable = mw.html.create

rtable = rtable:tag('table') :addClass('wikitable') :addClass('sortable') :css('text-align', 'right') local row = rtable:tag('tr') row:tag('th'):attr('style', color1):attr('scope', 'col'):wikitext('Player') if show_pos then row:tag('th'):attr('style', color1):attr('scope', 'col'):wikitext('Pos') end row:tag('th'):attr('style', color1):attr('scope', 'col'):wikitext('GP') row:tag('th'):attr('style', color1):attr('scope', 'col'):wikitext('GS') row:tag('th'):attr('style', color1):attr('scope', 'col'):wikitext('MP') row:tag('th'):attr('style', color1):attr('scope', 'col'):wikitext('Reb') row:tag('th'):attr('style', color1):attr('scope', 'col'):wikitext('Ast') row:tag('th'):attr('style', color1):attr('scope', 'col'):wikitext('Stl') row:tag('th'):attr('style', color1):attr('scope', 'col'):wikitext('Blk') row:tag('th'):attr('style', color1):attr('scope', 'col'):wikitext('Pts') for i = 2, limit, col do		if not args[i] then break end local data = {} local status = args['status'.. (i + col - 2) / col] for j = 0, (col - 1) do			local ptr = i + j			data[j + 1] = { value = args[ptr] or 0, highest = isHigh(args, mMath, ptr, j, limit, col) } end row = rtable:tag('tr') row:tag('td') :css('white-space', 'nowrap') :css('text-align', 'left') :wikitext(data[1].value .. (status and (' ('..status..')') or '')) for k=2, #data do			row:tag('td') :attr('style', data[k].highest and color2 or nil) :wikitext(data[k].value) -- if show_pos and k == 2 then row:css('text-align', 'center')	end -- row:wikitext(data[k]) end end return tostring(rtable) end

return p