پودمان:جدول نامزدهای هیئت نظارت
ظاهر
function admins(frame)
local rawList = mw.text.unstrip(frame:preprocess('{{ویژه:فهرست کاربران/sysop}}'))
local ret = {}
mw.ustring.gsub(rawList, 'mw%-userlink"%>(.-)%<%/a%>', function (user)
ret[user] = true
end)
return ret
end
return {
main = function (frame)
-- local adminsTable = admins(frame)
local adminsTable={"Ariobarzan", "AzorAhai", "Behaafarid", "Behzad.Modares", "Calak", "Ebrahim", "Fatemi", "Grim reaper", "Huji", "In twilight", "Kamix", "Ladsgroup", "MRG90", "Mahdiz", "Mardetanha", "Mehran", "PHoBiA", "Raamin", "Rezabot", "Sahehco", "Taranet", "Yamaha5", "ZxxZxxZ", "آرش" ,"ارژنگ" ,"درفش_کاویانی" ,"ظهیری" ,"ماني" ,"نوژن" ,"همان"}
local result = ''
for user in mw.text.gsplit(frame.args[2], ':') do
local text = mw.title.new("انتخابات هیئت نظارت/" .. frame.args[1] .. "/" .. user, "ویکیپدیا"):getContent()
local _, support = mw.ustring.gsub(text, "رای=موافق[^\n]+c=[pپ]", "")
if support == nil then support = 0 end
local _, oppose = mw.ustring.gsub(text, "رای=مخالف[^\n]+c=[pپ]", "")
if oppose == nil then oppose = 0 end
local _, failed = mw.ustring.gsub(text, "c=[fر]", "")
if failed == nil then failed = 0 end
local _, total = mw.ustring.gsub(text, "رای=", "")
if total == nil then total = 0 end
local pending = total - support - oppose - failed
for _,v in pairs(adminsTable) do
if v == user then
admin = 'بله'
break
end
admin = 'خیر'
end
local totalChecked = support + oppose
local ratio = totalChecked == 0 and 1 or (support / totalChecked)
ratio = math.floor(ratio * 10000) / 100
local status = '<b style="color: '
if ratio >= 80 then
status = status .. 'green'
elseif ratio >= 50 then
status = status .. '#FADA5E'
else
status = status .. '#AB4E52'
end
local lang = mw.message.getDefaultLanguage()
status = status .. '">' .. lang:formatNum(ratio) .. '</b>'
result = result .. "{{ویکیپدیا:انتخابات هیئت نظارت/" ..
frame.args[1] .."/نامزدها/سطر|" .. user .. "|" ..
lang:formatNum(support) .. "|" .. lang:formatNum(oppose) ..
"|" .. lang:formatNum(pending) .. "|" ..
admin .. "|" ..
'status=' .. status .. "}}" .. "\n|-\n"
end
return frame:preprocess(result)
end
}