Vainglory Esports Wiki
Advertisement

To edit the documentation or categories for this module, click here.


local p = {}

function p.makeFootnoteN(n)
	if n and n ~= "" then
		return string.format('<span class="sup">%s</span>', n)
	end
	return ""
end

function p.vsAlign(team1, team2)
	local tbl = mw.html.create("div")
	tbl:css({ width = "100%", display = "table", ["table-layout"] = "fixed" })
	tbl:tag("div")
		:css({ ["text-align"] = "right", display = "table-cell" })
		:wikitext(team1)
	:done()
	:tag("div")
		:css({ display = "table-cell", width = "20px", ["text-align"] = "center" })
		:wikitext(" vs ")
	:done()
	:tag("div")
		:css({ ["text-align"] = "left", display = "table-cell" })
		:wikitext(team2)
	:done()
		
	return tbl
end

function p.makeNodeFromWikitext(text)
	local tbl = mw.html.create()
		:wikitext(text)
	return tbl
end

-- this function only makes the inner divs; it does not put the content into a table to restrict width, that's up to the parent function
-- as such, this adds to an existing html object and does not create its own
-- while content is a table, padding is a constant because why would you want variable padding
-- the name of this function is inherited from the template BlockBox
function p.blockBoxContent(content, padding, tbl)
	for k, v in ipairs(content) do
		div = tbl:tag('div')
		div:css({
			display = "inline-block",
			['vertical-align'] = 'top',
		})
		if padding and k ~= #content then
			div:css('padding-right',padding)
		end
		div:wikitext(v)
	end
	return
end

function p.blockBox(content, padding)
	local tbl = mw.html.create('table')
		:addClass('blockbox')
	local tr = tbl:tag('tr')
	local td = tr:tag('td')
	p.blockBoxContent(content, padding, td)
	return tbl
end

function p.makeEmptySortRow(tbl, n)
	local tr = tbl:tag('tr'):css('font-size','60%')
	for i = 1, n do
		tr:tag('th')
		:wikitext('&nbsp;')
	end
	return
end

function p.makeEmptyWidthRow(tbl, widths)
	local tr = tbl:tag('tr'):css({
		background = 'none',
		['white-space'] = 'nowrap',
		visibility = 'collapse'
	})
	for _, v in ipairs(widths) do
		tr:tag('td'):css('width', v .. 'px'):wikitext('&nbsp;')
	end
	return
end

function p.imageHTML(image, args)
	local text = string.format('<img src="%s/Special:Filepath/%s" width="%s" height="%s" title="%s" alt="%s">',
		mw.site.server,
		image,
		args.width or '',
		args.height or '',
		args.title or '',
		args.alt or args.title or ''
	)
	if args.link then
		return string.format('<a href="%s" title="%s">%s</a>', args.link, args.alt or args.title, text)
	end
	return text
end
return p
Advertisement