Module:Sports career and Module:Sports career/sandbox: Difference between pages
Appearance
(Difference between pages)
Content deleted Content added
Undid revision 1257160477 by Frietjes (talk) seems still useful, adding back |
Create sandbox version of Module:Sports career; simplify regex and improve efficiency slightly |
||
Line 2: | Line 2: | ||
local function isnotempty(s) |
local function isnotempty(s) |
||
return s and s: |
return s and s:find('%S') |
||
end |
end |
||
Line 11: | Line 11: | ||
local tracking = '' |
local tracking = '' |
||
local iargs = {} |
local iargs = {} |
||
local pmax = tonumber(frame.args['pmax'] or |
local pmax = tonumber(frame.args['pmax'] or 40) or 40 |
||
local cmax = tonumber(frame.args['cmax'] or |
local cmax = tonumber(frame.args['cmax'] or 30) or 30 |
||
for k,v in pairs(pargs) do |
for k,v in pairs(pargs) do |
||
if type(k) == 'string' and isnotempty(v) then |
if type(k) == 'string' and isnotempty(v) then |
||
Line 18: | Line 18: | ||
local num = mw.ustring.gsub(k,'^team(%d+)$','%1') |
local num = mw.ustring.gsub(k,'^team(%d+)$','%1') |
||
table.insert(player, {tonumber(num) or 0, pargs['years' .. num] or '', v}) |
table.insert(player, {tonumber(num) or 0, pargs['years' .. num] or '', v}) |
||
elseif k:match('^cteam%d |
elseif k:match('^cteam%d%d*$') then |
||
local num = mw.ustring.gsub(k,'^cteam(%d+)$','%1') |
local num = mw.ustring.gsub(k,'^cteam(%d+)$','%1') |
||
table.insert(coach, {tonumber(num) or 0, pargs['cyears' .. num] or '', v}) |
table.insert(coach, {tonumber(num) or 0, pargs['cyears' .. num] or '', v}) |
||
Line 50: | Line 50: | ||
if i > 1 then |
if i > 1 then |
||
iargs['child'] = 'yes' |
iargs['child'] = 'yes' |
||
iargs['labelstyle'] = 'font-weight: normal |
iargs['labelstyle'] = 'font-weight: normal;' .. (frame.args['yearstyle'] or '') |
||
iargs['headerstyle'] = 'line-height: 1.2em;text-align: left;' .. (frame.args['headerstyle'] or '') |
iargs['headerstyle'] = 'line-height: 1.2em;text-align: left;' .. (frame.args['headerstyle'] or '') |
||
iargs['datastyle'] = 'line-height: 1.2em;text-align: left;' .. (frame.args['teamstyle'] or '') |
iargs['datastyle'] = 'line-height: 1.2em;text-align: left;' .. (frame.args['teamstyle'] or '') |