Module:ArbComMembers
-- Module:ArbComMembers
-- Dynamically counts active/inactive arbitrators by parsing the live Members page
local p = {}
-- Target page
local pageName = "Wikipedia:Arbitration Committee/Members"
-- Fetch page content
local title = mw.title.new(pageName)
if not title or not title.exists then
error("Module:ArbComMembers: Page '" .. pageName .. "' does not exist.")
end
local content = title:getContent()
-- Parses content to count active/inactive members
local function parseCounts(text)
local counts = { active = 0, inactive = 0 }
local current
for line in mw.text.gsplit(text, '\n') do
-- Detect Active/Inactive anchors
if line:find('vanchor|Active', 1, true) then
current = 'active'
elseif line:find('vanchor|Inactive', 1, true) then
current = 'inactive'
elseif current and mw.ustring.match(line, '^#') then
counts[current] = counts[current] + 1
end
end
return counts
end
-- Returns counts; accepts "active" or "inactive" or none
function p.getCount(frame)
local arg = frame.args[1]
local mode = arg and mw.text.trim(mw.ustring.lower(arg))
local counts = parseCounts(content)
if mode == 'active' then
return counts.active
elseif mode == 'inactive' then
return counts.inactive
else
return string.format("%d active, %d inactive", counts.active, counts.inactive)
end
end
-- Shortcuts
function p.activeCount()
return parseCounts(content).active
end
function p.inactiveCount()
return parseCounts(content).inactive
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.