Մոդուլ:ԷլոՑանկ
Արտաքին տեսք
Documentation for this module may be created at Մոդուլ:ԷլոՑանկ/doc
local p = {}
function p.main( frame )
local lang = mw.language.getContentLanguage()
local entityId = mw.wikibase.getEntityIdForCurrentPage()
if entityId == nil then
return ''
end
local eloRating = mw.wikibase.getAllStatements(entityId, 'P1087')
if eloRating == nil then
return ''
end
local data = {}
local wikitable = frame:expandTemplate{ title = 'Alternating rows table', args = {class = 'wikitable', style = 'font-size: 85%;'}}
local wikitable = wikitable .. '!Տարի !! Հնվ !! Փտր !! Մրտ !! Ապր !! Մայ !! Հուն !! Հուլ !! Օգս !! Սեպ !! Հոկ !! Նոյ !! Դեկտ !! Տարվա<br />լավագույն !! Տարվա<br />վատագույն'
local dataByYear = {}
local availableYears = {}
local seenYears = {}
for key, value in pairs(eloRating) do
local amount = value.mainsnak.datavalue.value.amount
local timestamp = value.qualifiers.P585[1].datavalue.value.time
local year, month = timestamp:match("%+(%d%d%d%d)-(%d%d)-%d%dT")
year = tonumber(year)
month = tonumber(month)
if seenYears[year] == nil then
seenYears[year] = true
table.insert(availableYears, year)
end
if dataByYear[year] == nil then
dataByYear[year] = {}
end
dataByYear[year][month] = tonumber(amount)
end
table.sort(availableYears)
for _, year in pairs(availableYears) do
local yearMax = 0
local yearMin = math.huge
wikitable = wikitable .. '\n|-\n'
local row = '!' .. year .. '\n|'
for i = 1, 12 do
if dataByYear[year][i] == nil then
row = row .. ' '
else
yearMax = math.max(yearMax, dataByYear[year][i])
yearMin = math.min(yearMin, dataByYear[year][i])
row = row .. dataByYear[year][i]
end
row = row .. '||'
end
row = row .. yearMax .. '||' .. yearMin
wikitable = wikitable .. row .. '\n'
end
wikitable = wikitable .. '\n' .. frame:expandTemplate{ title = 'End'}
return wikitable
end
return p