יחידה:NUMBEROF – הבדלי גרסאות
אין תקציר עריכה |
אין תקציר עריכה |
||
| (גרסת ביניים אחת של אותו משתמש אינה מוצגת) | |||
| שורה 37: | שורה 37: | ||
local function getIfLocal(site, action) | local function getIfLocal(site, action) | ||
local localSite = string.match(mw.site.server, 'https?://(.-)%.com$') | local localSite = string.match(mw.site.server, 'https?://(.-)%.com$') | ||
or string.match(mw.site.server, 'https?://(.-)%.co%.il$') | |||
if site == localSite then | if site == localSite then | ||
if action == 'activeusers' then | if action == 'activeusers' then | ||
| שורה 47: | שורה 47: | ||
function p.main(frame) | function p.main(frame) | ||
local args = frame:getParent().args | local args = frame.args or frame:getParent().args | ||
local action = trimArg(args[1], 1) -- | local action = trimArg(args[1], 1) -- articles, edits, etc. | ||
if not action then return -1 end | if not action then return -1 end | ||
| שורה 55: | שורה 55: | ||
end | end | ||
local site = trimArg(args[2], 2) or ' | local site = trimArg(args[2], 2) or '' | ||
if not site:find('.', 1, true) then | if site ~= 'total' and not site:find('.', 1, true) then | ||
site = site .. '.chabadpedia' | site = site .. '.chabadpedia' | ||
end | end | ||
local wantComma = trimArg(args[3]) | local wantComma = trimArg(args[3]) | ||
local result = getIfLocal(site, action) | local result = getIfLocal(site, action) | ||
if not result then | if not result then | ||
local data = mw.loadData('Module:NUMBEROF/data') | local data = mw.loadData('Module:NUMBEROF/data') | ||
local map = data.map | local map = data.map | ||
data = data.data | data = data.data | ||
result = data[site] | |||
if | if result then | ||
result = getValue( | result = getValue(result, action, map) | ||
end | end | ||
end | end | ||
| שורה 91: | שורה 88: | ||
local base = trimArg(args[2]) or 'chabadpedia' | local base = trimArg(args[2]) or 'chabadpedia' | ||
local wantComma = trimArg(args[3]) | local wantComma = trimArg(args[3]) | ||
local data = mw.loadData('Module:NUMBEROF/' .. (base == 'chabadpedia' and 'rank' or 'other')) | local data = mw.loadData('Module:NUMBEROF/' .. (base == 'chabadpedia' and 'rank' or 'other')) | ||
data = data[base] | data = data[base] | ||
if data then | if data then | ||
local result | local result | ||
| שורה 100: | שורה 99: | ||
else | else | ||
result = data.rankBySite[parm] | result = data.rankBySite[parm] | ||
if result and wantComma then | |||
result = mw.getContentLanguage():formatNum(result) | |||
end | |||
end | end | ||
if result | if result then | ||
result | return result | ||
end | end | ||
end | end | ||
return -1 | return -1 | ||
end | end | ||
return p | return p | ||