Module:MatchHTML: Difference between revisions

From TwogPedia
(Created page with "local MatchHTML = {} local VariablesLua = mw.ext.VariablesLua function MatchHTML.team(name, score, rev) local teamName = name and mw.ext.displaytitle.get(name) or '' local team = mw.html.create('div'):addClass('team') local nameNode = mw.html.create('div'):wikitext(teamName):addClass('teamName') if rev and VariablesLua.var( 'matchList', 0 ) == '1' then team:addClass('reverse') end return team:node(nameNode):node(mw.html.create('div'):wikitext(score):addClass(...")
 
mNo edit summary
Line 14: Line 14:


function MatchHTML.teamHover(p1, p2, p1score, p2score, date)
function MatchHTML.teamHover(p1, p2, p1score, p2score, date)
if p1 == nil or p2 == nil then return '' end
local p1Link = p1 and '[[' .. p1 .. ']]' or 'TBD'
    local p2Link = p2 and '[[' .. p2 .. ']]' or 'TBD'
local hover = mw.html.create('div'):addClass('match-details')
local hover = mw.html.create('div'):addClass('match-details')
local header = mw.html.create('div'):addClass('details-header')
local header = mw.html.create('div'):addClass('details-header')
if p1 ~= nil and p2 ~= nil then
local hover1 = mw.html.create('div'):addClass('team')
local hover1 = mw.html.create('div'):addClass('team')
:node(mw.html.create('div'):wikitext(p1Link):addClass('teamName'))
:node(mw.html.create('div'):wikitext('[[' .. p1 .. ']]'):addClass('teamName'))
:node(mw.html.create('div'):wikitext(p1score):addClass('score'))
:node(mw.html.create('div'):wikitext(p1score):addClass('score'))
local hover2 = mw.html.create('div'):addClass('team reverse')
local hover2 = mw.html.create('div'):addClass('team reverse')
:node(mw.html.create('div'):wikitext(p2Link):addClass('teamName'))
:node(mw.html.create('div'):wikitext('[[' .. p2 .. ']]'):addClass('teamName'))
:node(mw.html.create('div'):wikitext(p2score):addClass('score'))
:node(mw.html.create('div'):wikitext(p2score):addClass('score'))
header:node(hover1):node(hover2)
header:node(hover1):node(hover2)
 
end
local date = mw.html.create('div'):addClass('tc'):wikitext(date)
local date = mw.html.create('div'):addClass('tc'):wikitext(date)

Revision as of 10:35, 5 October 2023

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

local MatchHTML = {}
local VariablesLua = mw.ext.VariablesLua

function MatchHTML.team(name, score, rev)
	local teamName = name and mw.ext.displaytitle.get(name) or ''
	local team = mw.html.create('div'):addClass('team')
	local nameNode = mw.html.create('div'):wikitext(teamName):addClass('teamName')
	if rev and VariablesLua.var( 'matchList', 0 ) == '1' then 
		team:addClass('reverse') 
	end

	return team:node(nameNode):node(mw.html.create('div'):wikitext(score):addClass('score'))
end 

function MatchHTML.teamHover(p1, p2, p1score, p2score, date)
	local p1Link = p1 and '[[' .. p1 .. ']]' or 'TBD'
    local p2Link = p2 and '[[' .. p2 .. ']]' or 'TBD'
	local hover = mw.html.create('div'):addClass('match-details')
	local header = mw.html.create('div'):addClass('details-header')
	
	local hover1 = mw.html.create('div'):addClass('team')
		:node(mw.html.create('div'):wikitext(p1Link):addClass('teamName'))
		:node(mw.html.create('div'):wikitext(p1score):addClass('score'))
	local hover2 = mw.html.create('div'):addClass('team reverse')
		:node(mw.html.create('div'):wikitext(p2Link):addClass('teamName'))
		:node(mw.html.create('div'):wikitext(p2score):addClass('score'))
		
	header:node(hover1):node(hover2)

	local date = mw.html.create('div'):addClass('tc'):wikitext(date)
	
	return hover:node(header):node(date)
end

return MatchHTML