Module:Common/Draft

--[[

PLEASE DON'T CHANGE ANYTHING HERE WITHOUT KNOWING WHAT YOU ARE DOING AND FIRST DISCUSSING IT.

THIS CODE IS USED BY MULTIPLE OTHER MODULES AND TEMPLATES.

THANKS <3

]]

local p = {}

function p.getRedirectContent( pageTitle ) if pageTitle.isRedirect then local redirectPageName = pageTitle:getContent:match( "%[%[(.-)%]%]" ) return p.getContent( redirectPageName, pageTitle.nsText, true ) else return pageTitle:getContent end end

function p.getContent( pageName, namespace, fromRedirect ) --Create new title object with given page name and namespace (EXPENSIVE) local titleObj = mw.title.new( pageName, namespace ) --Return page content if the page exists otherwise nil if titleObj.exists then if not fromRedirect then return p.getRedirectContent( titleObj ) else return titleObj:getContent end else return nil end --return titleObj.exists and titleObj:getContent or nil end

function p.getCharacterStatus( characterName ) local content = p.getContent(characterName):gsub( "%s+", "" ) :gsub( "_", "" ) :lower :gsub( "( .+ )", "" )

if not content:find( "" ) then if not content:find( "" ) then return "Unknown" else content = content:sub( content:find( "" ), -1 ) :match('%b{}') end else content = content:sub( content:find( "" ), -1 ) :match('%b{}') end

--content = content:sub( content:find( "" ), -1 ) --	:match('%b{}')

local matches = {} local validStatuses = {"active", "inactive", "banned", "deceased"}

for s in content:gmatch("|status=(.-)[|}]") do		for _, status in pairs(validStatuses) do			if s == status then table.insert(matches, s)				break end end end

if matches[#matches] == "banned" then return "Inactive" elseif matches[#matches] then return mw.language.new("en"):ucfirst(matches[#matches]) else return "Active" end end

function p.getNamedArgs( argNames, frameArgs, templateArgs ) local argVals = {} local argCount = 1 for i=1, #argNames do		argVals[argNames[i][1]:lower] = mw.text.trim(frameArgs[i]) for _, a in ipairs(argNames[i]) do			if templateArgs[a] then argCount = argCount+1 break end end end return argCount, argVals end

function p.boxShadow( val ) if val ~= '' and val ~= nil then return '-o-box-shadow: ' .. val .. '; ' ..			'-ms-box-shadow: ' .. val .. '; ' ..			'-moz-box-shadow: ' .. val .. '; ' ..			'-webkit-box-shadow: ' .. val .. '; ' ..			'box-shadow: ' .. val .. '; '	else return '' end end

return p