Moduldokumentasjon

Denne modulen benyttes av {{FlaggIOC}}, {{FlaggIOClag}}, {{FlaggIOCmedaljør}} og {{FlaggIOCutøver}}.

local p = {}
 
local lang = mw.getContentLanguage()
local ccode = require('Modul:Land/alfa3')
local cname = require('Modul:Land/alfa3(2)')
 
function p.flagname(frame)
    local countrycode = lang:uc(frame.args.kode)
    if countrycode == "BRN" then
    	countrycode = "BHR"
	else
		countrycode = countrycode
	end
    if ccode[countrycode] == nil then
    	country = frame.args.kode
	else
		country = ccode[countrycode]
 	end
 
    -- Kode angitt og er riktig?
    if country == "" then
        return "''Feil i kode''[[Kategori:Sider med feil i FlaggIOC-mal]]"
    end
 
    return country
end
 
function p.countryname( frame )
    local countrycode;
    if lang:uc(frame.args.kode) == 'EUA' then
        countrycode = 'GER'
    elseif lang:uc(frame.args.kode) == 'BRN' then
    	countrycode = 'BHR'
	else
        countrycode = lang:uc(frame.args.kode)
	end
 
    local country = ccode[countrycode]
 
    if country ~= nil then
        return country
    elseif country ~= nil then
        return '[[Kategori:Sider med feil i FlaggIOC-mal]]'
    end
end
 
function p.year( frame )
    local year_out
    local year = tostring(lang:lc(frame.args.leker))
    local countrycode = tostring(lang:uc(frame.args.kode))
    if countrycode == 'EUN' or countrycode == 'OAR' or countrycode == 'ROT' or countrycode == 'ROC' or countrycode == 'SUS' then
	    year_out = 'OL'
	    return year_out
    end
    if year == 'sommer-ol 1896' then
    		year_out = '1896'
    elseif year == 'sommer-ol 1900' then
        if countrycode == 'CUB' or countrycode == 'IRI' or countrycode == 'NOR' then
            year_out = 'OL-1900'
        else
            year_out = '1900'
        end
    elseif year == 'sommer-ol 1904' then
            year_out = '1904'
    elseif year == 'sommer-ol 1908' then
        if countrycode == 'TUR' then
            year_out = 'OL-1908'
        else 
            year_out = '1908'
        end
    elseif year == 'sommer-ol 1912' then
        if countrycode == 'BOH' or countrycode == 'RSA' or countrycode == 'TUR' then
            year_out = 'OL-1912'
        else
            year_out = '1912'
        end
    elseif year == 'sommer-ol 1920' then
            year_out = '1920'
    elseif year == 'sommer-ol 1924' or year == 'vinter-ol 1924' then
        if countrycode == 'HUN' then
            year_out = 'OL-1924'
        else
            year_out = '1924'
        end
    elseif year == 'sommer-ol 1928' or year == 'vinter-ol 1928' then
        if countrycode == 'HUN' or countrycode == 'RSA' then
            year_out = 'OL-1928'
        else
            year_out = '1928'
        end
    elseif year == 'sommer-ol 1932' or year == 'vinter-ol 1932' then
        if countrycode == 'HUN' or countrycode == 'TPE' then
            year_out = 'OL-1932'
        else
            year_out = '1932'
        end
    elseif year == 'sommer-ol 1936' then
    	if countrycode == 'CAN' or countrycode == 'HUN' or countrycode == 'IND' or countrycode == 'PHI' or countrycode == 'TPE' then
            year_out = 'OL-1936'
        else
            year_out = '1936'
        end
    elseif year == 'vinter-ol 1936' then
        if countrycode == 'HUN' then
            year_out = 'OL-1936'
        else
            year_out = '1936'
        end
    elseif year == 'sommer-ol 1948' or year == 'vinter-ol 1948' then
        if countrycode == 'BIR' or countrycode == 'CEY' or countrycode == 'MLT' or countrycode == 'PUR' or countrycode == 'ROU' or countrycode == 'TPE' then
            year_out = 'OL-1948'
        else
            year_out = '1948'
        end
    elseif year == 'sommer-ol 1952' then
        if countrycode == 'PUR' then
            year_out = 'OL-1952'
        else
            year_out = '1952'
        end
    elseif year == 'vinter-ol 1952' then
    	if countrycode == 'AUS' then
    		year_out = 'OL-1952'
		else
            year_out = '1952'
        end
    elseif year == 'sommer-ol 1956' or year == 'vinter-ol 1956' then
        if countrycode == 'EUA' or countrycode == 'HUN' or countrycode == 'PUR' or countrycode == 'TPE' then
            year_out = 'OL-1956'
        else
            year_out = '1956'
        end
    elseif year == 'vinter-ol 1960' then
            year_out = '1960'
    elseif year == 'sommer-ol 1960' then
        if countrycode == 'BRA' or countrycode == 'TPE' or countrycode == 'USA' then
            year_out = 'OL-1960'
        else
            year_out = '1960'
        end
    elseif year == 'sommer-ol 1964' then
        if countrycode == 'BAH' or countrycode == 'IRI' or countrycode == 'TAN' or countrycode == 'TPE' then
            year_out = 'OL-1964'
        else
            year_out = '1964'
        end
    elseif year == 'vinter-ol 1964' then
            year_out = '1964'
    elseif year == 'sommer-ol 1968' or year == 'vinter-ol 1968' then
        if countrycode == 'BRA' or countrycode == 'FRG' or countrycode == 'GDR' or countrycode == 'MEX' or countrycode == 'TPE' then
            year_out = 'OL-1968'
        else
            year_out = '1968'
        end
    elseif year == 'sommer-ol 1972' or year == 'vinter-ol 1972' then
        if countrycode == 'EGY' or countrycode == 'SYR' or countrycode == 'TPE' then
            year_out = 'OL-1972'
        else
            year_out = '1972'
        end
    elseif year == 'sommer-ol 1976' then
    	if countrycode == 'AND' or countrycode == 'TPE' then
    		year_out = 'OL-1976'
    		else
    			year_out = '1976'
    	end
    	elseif year == 'vinter-ol 1976' then
        if countrycode == 'GRE' or countrycode == 'TPE' then
            year_out = 'OL-1976'
        else
            year_out = '1976'
        end
    elseif year == 'vinter-ol 1976' then
        if countrycode == 'AND' then
            year_out = 'Vinter-OL 1976'
        else
            year_out = '1976'
        end
    elseif year == 'sommer-ol 1980' then
        if countrycode == 'AND' or countrycode == 'AFG' or countrycode == 'AUS' or countrycode == 'BEL' or countrycode == 'DEN' or countrycode == 'FRA' or countrycode == 'GBR' or countrycode == 'IRL' or countrycode == 'ITA' or countrycode
    == 'LUX' or countrycode == 'NED' or countrycode == 'NZL' or countrycode == 'POL' or countrycode == 'POR' or countrycode == 'PUR' or countrycode == 'SMR' or countrycode == 'SYR' or countrycode == 'ESP' or countrycode == 'SUI' then
            year_out = 'OL-1980'
        else
            year_out = '1980'
        end
    elseif year == 'vinter-ol 1980' then
    	if countrycode == 'POL' then
    		year_out = 'OL-1980'
    	else
            year_out = '1980'
        end
    elseif year == 'sommer-ol 1984' or year == 'vinter-ol 1984' then
        	year_out = '1984'
    elseif year == 'sommer-ol 1988' or year == 'vinter-ol 1988' then
            year_out = '1988'
    elseif year == 'sommer-ol 1992' then
        if countrycode == 'ALB' or countrycode == 'BIH' or countrycode == 'BRA' or countrycode == 'ETH' or countrycode == 'MGL' or countrycode == 'PRK' or countrycode == 'RSA' then
            year_out = 'OL-1992'
        elseif countrycode == 'EUN' then
            year_out = 'OL'
        else
        	year_out = '1992'
        end
    elseif year == 'vinter-ol 1992' then
        if countrycode == 'EUN' or countrycode == 'PRK' then
            year_out = 'OL'
        else
        	year_out = '1992'
        end
    elseif year == 'vinter-ol 1994' then
        if countrycode == 'RSA' then
            year_out = 'OL-1994'
        else
            year_out = '1994'
        end
    elseif year == 'sommer-ol 1996' then
        if countrycode == 'ETH' or countrycode == 'SEY' or countrycode == 'ZAM' then
            year_out = 'OL-1996'
        else
            year_out = '1996'
        end
    elseif year == 'vinter-ol 1998' then
        if countrycode == 'BIH' then
            year_out = 'OL-1998'
        else
            year_out = '1998'
        end
    elseif year == 'sommer-ol 2000' then
        if countrycode == 'CAY' then
            year_out = 'OL-2000'
        else
            year_out = '2000'
        end
    elseif year == 'vinter-ol 2002' then
        if countrycode == 'CAY' then
            year_out = 'OL-2002'
        else
            year_out = '2002'
        end
    elseif year == 'sommer-ol 2004' then
        if  countrycode == 'CAY' or countrycode == 'GEO' or countrycode == 'LTU' or countrycode == 'IRQ' then
            year_out = 'OL-2004'
        else
            year_out = '2004'
        end
    elseif year == 'vinter-ol 2006' then
        if countrycode == 'CAY' then
            year_out = 'OL-2006'
        else
            year_out = '2006'
        end
    elseif year == 'sommer-ol 2008' then
        if countrycode == 'CAY' or countrycode == 'IRQ' then
            year_out = 'OL-2008'
        else
            year_out = '2008'
        end
    elseif year == 'vinter-ol 2010' then
        if countrycode == 'CAY' then
            year_out = 'OL-2010'
        else
            year_out = '2010'
        end
    elseif year == 'sommer-ol 2012' then
        if countrycode == 'CAY' then
            year_out = 'OL-2012'
        else
            year_out = '2012'
        end
    elseif year == 'vinter-ol 2014' then
    	if countrycode == 'CAY' then
    		year_out = 'OL-2014'
    	else
            year_out = '2014'
        end
    	elseif year == 'sommer-ol 2016' then
		if countrycode == 'CAY' then
			year_out= 'OL-2016'
		else
           year_out = '2016'
       end
    elseif year == 'vinter-ol 2018' then
        if countrycode == 'COR' then
	       year_out = 'OL-2018'
		elseif countrycode == 'OAR' then
            year_out = 'OL'
        else
	       year_out = '2018'
        end
    elseif year == 'sommer-ol 2020' then
    	if countrycode == 'ROC' then
	       year_out = 'OL'
       elseif countrycode == 'CAY' or countrycode == 'RUS' or countrycode == 'VEN' then
            year_out = 'OL-2020'
	    else
            year_out = '2020'
        end
    elseif year == 'vinter-ol 2022' then
		if countrycode == 'ROC' then
	       year_out = 'OL'
      elseif countrycode == 'RUS' then
            year_out = 'OL-2022'
	    else
        	year_out = '2022'
    	end
    elseif year == 'sommer-ol 2024' then
    		year_out = '2024'
	elseif year == 'vinter-ol 2026' then
           year_out = '2026'
	elseif year == 'sommer-ol 2028' then
    		year_out = '2028'
	elseif year == 'vinter-ol 2030' then
			year_out = '2030'
	elseif year == 'sommer-ol 2032' then
			year_out = '2032'
    else
        year_out = ''
	end
    
    return year_out
end
 
function p.location( frame )
    local place;
    local games = tostring(lang:lc(frame.args.leker))
    if games == 'sommer-ol 1896' or games == 'sommer-ol 1906' or games == 'sommer-ol 2004' then
        place = 'i [[Athen]]'
    elseif games == 'sommer-ol 1900' or games == 'sommer-ol 1924' or games == 'sommer-ol 2024' then
        place = 'i [[Paris]]'
    elseif games == 'sommer-ol 1904' then
        place = 'i [[St. Louis]]'
    elseif games == 'sommer-ol 1908' or games == 'sommer-ol 1948' or games == 'sommer-ol 2012' then
        place = 'i [[London]]'
    elseif games == 'sommer-ol 1912' then
        place = 'i [[Stockholm]]'
    elseif games == 'sommer-ol 1920' then
        place = 'i [[Antwerpen]]'
    elseif games == 'sommer-ol 1928' then
        place = 'i [[Amsterdam]]'
    elseif games == 'sommer-ol 1932' or games == 'sommer-ol 1984' or games == 'sommer-ol 2028' then
        place = 'i [[Los Angeles]]'
    elseif games == 'sommer-ol 1936' then
        place = 'i [[Berlin]]'
    elseif games == 'sommer-ol 1952' then
        place = 'i [[Helsingfors]]'
    elseif games == 'sommer-ol 1956' then
        place = 'i [[Melbourne]]/[[Stockholm]]'
    elseif games == 'sommer-ol 1960' then
        place = 'i [[Roma]]'
    elseif games == 'sommer-ol 1964' or games == 'sommer-ol 2020' then
        place = 'i [[Tokyo]]'
    elseif games == 'sommer-ol 1968' then
        place = 'i [[Mexico by]]'
    elseif games == 'sommer-ol 1972' then
        place = 'i [[München]]'
    elseif games == 'sommer-ol 1976' then
        place = 'i [[Montréal]]'
    elseif games == 'sommer-ol 1980' then
        place = 'i [[Moskva]]'
    elseif games == 'sommer-ol 1988' then
        place = 'i [[Seoul]]'
    elseif games == 'sommer-ol 1992' then
        place = 'i [[Barcelona]]'
    elseif games == 'sommer-ol 1996' then
        place = 'i [[Atlanta]]'
    elseif games == 'sommer-ol 2000' then
        place = 'i [[Sydney]]'
    elseif games == 'sommer-ol 2008' then
        place = 'i [[Beijing]]'
    elseif games == 'sommer-ol 2016' then
        place = 'i [[Rio de Janeiro]]'
    elseif games == 'sommer-ol 2032' then
        place = 'i [[Brisbane]]'
    elseif games == 'vinter-ol 1924' then
        place = 'i [[Chamonix]]'
    elseif games == 'vinter-ol 1928' or games == 'vinter-ol 1948' then
        place = 'i [[St. Moritz]]'
    elseif games == 'vinter-ol 1932' or games == 'vinter-ol 1980' then
        place = 'i [[Lake Placid (New York)|Lake Placid]]'
    elseif games == 'vinter-ol 1936' then
        place = 'i [[Garmisch-Partenkirchen]]'
    elseif games == 'vinter-ol 1952' then
        place = 'i [[Oslo]]'
    elseif games == 'vinter-ol 1956' then
        place = 'i [[Cortina d'Ampezzo|Cortina d'Ampezzo]]'
    elseif games == 'vinter-ol 1960' then
        place = 'i [[Squaw Valley Ski Resort|Squaw Valley]]'
    elseif games == 'vinter-ol 1964' or games == 'vinter-ol 1976' then
        place = 'i [[Innsbruck]]'
    elseif games == 'vinter-ol 1968' then
        place = 'i [[Grenoble]]'
    elseif games == 'vinter-ol 1972' then
        place = 'i [[Sapporo]]'
    elseif games == 'vinter-ol 1984' then
        place = 'i [[Sarajevo]]'
    elseif games == 'vinter-ol 1988' then
        place = 'i [[Calgary]]'
    elseif games == 'vinter-ol 1992' then
        place = 'i [[Albertville]]'
    elseif games == 'vinter-ol 1994' then
        place = 'på [[Lillehammer]]'
    elseif games == 'vinter-ol 1998' then
        place = 'i [[Nagano]]'
    elseif games == 'vinter-ol 2002' then
        place = 'i [[Salt Lake City]]'
    elseif games == 'vinter-ol 2006' then
        place = 'i [[Torino]]'
    elseif games == 'vinter-ol 2010' then
        place = 'i [[Vancouver]]'
    elseif games == 'vinter-ol 2014' then
        place = 'i [[Sotsji]]'
    elseif games == 'vinter-ol 2018' then
        place = 'i [[Pyeongchang]]'
    elseif games == 'vinter-ol 2022' then
    	place = 'i [[Beijing]]'
	elseif games == 'vinter-ol 2026' then
    	place = 'i [[Milano]]/[[Cortina d'Ampezzo|Cortina d'Ampezzo]]'
    else
        place = ''
    end
 
    return place
end
 
function p.link( frame )
    local countrycode = lang:uc(frame.args.kode)
    if countrycode == "BRN" then
    	countrycode = "BHR"
	else
		countrycode = countrycode
	end
    if ccode[countrycode] == nil then
    	country = frame.args.kode
	else
		country = ccode[countrycode]
	end
    local games_out;
    local games = tostring(lang:lc(frame.args.leker))
    if games == 'sommer' then
        games_out = 'Sommer-OL'
    elseif games == 'vinter' then
        games_out = 'Vinter-OL'
    elseif games == '' then
        games_out = 'OL'
    else
        games_out = frame.args.leker
    end

	if country == nil then
		link_out = tostring(frame.args.kode .. ' under ' .. games_out)
	else
		link_out = tostring(country .. ' under ' .. games_out)
 	end
 
    if link_out ~= nil then
        return link_out
    elseif link_out == nil then
        return '[[Kategori:Sider med feil i FlaggIOC-mal]]'
    end
end
 
function p.linktext( frame )
    local countrycode = lang:uc(frame.args.kode)
    if countrycode == "BRN" then
    	countrycode = "BHR"
	else
		countrycode = countrycode
	end
    local country = ccode[countrycode]
    local linktext_out = tostring(country)
    if linktext_out == "nil" then
    	linktext_out = tostring(frame.args.kode)
	else
		linktext_out = linktext_out
	end
	
    return linktext_out
end
 
function p.athlete( frame )
    local p_athlete = tostring(frame.args.utover)
    local athlete_out;
    if p_athlete ~= '' then
        athlete_out = p_athlete
    else
        athlete_out = ''
    end
 
    if athlete_out ~= nil then
        return athlete_out
    elseif athlete_out == nil then
        return ''
    end
end
 
function p.partisipants( frame )
    local p_partisipants = tonumber(frame.args.antall)
    if p_partisipants ~= nil then
       return '&nbsp;<span style="font-size:90%;">(' .. frame.args.antall .. ')</span>'
    elseif p_partisipants == nil then
       return ''
    end
end
 
function p.IOCcode( frame )
	local countrycode = frame.args.kode
	
	if cname[countrycode] ~=nil then
		country = cname[countrycode]
	else
		country = frame.args.kode
	end
	
    if countrycode == "BRN" then
    	country = "BHR"
	else
		country = country
	end

	-- Kode angitt og er riktig?
    if country == "" then
        return "''Feil i kode''[[Kategori:Sider med feil i FlaggIOC-mal]]"
    end
 
    return '&nbsp;<span style="font-size:90%;">(' .. country .. ')</span>'

end
 
function p.NameToCode( frame )
	local countrycode = frame.args.kode
	
	if cname[countrycode] ~=nil then
		country = cname[countrycode]
	else
		country = frame.args.kode
	end
	
    if countrycode == "BRN" then
    	country = "BHR"
	else
		country = country
	end

	-- Kode angitt og er riktig?
    if country == "" then
        return "''Feil i kode''[[Kategori:Sider med feil i FlaggIOC-mal]]"
    end
 
    return  country

end
 
return p