モジュール:Sports career
モジュールの解説[作成]
local p = {}
local function isnotempty(s)
return s and s:match('%S')
end
function p.main(frame)
local player = {}
local coach = {}
local executive = {}
local pargs = frame:getParent().args
local tracking = ''
local iargs = {}
local pmax = tonumber(frame.args['pmax'] or '40') or 40
local cmax = tonumber(frame.args['cmax'] or '30') or 30
local emax = tonumber(frame.args['emax'] or '30') or 30
for k,v in pairs(pargs) do
if type(k) == 'string' and isnotempty(v) then
if k:match('^team%d%d*$') then
local num = mw.ustring.gsub(k,'^team(%d%d*)$','%1')
table.insert(player, {tonumber(num) or 0, pargs['years' .. num] or '', v})
elseif k:match('^cteam%d%d*$') then
local num = mw.ustring.gsub(k,'^cteam(%d%d*)$','%1')
table.insert(coach, {tonumber(num) or 0, pargs['cyears' .. num] or '', v})
elseif k:match('^所属%d%d*$') then
local num = mw.ustring.gsub(k,'^所属(%d%d*)$','%1')
table.insert(player, {tonumber(num) or 0, pargs['所属年' .. num] or '', v})
elseif k:match('^監督%d%d*$') then
local num = mw.ustring.gsub(k,'^監督(%d%d*)$','%1')
table.insert(coach, {tonumber(num) or 0, pargs['監督年' .. num] or '', v})
elseif k:match('^E所属%d%d*$') then
local num = mw.ustring.gsub(k,'^E所属(%d%d*)$','%1')
table.insert(executive, {tonumber(num) or 0, pargs['E所属年' .. num] or '', v})
end
end
end
table.sort(player, function (a, b) return a[1] < b[1] end)
table.sort(coach, function (a, b) return a[1] < b[1] end)
table.sort(executive, function (a, b) return a[1] < b[1] end)
local i = 1
if #player > 0 then
iargs['header' .. i] = frame.args['pheader'] or '選手経歴:'
i = i + 1
for k,v in ipairs(player) do
if v[2] ~= '' then iargs['label' .. i] = v[2] end
if v[3] ~= '' then iargs['data' .. i] = v[3] end
i = i + 1
end
end
if #coach > 0 then
iargs['header' .. i] = frame.args['cheader'] or '指導者経歴:'
i = i + 1
for k,v in ipairs(coach) do
if v[2] ~= '' then iargs['label' .. i] = v[2] end
if v[3] ~= '' then iargs['data' .. i] = v[3] end
i = i + 1
end
end
if #executive > 0 then
iargs['header' .. i] = frame.args['eheader'] or 'エグゼクティブ経歴:'
i = i + 1
for k,v in ipairs(executive) do
if v[2] ~= '' then iargs['label' .. i] = v[2] end
if v[3] ~= '' then iargs['data' .. i] = v[3] end
i = i + 1
end
end
if i > 1 then
iargs['child'] = 'yes'
iargs['labelstyle'] = 'font-weight: normal;' .. (frame.args['yearstyle'] 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 '')
if #player > pmax then
tracking = tracking .. (frame.args['pmaxcat'] or '')
end
if #coach > cmax then
tracking = tracking .. (frame.args['cmaxcat'] or '')
end
if #executive > emax then
tracking = tracking .. (frame.args['emaxcat'] or '')
end
return (frame.args['title'] or 'プロチーム所属歴') .. require('Module:Infobox').infobox(iargs) .. tracking
end
return tracking
end
return p
|
Index:
pl ar de en es fr it arz nl ja pt ceb sv uk vi war zh ru af ast az bg zh-min-nan bn be ca cs cy da et el eo eu fa gl ko hi hr id he ka la lv lt hu mk ms min no nn ce uz kk ro simple sk sl sr sh fi ta tt th tg azb tr ur zh-yue hy my ace als am an hyw ban bjn map-bms ba be-tarask bcl bpy bar bs br cv nv eml hif fo fy ga gd gu hak ha hsb io ig ilo ia ie os is jv kn ht ku ckb ky mrj lb lij li lmo mai mg ml zh-classical mr xmf mzn cdo mn nap new ne frr oc mhr or as pa pnb ps pms nds crh qu sa sah sco sq scn si sd szl su sw tl shn te bug vec vo wa wuu yi yo diq bat-smg zu lad kbd ang smn ab roa-rup frp arc gn av ay bh bi bo bxr cbk-zam co za dag ary se pdc dv dsb myv ext fur gv gag inh ki glk gan guw xal haw rw kbp pam csb kw km kv koi kg gom ks gcr lo lbe ltg lez nia ln jbo lg mt mi tw mwl mdf mnw nqo fj nah na nds-nl nrm nov om pi pag pap pfl pcd krc kaa ksh rm rue sm sat sc trv stq nso sn cu so srn kab roa-tara tet tpi to chr tum tk tyv udm ug vep fiu-vro vls wo xh zea ty ak bm ch ny ee ff got iu ik kl mad cr pih ami pwn pnt dz rmy rn sg st tn ss ti din chy ts kcg ve
Portal di Ensiklopedia Dunia