Mine sisu juurde

Modul':Sports career

Мегавики-späi

local p={}

local currentTemplate = 'н. в.' local spacesTemplate = '0000' local yearFormat = '[12]%d?[%d?][%d?]'

function formatRow(row, mode, years, club, scores) years = years and mw.text.trim(years) or club = club and mw.text.trim(club) or scores = scores and mw.text.trim(scores) or

if years ~= then years = mw.ustring.gsub(years, ' *[—-] *', '—') years = mw.ustring.gsub(years, 'н\. *в\.', currentTemplate) local unboldYears = mw.ustring.gsub(years, "", "") if not mw.ustring.find(unboldYears, '^' .. yearFormat .. '$') and not mw.ustring.find(unboldYears, '^' .. yearFormat .. '—' .. yearFormat .. '$') and not mw.ustring.find(unboldYears, '^' .. yearFormat .. '—' .. currentTemplate .. '$') and not mw.ustring.find(unboldYears, '^' .. spacesTemplate .. '—' .. yearFormat .. '$') then years = '' .. years .. 'Категория:Википедия:Шаблон:Спортивная карьера:Проверить дату' end end if scores ~= and mw.ustring.len(mw.text.trim(scores)) > 16 and not mw.ustring.find(scores, 'comment') and not mw.ustring.find(scores, 'ref') then scores = '' .. scores .. 'Категория:Википедия:Шаблон:Спортивная карьера:Проверить очки' end

if years ~= or club ~= then local class = if mode == 3 then class = (row % 2 == 0) and ' even' or ' odd' end if scores ~= then return '|- class="nowrap' .. class .. '"\n| ' .. years .. '\n| ' .. club .. '\n| ' .. scores .. '\n' else return '|- class="nowrap' .. class .. '"\n| ' .. years .. '\n| colspan="2" |' .. club .. '\n' end else return end end

function p.main(frame) local args = frame:getParent().args local mode = (frame.args.mode == '2') and 2 or 3 local result =

local params = {} local row = 1 for key, param in pairs(args) do if tonumber(key) then table.insert(params, param) if key % mode == 0 then result = result .. formatRow(row, mode, unpack(params)) params = {} row = row+1 end end end if #params > 0 then result = result .. formatRow(row, mode, unpack(params)) end

if result == then return else return result end end

return p