Jump to content

Module:User contrib

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Zackmann08 (talk | contribs) at 19:09, 16 October 2018. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}
local Userbox = require('Module:Userbox')
local getArgs = require('Module:Arguments').getArgs

function p.contrib(frame, args)
	if not args then
		args = getArgs(frame)
	end
	local count = tonumber(args[1])
	local username = args[2] or mw.title.getCurrentTitle().baseText
	local font_color
	local bg_color
	local id_color = '#111'
	
	local modular = math.fmod (count, 25000)
	
	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 = '#eee'; id_color = '#ddd'
	elseif count < 50000 then bg_color = '#ddd'; id_color = '#ccc'
	elseif count < 75000 then bg_color = '#ccc'; id_color = '#bbb'
	else					  bg_color = '#bbb'; id_color = '#aaa'
	end
	
	-- mw.log(count)
	-- id-color	id-bg	info-color	info-bg
	local user_args = {}
	-- local id_color		= '#ff0000'
	-- local id_bg 		= '#00ff00'
	-- local info_color	= '#0000ff'
	-- local info_bg		= '#ff00ff'
	-- -- local root = mw.html.create()
	
	user_args['info-c']	 = bg_color
	user_args['id-c']    = id_color
	user_args['info-fc'] = font_color
	user_args['id-fc']	 = font_color
	user_args['id'] = args[1] .. '+'
	user_args['info'] = username ..'This user has made more than ' .. args[1] .. ' [https://xtools.wmflabs.org/ec/en.wikipedia.org/'..username..' contributions] to Wikipedia.'
	
	return Userbox.main('_userbox', user_args)
end

return p

	
	-- {{userbox
	-- 	| border-c      = 
	-- 	| id            = 
	-- 	| id-c          = 
	-- 	| id-fc         = 
	-- 	| id-s          = 
	-- 	| info          = 
	-- 	| info-c        = 
	-- 	| info-fc       = 
	-- 	| info-lh       = 
	-- 	| info-s        = 
	-- }}