ماژول:Goalscorers: نوسخه‌لر آراسینداکی فرق

محتوای حذف‌شده محتوای افزوده‌شده
بدون خلاصۀ ویرایش
بدون خلاصۀ ویرایش
خط ۹۷:
if g.totalGoals == 1 then
pluralGoals = ""
if dateUpdated == 'complete' then text1 = "was" else text1 = "has been" end
else
if dateUpdated == 'complete' then text1 = "were" else text1 = "have been" end
end
local text = string.format("There %s %s goal%s scored", text1, mw.getLanguage('en'):formatNum(g.totalGoals), pluralGoals)
local text = ''
local pluralMatches = "es"
if matches==1 then pluralMatches = "" end
if matches then
خط ۱۱۳:
local pluralAverage = "s"
if tonumber(string.format("%.2f",average))==1 then pluralAverage = "" end
text = text .. string.format("بو قوللارin %d اویونداmatch%s, وورولوب،for اورتاسیan average of %."..precision.."g قولgoal%s هرper اویونداmatch", matches, pluralMatches, average, pluralAverage)
end
if dateUpdated == 'complete' or dateUpdated == "" then
text = text .. "."
text = text .. string.format(" و %s%s قول وورولدو.", text1, mw.getLanguage('en'):formatNum(g.totalGoals), pluralGoals)
else
local dateFormat = 'dmy' -- default
خط ۱۲۴:
if mdyFormat == false then dateFormat = "dmy" end -- template param overrides
end
text = text .. " (یوخلاماas تاریخی:of " .. Date(dateUpdated):text(dateFormat) .. ")."
end
text = p.addAdditionHeaderText(text, dateUpdated) -- handles template parameters bold, further, extra
خط ۴۷۳:
table.sort(items, function(a,b) return a<b end) -- sort the table alphbetically
 
local list = "حریف:against " -- construct the alphabetical list string
for i=1, #items do
local sep = ", " -- separator for comma-delimited list
خط ۵۶۱:
 
end
function p.tabulateGoalscorers(frame, og)
-- ==============output the lists of goalscorers by goal======================
local goalNumber = 1000
local maxRank = tonumber(g.args['maxrank'] or 10) -- limit list top ten or value in parameter maxrank
local rank = 1
local playerCount = 0
local rankCount = 0
local playerCells = ""
local firstplayerCell = ""
 
local tableString = '\n{| class="wikitable"' -- start table
..'\n|-' .. '\n!Rank !! Player !! Goals' -- add table headers
if g.args['header'] then tableString = tableString .. '\n|+ ' .. g.args['header'] end -- add header
for j,u in pairs(g.goalscorers) do -- run through sorted list of selected goalscorers
-- is the player active still?
local playerActive = false
if data.active_countries then
for k,v in pairs(data.active_countries) do
if v == u['country'] then
playerActive = true
break;
end
end
end
local _,roundStatus = p.getNumberMatches()
if roundStatus == "complete" then playerActive = false end -- overrides active_countries
-- wikitext for tablulated list
local goalscorerString = p.addLinkedIcon(frame, u['country']) -- linked flag icon
if playerActive and g.args['bold']~='no' then
goalscorerString = goalscorerString .. " '''" .. u['player'] .. "'''>" -- bolded name
else
goalscorerString = goalscorerString .. " " .. u['player'] -- name
end
goalscorerString = goalscorerString .. u['comment'] -- comment for o.g.
 
-- we have a goalscorer
playerCount = playerCount + 1
rankCount = rankCount + 1
if u['goals'] < goalNumber then -- player belongs to rowspan for new number of goals
-- need to generate code for the previous rowspan (if there is one)
-- then start the counts and player list for the new one
if playerCount == 1 then
firstplayerCell = '\n|' .. goalscorerString -- if first player in list just create cell and set goals
goalNumber = u['goals']
--rank = 1
rankCount = 0
else -- else generate previous rowspan
local rowSpan = rankCount
if playerCount > maxRank * 1.5 then
firstplayerCell = '\n| style="font-style:italic;text-align:center;"|' .. rankCount .. " players"
playerCells = ""
rowSpan = 1
end
tableString = tableString .. '\n|-\n| style="text-align:center;" rowspan="' .. rowSpan .. '"|' .. rank
--if rankCount > 1 then tableString = tableString .. "=" end -- adds equals when rank shared
tableString = tableString .. firstplayerCell
tableString = tableString .. '\n| style="text-align:center;" rowspan="' .. rowSpan .. '"|' .. goalNumber
tableString = tableString .. playerCells
 
rank = rank + rankCount
if rank > maxRank then break end -- limit list top ten or value in parameter
rankCount = 0
goalNumber = u['goals']
firstplayerCell = '\n|' .. goalscorerString -- set first player cell for next rowspan
playerCells = ""
end
else -- else another player with same number of goals
playerCells = playerCells .. '\n|-' .. '\n|' .. goalscorerString -- add to player cell list
end
end -- reached end of list of goalscorers
 
if tableString ~= "" then
tableString = tableString .. "\n|}"
return tableString
else
return ("No goals matching requested criteria.")
end
end
function p.outputGoalscorers(frame, og) -- output list of goalscorers
if g.args['table'] then return p.tabulateGoalscorers(frame, og) end -- optional table output
local outputString = ""
if og == "OG" then end
سطر ۵۸۳ ⟵ ۶۶۹:
goalNumber = u['goals']
local goalString = " قولgoal"
--if og == "OG" then
if goalNumber < 0 then
goalString = " اوزونهown" .. goalString
end
if math.abs(u['goals']) ~= 1 then goalString = goalString .. "s" end
 
outputString = outputString .. "\n'''" .. math.abs(u['goals']) .. goalString .. "'''" -- list caption
سطر ۶۴۹ ⟵ ۷۳۵:
function p.openList(frame,og)
 
return mw.getCurrentFrame():extensionTag{
return '<div class="div-col columns column-count column-count-3" style="'
.. frame:expandTemplate{ title name = 'column-counttemplatestyles', args = {3} }src = 'Div col/styles..css' '">'}
} .. '<div class="div-col" style="column-width:25em;">' -- perhaps add "column-count:3;"" to limit max number of columns?
end
function p.closeList(frame)
سطر ۷۲۰ ⟵ ۸۰۷:
local updateString = ""
local averageString = ""
local goalPlural = "s" -- goal(s)
local text3 = ""
if g.args['goals'] and tonumber(g.args['goals']) >== 1 then text3 = "es" end
goalPlural = ""
text2 = "was"
if ongoing then text2 = "has been" end
end
local matchPlural = "es" -- match(es)
if g.args['matches'] and tonumber(g.args['matches']) == 1 then matchPlural = "" end
-- auto version: string.format(" in %d match%s, for an average of %."..precision.."g goal%s per match", matches, pluralMatches, average, pluralAverage)
if g.args['goals'] and g.args['matches'] then
averageStringlocal averageGoals = string.format(" in %d match%s, for an average of %.3g goals per match", g.args['matches'], text3,g.args['goals']/g.args['matches'])
local avGoalPlural = "s"
if averageGoals == 1 then avGoalPlural = "" end
averageString = string.format(" in %d match%s, for an average of %.3g goal%s per match", g.args['matches'], matchPlural, averageGoals, avGoalPlural)
end
if g.args['updated'] and g.args['updated'] ~= "complete" then
سطر ۷۳۴ ⟵ ۸۳۱:
local text = ""
if g.args['goals'] then
text = string.format("%s %s %d %sss%s scored%s",
text1, text2, statNumber, statType, goalPlural, averageString..updateString..sep)
end
text = p.addAdditionHeaderText(text) -- handles template parameters bold, further, extra
--[[ {{#if:{{{30 goals|{{{30 assists|}}}}}}|'''30 {{#if:{{{assists|}}}|assists|goals}}'''
<div class="div-col columns column-count column-count-3" style="{{column-count|:3}};">
{{#if:{{{assists|}}}|{{{30 assists}}}|{{{30 goals}}}}}</div>|}}]]
local output = "\n"
سطر ۷۶۳ ⟵ ۸۶۰:
 
output = output .. "\n'''" .. tostring(math.abs(number)) .. " " .. statType .. plural .. "'''\n"
.. p.openList(frame) .. "\n" .. entry .. p.closeList(frame)
.. '<div class="div-col columns column-count column-count-3" style="' .. frame:expandTemplate{ title = "column-count", args = {3} } .. '">'
.. "\n" .. entry .. '</div>'
totalGoals = p.countGoals(entry, number, totalGoals)
end
سطر ۷۷۷ ⟵ ۸۷۳:
end
--{{#if:{{{bottom|}}}|{{small|{{{bottom_text}}}}} <div class="div-col columns column-count column-count-3" style="{{column-count|:3}};"> {{{bottom}}}</div>|}}{{#if:{{{source|}}}|{{smaller|Source: {{{source}}}}}|}}
local footerText = g.args['footer-text'] or g.args['bottom'] or ""
local footerHeading = g.args['footer-heading'] or g.args['bottom-text'] or ""
سطر ۷۸۶ ⟵ ۸۸۲:
heading = '<p>' .. footerHeading .. '</p>'
end
footer = '\n' .. heading .. p.openList(frame) .. '\n' .. footerText .. p.closeList(frame)
.. '<div class="div-col columns column-count column-count-3" style="' .. frame:expandTemplate{ title = "column-count", args = {3} } .. '">'
.. '\n' .. footerText .. '</div>'
end