Modul:Country alias: Versiyalar orasidagi farq
Programmer (munozara | hissa) Country alias modulida memoizatsiya (keshlash) qo'shildi (CPU vaqt chegarasidan oshib ketishni oldini olish) |
Programmer (munozara | hissa) flagXYZ tezyurar satr ulanishiga (string concatenation) o'tkazildi va optimallashtirildi |
||
| Qator 253: | Qator 253: | ||
local function flagXYZ(frame) | local function flagXYZ(frame) | ||
local args = (frame.args and frame.args[1] and frame.args) or frame:getParent().args | |||
local dispType = stripToNil(frame.args['type']) | local dispType = stripToNil(frame.args['type']) | ||
local code='' | local code='' | ||
| Qator 265: | Qator 259: | ||
local athletes='' | local athletes='' | ||
if dispType == 'athlete-O' then | if dispType == 'athlete-O' then | ||
dispType = 'athlete' | dispType = 'athlete' | ||
args[3] = (args[3] or '') .. 'Olimpiada' | args[3] = (args[3] or '') .. 'Olimpiada' | ||
| Qator 278: | Qator 271: | ||
games = stripToNil(args[3]) or error('Parameter 3 should be a competition name') | games = stripToNil(args[3]) or error('Parameter 3 should be a competition name') | ||
end | end | ||
local parms = { | local parms = { | ||
alias = code, | alias = code, | ||
| Qator 293: | Qator 286: | ||
if dispType == 'team' then dispType = 'name' end | if dispType == 'team' then dispType = 'name' end | ||
end | end | ||
local flag = countryAlias(parms) | |||
local disp = dispName or fullName | |||
if dispType == 'name' then | if dispType == 'name' then | ||
local ath = athletes and (' <span style="font-size:90%;">(' .. athletes .. ')</span>') or '' | |||
return '[[Fayl:' .. flag .. '|22x20px|border|alt=|link=]] [[' .. fullName .. ' ' .. games .. '|' .. disp .. ']]' .. ath | |||
elseif dispType == 'team' then | elseif dispType == 'team' then | ||
return | return '[[Fayl:' .. flag .. '|22x20px|border|alt=|link=]] [[' .. fullName .. ' ' .. games .. '|' .. disp .. ']] <span style="font-size:90%;">(' .. code .. ')</span>' | ||
elseif dispType == 'athlete' then | elseif dispType == 'athlete' then | ||
return | return '[[Fayl:' .. flag .. '|22x20px|border|alt=|link=]] ' .. athletes .. ' <span style="font-size:90%;">([[' .. fullName .. ' ' .. games .. '|' .. code .. ']])</span>' | ||
elseif dispType == 'medalist' then | elseif dispType == 'medalist' then | ||
return | return athletes .. '<br>[[Fayl:' .. flag .. '|23x15px|border|alt=|link=]] [[' .. fullName .. ' ' .. games .. '|' .. disp .. ']]' | ||
end | end | ||
end | end | ||