Module:MatchList: Difference between revisions

From TwogPedia
mNo edit summary
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 10: Line 10:
     if args.bestof then VariablesLua.vardefine('bestof', args.bestof) end
     if args.bestof then VariablesLua.vardefine('bestof', args.bestof) end
     if args.stage then VariablesLua.vardefine('stage', args.stage) end
     if args.stage then VariablesLua.vardefine('stage', args.stage) end
    if args.twitch then VariablesLua.vardefine('twitch', args.twitch) end
if args.youtube then VariablesLua.vardefine('youtube', args.youtube) end
local tableContainer = mw.html.create('div')
local tableContainer = mw.html.create('div')
:addClass('matchList matchInfo')
:addClass('matchList matchInfo')
Line 36: Line 38:
-- if tournament, title, promote, relegate ~= nil
-- if tournament, title, promote, relegate ~= nil
-- reset matchList var value
-- reset var values
VariablesLua.vardefine('matchList', 0)
VariablesLua.vardefine('matchList', 0)
    if args.stage then VariablesLua.vardefine('stage', 0) end
    if args.twitch then VariablesLua.vardefine('twitch', 0) end
if args.youtube then VariablesLua.vardefine('youtube', 0) end
return tableContainer
return tableContainer
end
end


return MatchList
return MatchList

Latest revision as of 22:34, 16 October 2023

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

local getArgs = require('Module:Arguments').getArgs

local MatchList = {}

local VariablesLua = mw.ext.VariablesLua

function MatchList.main(frame)
	local args = getArgs(frame)
	VariablesLua.vardefine('matchList', 1)
    if args.bestof then VariablesLua.vardefine('bestof', args.bestof) end
    if args.stage then VariablesLua.vardefine('stage', args.stage) end
    if args.twitch then VariablesLua.vardefine('twitch', args.twitch) end
	if args.youtube then VariablesLua.vardefine('youtube', args.youtube) end
	local tableContainer = mw.html.create('div')
		:addClass('matchList matchInfo')
		:css('width', args.width or '350px')
	
	local title = mw.html.create('div')
		:addClass('matchList-title')
		:wikitext(args.title)
		
	tableContainer:node(title)
	
	local i = 1
	
	while (args[i] ~= nil) do
		if string.find(args[i], '<div') ~= nil then
			tableContainer:node(args[i])
		else 
			local playday = mw.html.create('div')
				:addClass('matchList-playday')
				:wikitext(args[i])
			tableContainer:node(playday)
		end
		
		i = i + 1
	end
	-- if tournament, title, promote, relegate ~= nil
	
	-- reset var values
	VariablesLua.vardefine('matchList', 0)
    if args.stage then VariablesLua.vardefine('stage', 0) end
    if args.twitch then VariablesLua.vardefine('twitch', 0) end
	if args.youtube then VariablesLua.vardefine('youtube', 0) end
	return tableContainer
end

return MatchList