Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/McVahl/sometest
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- 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 (' <b>('..status..')</b>') 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
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Tl
(
edit
)
Module:Sandbox/McVahl/sometest/doc
(
edit
)