Pojdi na vsebino

Modul:Infobox cyclist tracking

Iz Wikipedije, proste enciklopedije
Redakcija dne 14:16, 23. december 2014 od Pinky sl (pogovor | prispevki) (Nova stran z vsebino: local p = {} function p.tracking(frame) function isblank( val ) return (val == nil) or val:match('^[%s]*$') end local function isnotblank(s) return s a...)
(razl) ← Starejša redakcija | prikaži trenutno redakcijo (razl) | Novejša redakcija → (razl)
local p = {}
 
function p.tracking(frame)
    function isblank( val ) 
        return (val == nil) or val:match('^[%s]*$')
    end
	local function isnotblank(s)
		return s and s:match( '^%s*(.-)%s*$' ) ~= ''
	end
 
    local cats = ''
    local args = frame:getParent().args
    
    local hasbr = 0
    local hasnewline = 0
    local toohighnumber = 0
    local missingyears = {0, 0, 0}
    local missingteams = {0, 0, 0}
    local hasyears = {0, 0, 0}
    local hasteams = {0, 0, 0}
    
    local prefixes = {'pro', 'amateur', 'manage'}
    local maxindices = {25, 15, 15}
    for k=1,3 do
		local prefix = prefixes[k]
		local maxindex = maxindices[k]
		if (isnotblank(args[prefix .. 'years']) ) then hasyears[k] = 1 end
		if (isnotblank(args[prefix .. 'years']) and isblank(args[prefix .. 'teams']) ) then
			missingteams[k] = 1
		end
		if (isnotblank(args[prefix .. 'teams']) ) then hasteams[k] = 1 end
		if (isnotblank(args[prefix .. 'teams']) and isblank(args[prefix .. 'years']) ) then
			missingyears[k] = 1
		end
		if (args[prefix .. 'years'] or ''):match('<[\t ]*[Bb]') then
			hasbr = 1
		end
		if (args[prefix .. 'teams'] or ''):match('<[\t ]*[Bb]') then
			hasbr = 1
		end
		if (args[prefix .. 'years'] or ''):match('[\r\n]') then
			hasnewline = 1
		end
		if (args[prefix .. 'teams'] or ''):match('[\r\n]') then
			hasnewline = 1
		end
		for i = 1,maxindex do
			if (isnotblank(args[prefix .. 'years'.. tostring(i)]) ) then hasyears[k] = 1 end
			if (isnotblank(args[prefix .. 'years'.. tostring(i)]) and isblank(args[prefix .. 'team'.. tostring(i)]) ) then
				missingteams[k] = 1
			end
			if (isnotblank(args[prefix .. 'team'.. tostring(i)]) ) then hasteams[k] = 1 end
			if (isnotblank(args[prefix .. 'team'.. tostring(i)]) and isblank(args[prefix .. 'years'.. tostring(i)]) ) then
				missingyears[k] = 1
			end
			if(args[prefix .. 'years' .. tostring(i)] or ''):match('<[\t ]*[Bb]') then
				hasbr = 1
			end
			if(args[prefix .. 'team' .. tostring(i)] or ''):match('<[\t ]*[Bb]') then
				hasbr = 1
			end
			if(args[prefix .. 'years' .. tostring(i)] or ''):match('[\r\n]') then
				hasnewline = 1
			end
			if(args[prefix .. 'team' .. tostring(i)] or ''):match('[\r\n]') then
				hasnewline = 1
			end
		end
		if (isnotblank(args[prefix .. 'team'.. tostring(maxindex+1)]) or isnotblank(args[prefix .. 'years'.. tostring(maxindex+1)]) ) then
			toohighnumber = 1
		end
	end
    if (hasbr > 0) then
        cats = cats .. '[[Category:Pages using infobox cyclist with deprecated parameters|B{{PAGENAME}}]]'
    end
    if (hasnewline > 0) then
        cats = cats .. '[[Category:Pages using infobox cyclist with deprecated parameters|N{{PAGENAME}}]]'
    end
	for k=1,3 do
		if (missingyears[k] > 0 and hasyears[k] > 0) then
			cats = cats .. '[[Category:Pages using infobox cyclist with deprecated parameters|Y{{PAGENAME}}]]'
		end
		if (missingteams[k] > 0 and hasteams[k] > 0) then
			cats = cats .. '[[Category:Pages using infobox cyclist with deprecated parameters|T{{PAGENAME}}]]'
		end
	end
    if (toohighnumber > 0) then
        cats = cats .. '[[Category:Pages using infobox cyclist with deprecated parameters|N{{PAGENAME}}]]'
    end
 
    return cats
end
 
return p