local navbar = require('Module:Navbar')._navbarlocal mm = require('Module:Math')local p =
local function stripToNil(text) -- If text is a string, return its trimmed content, or nil if empty. -- Otherwise return text (which may, for example, be nil). if type(text)
' .. ' ' .. percentDone .. '% completed
' .. '' return progBarTextendlocal levelNames = local levelTime = local levelEdits = function p.serviceLevel(args) --Inputs local editorTime = tonumber(stripToNil(args.editorTime)) local edits = tonumber(stripToNil(args.edits)) local styleoverride = stripToNil(args.styleoverride) local genderoverride = stripToNil(args.genderoverride) local url = stripToNil(args.url) -- Other Variables local timeLevel = -- Level associated with time local editLevel = -- Level associated with edits local userLevel = -- Full name of current user level local lowEdits = -- Minimum number of edits for current user level local lowTime = -- Minimum amount of time for current user level local highEdits = -- Max number of edits for current user level local highTime = -- Max amount of time for current user level local nextLevel = -- Full name of next user level local fullMessage = '
= levelTime[x] then timeLevel = x break end end -- Fine "level" of editor based on edits for y = 1, 39, 1 do if edits >= levelEdits[y] then editLevel = y break end end -- Set user level and the next level up if timeLevel
1 then userLevel = levelNames[1] topLevel = true else userLevel = levelNames[editLevel] nextLevel = levelNames[editLevel-1] lowEdits = levelEdits[editLevel] highEdits = levelEdits[editLevel-1] lowTime = levelTime[editLevel] highTime = levelTime[editLevel-1] needsBoth = true end elseif timeLevel < editLevel then userLevel = levelNames[editLevel] nextLevel = levelNames[editLevel-1] lowEdits = levelEdits[editLevel] highEdits = levelEdits[editLevel-1] lowTime = levelTime[editLevel] highTime = levelTime[editLevel-1] needsEdits = true else userLevel = levelNames[timeLevel] nextLevel = levelNames[timeLevel-1] lowEdits = levelEdits[timeLevel] highEdits = levelEdits[timeLevel-1] lowTime = levelTime[timeLevel] highTime = levelTime[timeLevel-1] needsTime = true end -- Build notice -- First paragraph fullMessage = fullMessage .. styleoverride .. '">' .. navbar .. 'Currently, this editor has earned the ' .. userLevel .. ' service award.
' if topLevel then fullMessage = fullMessage .. '
This is the highest level achievable by an editor!
' else fullMessage = fullMessage .. '
To get to the next level, ' .. nextLevel .. ', ' .. genderoverride .. ' to meet the ' if needsBoth then fullMessage = fullMessage .. 'editing and the time requirement.
' elseif needsEdits then fullMessage = fullMessage .. 'editing requirement.
' else fullMessage = fullMessage .. 'time requirement.
function p.main(frame) return p.serviceLevel(frame.args)end
return p