Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
Advertisement

Documentation for this module may be created at Module:API info/main/api/doc

local flavor_module = require("Module:API_info/flavor")
local elink_module = require("Module:API_info/elink")
local patch_module = require("Module:API_info/patch")
-- dont show the infobox when multiple apis are documented on the same page 
local multi_api = mw.loadData("Module:API_info/multi_api")
local m = {}

local comparison = {
	a = "Global_functions/Classic",
	e = "Events/Classic",
}

local HTML_LIST_START = '<ul class="plainlinks elinks">\n'
local HTML_LIST_ITEM = [=[<li style="padding-left: 0px; min-height: %dpx">%s %s</li>
]=]
local HTML_LIST_END = '</ul>'

local function GetFlavorText(name, args)
	local flavors = flavor_module:GetFlavors(name, args.t)
	if flavors then
		local s = HTML_LIST_START
		for _, info in pairs(flavors) do
			s = s..HTML_LIST_ITEM:format(0, info.icon, info.link)
		end
		s = s..HTML_LIST_END
		return s
	end
end

local function GetElinksText(name, args)
	local elinks = elink_module:GetElinks(name, args.t)
	if next(elinks) then
		local s = HTML_LIST_START
		for _, info in pairs(elinks) do
			s = s..HTML_LIST_ITEM:format(25, info.icon, "&nbsp;"..info.link)
		end
		s = s..HTML_LIST_END
		return s
	end
end

local function GetInfobox(name, args)
	local flavorText = GetFlavorText(name, args)
	local elinksText = GetElinksText(name, args)
	if flavorText or elinksText then
		local s = '<div class="nomobile" style="float:right; clear:right">\n{| class="darktable" style="min-width:142px;"'
		if flavorText then
			s = s..string.format("\n|-\n! Game [[%s|Flavors]]\n|-\n| %s", comparison[args.t], flavorText)
		end
		if elinksText then
			s = s.."\n|-\n! Links\n|-\n| "..elinksText
		end
		local added, removed = patch_module:GetPatches(name)
		if #added > 0 then
			s = s.."\n|-\n! Patch"
			s = s.."\n|-\n| Added in "..added
			if #removed > 0 then
				s = s.."\n|-\n| Removed in "..removed
			end
		end
		s = s.."\n|}\n</div>"
		return s
	end
end

function m.main(f)
	local PAGENAME = f.args[1]
	local name = PAGENAME:gsub("API ", ""):gsub(" ", "_")
	if not multi_api[PAGENAME] then
		return GetInfobox(name, f.args)
	end
end

return m
Advertisement