local p =
local function addRow (label,data) data = mw.text.split(data,",") for i = 1,#data do data [i] = tonumber (data [i]) end max = math.max (max,#data) table.insert (array,data) table.insert (labels,label)end
local function appendLine (line) result = result .. line .. "\n"end
local function buildReference (r) local s = "" if r.ref or r.ref_name then s = s .. "[1] " end return send
function p.table (frame) labels = array = max = 0 for i,parameter in ipairs (frame.args) do local parts = mw.text.split (parameter,":") addRow (frame:expandTemplate,parts [2]); end addRow ("valid ballots",frame.args.valid) addRow ("abstentions",frame.args.abstentions) addRow ("present and voting",frame.args.voting) addRow ("required majority",frame.args.required) result = "" appendLine ("
-") appendLine ("! colspan=\"" .. (max + 1) .. "\" | " .. frame.args.group .. " election results" .. frame:preprocess (buildReference (frame.args))) appendLine (" | -") appendLine ("! Member") for i=1,max do appendLine (" | style=\"background:silver;\" | Round " .. i .. "") end for j,label in ipairs (labels) do result = result .. " | -\n | style=\"text-align:left;\" | " .. label for i=1,max do local value = array [j] [i] local bold = j < #array - 1 and value and value >= array [#array] [i] and "" or "" result = result .. " | " .. bold .. (value or "—") .. bold end result = result .. "\n" end appendLine (" |
return resultend
return p