Modul:NUMBEROF
![Dokumentácia](http://upload.wikimedia.org/wikipedia/commons/thumb/2/28/Information.svg/20px-Information.svg.png)
Dokumentácia pre tento modul zatiaľ neexistuje. Môžete ju vytvoriť na Modul:NUMBEROF/Dokumentácia
Ak máte otázku k tomuto modulu, alebo potrebujete jeho rozšírenie a neviete ho správne naformátovať, pýtajte sa v diskusii k modulu. Pokiaľ je potrebné modul urgentne opraviť, obráťte sa na technickú podporu.
- Použitie modulu v článkoch.
- Zoznam podstránok tohto modulu.
local function trimArg(arg, i)arg = mw.text.trim(arg or '')if arg == '' thenif i thenerror('Parameter ' .. i .. ' is missing. See template documentation')endreturn nilendreturn mw.ustring.lower(arg)endlocal function getValue(stats, action, map)if action == 'depth' then-- https://meta.wikimedia.org/wiki/Wikipedia_article_depth-- This gives silly results if, for example, the number of articles is small.local n = { 'articles', 'edits', 'pages' }if map thenfor i, v in ipairs(n) don[i] = map[v]endendfor i, v in ipairs(n) don[i] = stats[v] or 0endlocal articles, edits, pages = n[1], n[2], n[3]if pages == 0 or articles == 0 thenreturn 0endreturn math.floor((edits/pages) * ((pages - articles)/articles)^2)endif map thenaction = map[action]endreturn stats[action]endlocal function getIfLocal(site, action)-- If wanted site is the local site where module is running,-- return numberof result for given action, or nil.-- This is faster than reading the cached table, and gives the current value.local localSite = string.match(mw.site.server, '.*//(.*)%.org$') -- examples: 'af.wikipedia', 'commons.wikimedia'if site == localSite thenif action == 'activeusers' thenaction = 'activeUsers'endreturn getValue(mw.site.stats, action)endendlocal function main(frame)local args = frame:getParent().argslocal action = trimArg(args[1], 1) -- activeusers, admins, articles, edits, files, pages, users, depthif action:sub(1, 8) == 'numberof' then -- numberofX is an alias for Xaction = trimArg(action:sub(9), 1)endlocal site = trimArg(args[2], 2) -- "af" or "af.wikipedia" or "af.wikiquote" etc., including "total"if not site:find('.', 1, true) thensite = site .. '.wikipedia'endlocal wantComma = trimArg(args[3]) -- nil for no commas in output; "N" or anything nonblank inserts commaslocal result = getIfLocal(site, action)if not result thenlocal data = mw.loadData('Modul:NUMBEROF/data')local map = data.mapdata = data.dataresult = data[site]if result thenresult = getValue(result, action, map)endendif result thenif wantComma thenresult = mw.getContentLanguage():formatNum(result)endreturn result -- number or formatted stringendreturn -1endlocal function rank(frame)-- Rank sites in a specified sister project by their number of articles.local args = frame:getParent().argslocal parm = trimArg(args[1], 1) -- a number like 12 or a site name like "af" (not "af.wikipedia")local base = trimArg(args[2]) or 'wikipedia' -- base of full site name like "wikipedia" or "wikiquote"local wantComma = trimArg(args[3])local data = mw.loadData('Modul:NUMBEROF/' .. (base == 'wikipedia' and 'rank' or 'other'))data = data[base]if data thenlocal resultparm = tonumber(parm) or parmif type(parm) == 'number' thenresult = data.rankByIndex[parm]elseresult = data.rankBySite[parm]if result and wantComma thenresult = mw.getContentLanguage():formatNum(result)endendif result thenreturn result -- number or stringendendreturn -1endreturn {main = main,rank = rank,}
🔥 Top keywords: Hlavná stránkaIvan HričovskýŠpeciálne:HľadanieWikipédia:KontaktŠpeciálne:PoslednéÚpravyWikipédia:Wiki miluje ZemMajstrovstvá Európy vo futbale 2024György GyimesiCyril a MetodSviatok svätého Cyrila a svätého MetodaČlenovia Európskej únieDivina (obec)SlovenskoMajstrovstvá sveta vo futbale 2026Ladislav BorbélyYouTubeAlex PereiraMark CavendishTomáš HolýMajstrovstvá Európy vo futbaleZoznam okresov na SlovenskuPeter SaganCristiano RonaldoCyprusZoznam miest na SlovenskuBratislava3. júlFerruccio LamborghiniCéline DionováHorný HričovLabouristická strana (Spojené kráľovstvo)Súbor:Relief Map of Slovakia.pngHolotúrieJean GabinLamborghiniPortál:ĽudiaTureckoZoznam poznávacích značiek motorových vozidielDominik Dán