Module

WorldPills

From Dogcraft Wiki

m (Trying smaller pills)
Tag: Reverted
(Undo revision 37079 by Domino)
Tag: Undo
Line 6: Line 6:
function pill (text, color)
function pill (text, color)
return ('[[' .. text .. '|<span class="world-pill" style="background:' .. color ..  
return ('[[' .. text .. '|<span class="world-pill" style="background:' .. color ..  
'; padding: 3px 7px; color: white; font-weight: normal; font-size: small; border-radius: 7.5px; display: inline-block; margin-bottom:3px;">' .. text .. '</span>]]')
'; padding: 3px 7px; color: white; font-weight: bold; border-radius: 7.5px; display: inline-block; margin-bottom:3px;">' .. text .. '</span>]]')
end
end



Revision as of 23:51, 29 June 2024

Documentation for this module may be created at Module:WorldPills/doc

local p = {} --p stands for package
local worldTools = require('Module:World')

local lang = mw.language.getContentLanguage()

function pill (text, color)
	return ('[[' .. text .. '|<span class="world-pill" style="background:' .. color .. 
			'; padding: 3px 7px; color: white; font-weight: bold; border-radius: 7.5px; display: inline-block; margin-bottom:3px;">' .. text .. '</span>]]')
end


function p.single(frame)
	color = frame.args[color] or 'lightslategray'
	world= worldTools.extractWorld(frame.args[1] .. frame.args[2])
	subworld = worldTools.extractSubworld(frame.args[1] .. frame.args[2])
	
	if (subworld ~= '') then
		return (pill(lang:ucfirst(world), color) .. ' ' .. pill(lang:ucfirst(subworld), color))
	elseif (world ~= '') then
		return (pill(lang:ucfirst(world), color))
	else 
		return ''
	end
end


function p.multi(frame)
	color = frame.args[color] or 'lightslategray'
	frame.args[2] = frame.args[2] or ''
	input = mw.ustring.lower(frame.args[1] .. frame.args[2])
	out = ''
	
	for key,value in ipairs(worldTools.worlds) do 
		if (mw.ustring.find(input, value, 1, true) ~= nil) then
			value = lang:ucfirst(value)
			out = out .. pill(value, color) .. ' '
		end
	end
	
	return out
end


return p
This page was last modified on 29 June 2024, at 23:51. (2 months ago)
Background Takeshi by Edo