Modul:Transclusion count/data/B: Perbedaan antara revisi
Loncat ke navigasi
Loncat ke pencarian
dw>RaFaDa20631 (←Membuat halaman berisi 'return { ["B-Class"] = 36000, ["BBC_Online"] = 3500, ["BBC_programme"] = 2400, ["BCGNIS"] = 2100, ["BDFutbol"] = 6800, ["BEL"] = 8200, ["BGR"] = 4900, ["BIH"] = 3500, ["BLP"] = 1080000, ["BLP_others"] = 6300, ["BLP_primary_sources"] = 6000, ["BLP_sources"] = 88000, ["BLP_unsourced"] = 6600, ["BLP_unsourced_section"] = 4800, ["BLR"] = 5100, ["BRA"] = 8400, ["BS"] = 2400, ["BS-map"] = 3900, ["BS-map/map"] = 3800, ["BS-overlap"] = 4700, ["BS3"] = 2200, ["BS_template...') |
k (1 revisi diimpor) |
||
(1 revisi perantara oleh pengguna yang sama tidak ditampilkan) | |||
Baris 1: | Baris 1: | ||
local p = {} | |||
function p.fetch(frame) | |||
local template = nil | |||
local return_value = nil | |||
-- Use demo parameter if it exists, otherswise use current template name | |||
local namespace = mw.title.getCurrentTitle().namespace | |||
[" | if frame.args["demo"] and frame.args["demo"] ~= "" then | ||
[" | template = frame.args["demo"] | ||
elseif namespace == 10 then -- Template namespace | |||
template = mw.title.getCurrentTitle().text | |||
[" | elseif namespace == 828 then -- Module namespace | ||
template = (mw.site.namespaces[828].name .. ":" .. mw.title.getCurrentTitle().text) | |||
end | |||
-- If in template or module namespace, look up count in /data | |||
if template ~= nil then | |||
namespace = mw.title.new(template, "Template").namespace | |||
if namespace == 10 or namespace == 828 then | |||
template = mw.ustring.gsub(template, "/doc$", "") -- strip /doc from end | |||
[ | local index = mw.ustring.sub(mw.title.new(template).text,1,1) | ||
local data = mw.loadData('Module:Transclusion_count/data/' .. (mw.ustring.find(index, "%a") and index or "other")) | |||
return_value = tonumber(data[mw.ustring.gsub(template, " ", "_")]) | |||
end | |||
end | |||
-- If database value doesn't exist, use value passed to template | |||
if return_value == nil and frame.args[1] ~= nil then | |||
local arg1=mw.ustring.match(frame.args[1], '[%d,]+') | |||
return_value = tonumber(frame:callParserFunction('formatnum', arg1, 'R')) | |||
end | |||
return return_value | |||
end | |||
return p | |||
[ | |||
[ | |||
[ | |||
[ | |||
Revisi terkini sejak 6 Oktober 2023 21.20
Dokumentasi untuk modul ini dapat dibuat di Modul:Transclusion count/data/B/doc
local p = {} function p.fetch(frame) local template = nil local return_value = nil -- Use demo parameter if it exists, otherswise use current template name local namespace = mw.title.getCurrentTitle().namespace if frame.args["demo"] and frame.args["demo"] ~= "" then template = frame.args["demo"] elseif namespace == 10 then -- Template namespace template = mw.title.getCurrentTitle().text elseif namespace == 828 then -- Module namespace template = (mw.site.namespaces[828].name .. ":" .. mw.title.getCurrentTitle().text) end -- If in template or module namespace, look up count in /data if template ~= nil then namespace = mw.title.new(template, "Template").namespace if namespace == 10 or namespace == 828 then template = mw.ustring.gsub(template, "/doc$", "") -- strip /doc from end local index = mw.ustring.sub(mw.title.new(template).text,1,1) local data = mw.loadData('Module:Transclusion_count/data/' .. (mw.ustring.find(index, "%a") and index or "other")) return_value = tonumber(data[mw.ustring.gsub(template, " ", "_")]) end end -- If database value doesn't exist, use value passed to template if return_value == nil and frame.args[1] ~= nil then local arg1=mw.ustring.match(frame.args[1], '[%d,]+') return_value = tonumber(frame:callParserFunction('formatnum', arg1, 'R')) end return return_value end return p