Module:HTMLUtil

local p = {}

function p.makeFootnoteN(n) if n and n ~= "" then return string.format(' %s ', 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(' ') 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(' ') end return end

function p.imageHTML(image, args) local text = string.format('',		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('%s', args.link, args.alt or args.title, text) end return text end

function p.makeHeader(tbl, data) local tr = tbl:tag('tr') for _, v in ipairs(data) do		tr:tag('th'):wikitext(v) end return end

function p.printRowsByArray(tbl, data) for _, row in ipairs(data) do		tbl:tag('tr') for _, cell in ipairs(row) do			tbl:tag('td'):wikitext(cell) end end return end

function p.printRowsByList(tbl, data, list) for _, row in ipairs(data) do		tbl:tag('tr') for _, item in ipairs(list) do			tbl:tag('td'):wikitext(row[item]) end end return end

return p