Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Humanipedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:United Nations Security Council election results
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} local function addNumbers (label,data) maxcols = math.max (maxcols,#data) table.insert (array,data) table.insert (labels,label) end local function addRow (label,data) data = mw.text.split(data,",") for i = 1,#data do data [i] = tonumber (data [i]) end addNumbers (label,data) end local function appendLine (line) result = result .. line .. "\n" end local function buildReferences (r) r.ref1 = r.ref or r.ref1 r.ref_name1 = r.ref_name or r.ref_name1 local s = "" local i = 1 while true do local ref = r ["ref" .. i] local ref_name = r ["ref_name" .. i] -- an actual reference and/or a reference name may be provided if not (ref or ref_name) then return s end s = s .. "<ref" if ref_name then s = s .. " name=\"" .. ref_name .. "\"" end s = s .. ">" .. (ref or "") .. "</ref>" i = i + 1 end end function p.table (frame) labels = {} -- first column array = {} -- matrix of numeric data maxcols = 0 -- maximum number of columns -- iterate over the numbered arguments with country data, e.g. ITA:113,92,94,95,95 for i,parameter in ipairs (frame.args) do local parts = mw.text.split (parameter,":") addRow (frame:expandTemplate{title = parts [1],args = {unpack (parts,2,#parts - 1)}},parts [#parts]); -- ITA yields {{ITA}}, flag:Peru:state yields {{flag|Peru|state}} end local last = #array addRow ("valid ballots",frame.args.valid) if frame.args.invalid and string.match(frame.args.invalid,"[^0,]") then addRow ("invalid ballots",frame.args.invalid) -- add invalid ballots if theyโre specified and not all zero end addRow ("abstentions",frame.args.abstentions) -- compute vote count and required majority from counts of ballots and abstensions local voting = {} local required = {} for i=1,maxcols do local votes = array [last + 1] [i] - array [#array] [i] -- valid ballots minus abstentions table.insert (voting,votes) table.insert (required,math.ceil (votes * 2 / 3)) end addNumbers ("present and voting",voting) addNumbers ("required majority",required) result = "" appendLine ("{| class=\"wikitable collapsible\" style=\"text-align: center;\""); appendLine ("|-") appendLine ("! colspan=\"" .. (maxcols + 1) .. "\" | " .. frame.args.group .. " election results" .. (frame.args.day and (" โ day " .. frame.args.day) or "") .. frame:preprocess (buildReferences (frame.args))) appendLine ("|-") appendLine ("! Member") local round = frame.args.round or 1 for i=0,maxcols - 1 do appendLine ("| style=\"background:silver;\"|'''Round " .. (i + round) .. "'''") end for j,label in ipairs (labels) do result = result .. "|-\n| style=\"text-align:left;\" | " .. label local isCountry = j <= last for i=1,maxcols do local value = array [j] [i] local bold = isCountry and value and value >= array [#array] [i] and "'''" or "" -- bold vote count if itโs at least the required majority result = result .. "|| " .. bold .. ((not isCountry or (value and value ~= 0)) and value or "โ") .. bold -- missing or zero vote counts are replaced by em dashes end result = result .. "\n" end result = result .. "|}" return result end return p
Summary:
Please note that all contributions to Humanipedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Humanipedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Country data Peru
(
edit
)
Template:Demo
(
edit
)
Template:Demo inline
(
edit
)
Template:ETH
(
edit
)
Template:Flag
(
edit
)
Template:Flag/core
(
edit
)
Template:ITA
(
edit
)
Template:KAZ
(
edit
)
Template:Replace
(
edit
)
Template:Sandbox other
(
edit
)
Template:THA
(
edit
)
Template:UN document
(
edit
)
Module:Arguments
(
edit
)
Module:Demo
(
edit
)
Module:Flag
(
edit
)
Module:String
(
edit
)
Module:United Nations Security Council election results
(
edit
)
Module:United Nations Security Council election results/doc
(
edit
)