https://en.wikipedia.org/w/index.php?action=history&feed=atom&title=Module%3ASports_career%2Fsandbox
Module:Sports career/sandbox - Revision history
2025-06-13T19:26:57Z
Revision history for this page on the wiki
MediaWiki 1.45.0-wmf.5
https://en.wikipedia.org/w/index.php?title=Module:Sports_career/sandbox&diff=1150240040&oldid=prev
Lemondoge: Create sandbox version of Module:Sports career; simplify regex and improve efficiency slightly
2023-04-17T01:41:02Z
<p>Create sandbox version of <a href="/wiki/Module:Sports_career" title="Module:Sports career">Module:Sports career</a>; simplify regex and improve efficiency slightly</p>
<p><b>New page</b></p><div>local p = {}<br />
<br />
local function isnotempty(s)<br />
return s and s:find('%S')<br />
end<br />
<br />
function p.main(frame)<br />
local player = {}<br />
local coach = {}<br />
local pargs = frame:getParent().args<br />
local tracking = ''<br />
local iargs = {}<br />
local pmax = tonumber(frame.args['pmax'] or 40) or 40<br />
local cmax = tonumber(frame.args['cmax'] or 30) or 30<br />
for k,v in pairs(pargs) do<br />
if type(k) == 'string' and isnotempty(v) then<br />
if k:match('^team%d+$') then<br />
local num = mw.ustring.gsub(k,'^team(%d+)$','%1')<br />
table.insert(player, {tonumber(num) or 0, pargs['years' .. num] or '', v})<br />
elseif k:match('^cteam%d%d*$') then<br />
local num = mw.ustring.gsub(k,'^cteam(%d+)$','%1')<br />
table.insert(coach, {tonumber(num) or 0, pargs['cyears' .. num] or '', v})<br />
end<br />
end<br />
end<br />
<br />
table.sort(player, function (a, b) return a[1] < b[1] end)<br />
table.sort(coach, function (a, b) return a[1] < b[1] end)<br />
<br />
local i = 1<br />
if #player > 0 then<br />
iargs['header' .. i] = frame.args['pheader'] or 'As player:'<br />
i = i + 1<br />
for k,v in ipairs(player) do<br />
if v[2] ~= '' then iargs['label' .. i] = v[2] end<br />
if v[3] ~= '' then iargs['data' .. i] = v[3] end<br />
i = i + 1<br />
end<br />
end<br />
if #coach > 0 then<br />
iargs['header' .. i] = frame.args['cheader'] or 'As coach:'<br />
i = i + 1<br />
for k,v in ipairs(coach) do<br />
if v[2] ~= '' then iargs['label' .. i] = v[2] end<br />
if v[3] ~= '' then iargs['data' .. i] = v[3] end<br />
i = i + 1<br />
end<br />
end<br />
<br />
if i > 1 then<br />
iargs['child'] = 'yes'<br />
iargs['labelstyle'] = 'font-weight: normal;' .. (frame.args['yearstyle'] or '')<br />
iargs['headerstyle'] = 'line-height: 1.2em;text-align: left;' .. (frame.args['headerstyle'] or '')<br />
iargs['datastyle'] = 'line-height: 1.2em;text-align: left;' .. (frame.args['teamstyle'] or '')<br />
if #player > pmax then<br />
tracking = tracking .. (frame.args['pmaxcat'] or '')<br />
end<br />
if #coach > cmax then<br />
tracking = tracking .. (frame.args['cmaxcat'] or '')<br />
end<br />
return (frame.args['title'] or 'Career history') .. require('Module:Infobox').infobox(iargs) .. tracking<br />
end<br />
<br />
return tracking<br />
end<br />
<br />
return p</div>
Lemondoge