Please join this new Discord server!

Merge notice

Module:Infobox

From Etrian Odyssey Wiki
This documentation is transcluded from Module:Infobox/doc. To edit this documentation, click here.

Used by {{Infobox}} to generate uniform infoboxes.

Should not be used outside that template. Information on implementing infoboxes can be found at Template:Infobox/doc.



local p = {}

function p.infobox(frame)
	-- Name input for convenience
	local in_args = frame:getParent().args
	
	local params = {}
	local values = {}
	
	for k, v in pairs(in_args) do
		if type(k) ~= "number" then
			if k:sub(1,5) == "param" then
				local i = tonumber(k:sub(6))
				params[i] = v
			elseif k:sub(1,5) == "value" then
				local i = tonumber(k:sub(6))
				values[i] = v
			end
		end
	end
	
	local infobox_output = mw.html.create("table")
		:addClass("wikitable")
		:css("float", "right")
		:css("width", in_args.width)
		:css("font-size", "90%")
		:tag("tr")
			:tag("th")
				:attr("colspan", "2")
				:wikitext(in_args.title)
				:done()
			:done()
		:tag("tr")
			:tag("td")
				:attr("colspan", "2")
				:css("font-size", "90%")
				:css("text-align", "center")
				:wikitext(in_args.image)
				:done()
			:done()
	
	for i = 1, #params do
		local tr = infobox_output:tag("tr")
		if values[i] ~= "" and values[i] ~= nil then
			tr:tag("td")
				:css("width", "40%")
				:tag("strong")
					:wikitext(params[i])
					:done()
				:done()
			:tag("td")
				:css("width", "60%")
				:wikitext(values[i])
				:done()
			:done()
		end
	end
	
	return infobox_output
end

return p