local p = {}
local Userbox = require('Module:Userbox')
local getArgs = require('Module:Arguments').getArgs
local function urlencode(text)
-- Return equivalent of {{urlencode:text}}.
local function byte(char)
return string.format('%%%02X', string.byte(char))
end
return text:gsub('[^ %w%-._]', byte):gsub(' ', '+')
end
local function formatNumber(number)
return mw.getContentLanguage():formatNum( tonumber(number) )
end
function p.contrib(frame, args)
if not args then
args = getArgs(frame)
end
local count = tonumber(args[1])
local id_fc, id_c, info_fc, info_c
if count < 5000 then id_fc = '#ffffff'; id_c = '#186A3B'; info_fc = '#000000'; info_c = '#1D8348'
elseif count < 10000 then id_fc = '#ffffff'; id_c = '#1D8348'; info_fc = '#000000'; info_c = '#239B56'
elseif count < 15000 then id_fc = '#ffffff'; id_c = '#239B56'; info_fc = '#000000'; info_c = '#28B463'
elseif count < 20000 then id_fc = '#000000'; id_c = '#28B463'; info_fc = '#000000'; info_c = '#2ECC71'
elseif count < 25000 then id_fc = '#000000'; id_c = '#2ECC71'; info_fc = '#ffffff'; info_c = '#58D68D'
elseif count < 30000 then id_fc = '#ffffff'; id_c = '#1B4F72'; info_fc = '#000000'; info_c = '#2874A6'
elseif count < 35000 then id_fc = '#ffffff'; id_c = '#2874A6'; info_fc = '#000000'; info_c = '#3498DB'
elseif count < 40000 then id_fc = '#ffffff'; id_c = '#3498DB'; info_fc = '#000000'; info_c = '#85C1E9'
elseif count < 45000 then id_fc = '#000000'; id_c = '#85C1E9'; info_fc = '#000000'; info_c = '#D6EAF8'
elseif count < 50000 then id_fc = '#000000'; id_c = '#D6EAF8'; info_fc = '#ffffff'; info_c = '#1B4F72'
-- https://htmlcolorcodes.com/
elseif count < 55000 then id_fc = '#ffffff'; id_c = '#4A235A'; info_fc = '#000000'; info_c = '#6C3483'
elseif count < 60000 then id_fc = '#ffffff'; id_c = '#6C3483'; info_fc = '#000000'; info_c = '#8E44AD'
elseif count < 65000 then id_fc = '#ffffff'; id_c = '#8E44AD'; info_fc = '#000000'; info_c = '#BB8FCE'
elseif count < 70000 then id_fc = '#000000'; id_c = '#BB8FCE'; info_fc = '#000000'; info_c = '#E8DAEF'
elseif count < 75000 then id_fc = '#000000'; id_c = '#E8DAEF'; info_fc = '#ffffff'; info_c = '#4A235A'
elseif count < 80000 then id_fc = '#000000'; id_c = '#dddddd'; info_fc = '#000000'; info_c = '#eeeeee'
elseif count < 85000 then id_fc = '#000000'; id_c = '#dddddd'; info_fc = '#000000'; info_c = '#eeeeee'
elseif count < 90000 then id_fc = '#ffffff'; id_c = '#000000'; info_fc = '#000000'; info_c = '#eeeeee'
elseif count < 95000 then id_fc = '#000000'; id_c = '#dddddd'; info_fc = '#000000'; info_c = '#eeeeee'
elseif count < 100000 then id_fc = '#000000'; id_c = '#33FFFF'; info_fc = '#000000'; info_c = '#99FFFF'
else id_fc = '#000000'; id_c = '#dddddd'; info_fc = '#000000'; info_c = '#eeeeee'
end
local user_args = {}
local language = ''
if args['lang'] then language = 'the '.. args['lang'] ..' ' end
local project = args['project'] or 'Wikipedia'
local project_site = args['projsite'] or 'en.wikipedia.org'
local username = args[2] or mw.title.getCurrentTitle().baseText
local url = 'https://xtools.wmflabs.org/ec/'.. project_site .. '/' ..urlencode(username)
local formated_count = mw.getContentLanguage():formatNum( count )
local deleted, articles, automated = '','',''
if args['deleted'] then deleted = 'over ' ..formatNumber(args['deleted'])..' of which were to pages that are now deleted' end
user_args['id-s'] = 12
user_args['info-c'] = info_c
user_args['id-c'] = id_c
user_args['info-fc'] = info_fc
user_args['id-fc'] = id_fc
user_args['id'] = formated_count .. '+'
user_args['info'] = '<span class="plainlinks neverexpand">This user has made ['
..url
..' <span style="color: '..info_fc
..'"> more than '
.. '<b>'..formated_count..'</b>'
.. ' contributions] to '.. language.. project
.. automated
.. deleted
.. articles
.. '.</span>'
return Userbox.main('_userbox', user_args)
end
return p
-- if modular < 5000 then font_color = '#f00'
-- elseif modular < 10000 then font_color = '#0f0'
-- elseif modular < 15000 then font_color = '#00f'
-- elseif modular < 20000 then font_color = '#f0f'
-- else font_color = '#0ff'
-- end
-- if count < 25000 then bg_color = '#eeeeee' id_color = '#dddddd'
-- elseif count < 50000 then bg_color = '#dddddd'; id_color = '#ccc'
-- elseif count < 75000 then bg_color = '#ccc'; id_color = '#bbb'
-- else bg_color = '#bbb'; id_color = '#aaa'
-- end