Module:Sport career

Уикипедия — ашық энциклопедиясынан алынған мәлімет
Навигацияға өту Іздеуге өту

Бұл модульдің құжаттамасын Module:Sport career/doc бетінде бастай аласыз

local p={}

local currentTemplate = '<abbr title="қазіргі кез" class="nowrap">қ.&thinsp;к.</abbr>'
local spacesTemplate = '<span style="visibility:hidden;">0000</span>'
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, "'''", "")
	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