Khác biệt giữa bản sửa đổi của “Mô đun:Sandbox/Ioe2015/voteCount”
Nội dung được xóa Nội dung được thêm vào
Không có tóm lược sửa đổi |
Không có tóm lược sửa đổi |
||
Dòng 1:
local getArgs = require('Module:Arguments').getArgs
local TableTools = require('Module:TableTools')
local ColorContract = require("Module:Color contrast")
local p = {} -- Defines a variable p as an empty table, but *not* nil.
Hàng 205 ⟶ 206:
function p.getCountTable(templates)
function incTableVal(t, key)
local ret = {▼
if t[key] ~= nil then
total = 0,▼
else▼
delete = 0,▼
end▼
▲ local ret = {}
for _, template in pairs(templates) do
if p.isKeepVote(template) then
incTableVal(ret
elseif p.isDeleteVote(template) then
incTableVal(ret
elseif p.isAgreeVote(template) then
incTableVal(ret
elseif p.isDisagreeVote(template) then
incTableVal(ret
end
end
return ret▼
end▼
▲ return ret, total
end
Hàng 238 ⟶ 244:
function p._display(args)
local container = mw.html.create("div"):css({
float = "right",
["text-align"] = "center",
width = "70px",
height = "20px",
})
local templates = p.getVotingTemplates(p.getPage(args[1]))
local counts, total =
local
keep = "blue",
▲ for k, v in pairs(counts) do
agree = "green",
▲ }
▲ end
▲ end
▲ local i = 0
--for count, type in TableTools.sparseIpairs(counts) do
for
container:tag("span"):css({
▲ i = i + 1
width = mw.ustring.format("%.2f%%", count / total * 100),
height = "100%",
▲ else
["background-color"] = colorMap[type],
color = ColorContract._greatercontrast(
{colorMap[type], "white", "black"}
)
}):wikitext(count):done()
end
return
end
|