Module:SpoilerFreeSchedule

local p = {}

function p.spoilerFreeSchedule ( frame ) if frame == mw.getCurrentFrame then args = require( 'Module:ProcessArgs' ).merge( true ) else frame = mw.getCurrentFrame end local Team = require('Module:Team').team local customwidth = args["customwidth"] or 300 local pagename = tostring(mw.title.new(args[1] or '').redirectTarget or args[1]) local text = {} text[#text+1] = "Click here to view tournament page." text[#text+1] = '\n{|class="wikitable" style="text-align:center"' local gametime = {} local countdownI = 0 local phaseSettings = { [1] = { ['?toggle'] = 'UpcomingNo', ['?hidden'] = '_tog_object_inithide', ['?where'] = '<', ['?title'] = "Completed" }, [2] = { ['?toggle'] = 'UpcomingYes', ['?hidden'] = '', ['?where'] = '>', ['?title'] = "Upcoming" } }	for phase = 1, 2 do text[#text+1] = '\n|-\n! colspan=20 class="_tog_object _toggler-' .. phaseSettings[phase]['?toggle'] .. '" | [Show/Hide] ' .. phaseSettings[phase]['?title'] .. ' Matches' text[#text+1] = '\n|- style="background:none;white-space:nowrap;visibility:collapse;"' text[#text+1] = '\n| style="width:65px;"| ' text[#text+1] = '\n| style="width:' .. customwidth .. 'px;"| ' text[#text+1] = '\n| style="width:120px;" | ' text[#text+1] = '\n| style="width:40px;" | ' text[#text+1] = '\n| style="width:40px;" | ' text[#text+1] = '\n| style="width:40px;" | ' text[#text+1] = '\n| style="width:40px;" | ' text[#text+1] = '\n| style="width:85px;" | ' text[#text+1] = '\n| style="width:125px;" | ' text[#text+1] = '\n|-class="_tog_object _toggle ' .. phaseSettings[phase]['?toggle'] .. ' ' .. phaseSettings[phase]['?hidden'] .. '"\n! style="width:65px;"| Round\n! style="width:' .. customwidth .. 'px;"| Match\n! style="width:120px" | Date \n! style="width:40px" | YOU \n! style="width:40px;" | PST\n! style="width:40px;" | CET\n! style="width:40px;" | KST\n! style="width:85px;" | Countdown\n! style="width:125px;" | VoDs/Stream\n|- ' local cargotable = "GameSchedule" local cargofields = 'Team1=team1,Team2=team2,Round=round,DateTime=datetime,Time_PST=PST,Time_CET=CET,Time_KST=KST,Stream=stream,Vod1=vod1,Vod2=vod2,Vod3=vod3,Vod4=vod4,Vod5=vod5,Vod6=vod6' local cargoquery = {where='_pageName = "' .. pagename .. '" AND DateTime ' .. phaseSettings[phase]['?where'] .. ' NOW',groupBy='UniqueLine',orderBy='DateTime'} result = mw.ext.cargo.query(cargotable, cargofields, cargoquery) for _, row in ipairs(result) do text[#text+1] = '\n|-class="_tog_object _toggle ' .. phaseSettings[phase]['?toggle'] .. ' ' .. phaseSettings[phase]['?hidden'] .. '"' text[#text+1] = '\n|' .. row.round text[#text+1] = '\n|style="whitespace:nowrap;text-align:left;"|' .. Team{row["team1"],"leftshortlinked"} .. ' vs ' .. Team{row["team2"],"rightshortlinked"} .. ' '			if row.datetime == "" then text[#text+1] = '\n| colspan = 6 style= "text-align:center;"| TBD' else local year, month, day, hour, minute, second = string.match(row["datetime"], "(%d%d%d%d)-(%d%d)-(%d%d) (%d%d):(%d%d):(%d%d)") gametime = {["year"] = year, ["month"] = month, ["day"] = day, ["hour"] = hour, ["min"] = minute, ["sec"] = second} text[#text+1] = '\n| ' .. mw.getLanguage('en'):formatDate("Y,n,d,H,i",row.datetime) .. ' '				if row.PST == "" then text[#text+1] = '\n| colspan=4 style="text-align:center;"| TBD ' else text[#text+1] = '\n| ' .. mw.getLanguage('en'):formatDate("Y,n,d,H,i",row.datetime) .. ' '					text[#text+1] = '\n| ' .. string.match(row.PST,"(%d%d:%d%d):%d%d") text[#text+1] = '\n| ' .. string.match(row.CET,"(%d%d:%d%d):%d%d") text[#text+1] = '\n| ' .. string.match(row.KST,"(%d%d:%d%d):%d%d") end text[#text+1] = '\n| ' if os.difftime(os.time(gametime),os.time) > 0 then text[#text+1] = ' ' .. mw.getLanguage('en'):formatDate("j F Y H:i:s",row.datetime) .. ' +0000 - '				end

end text[#text+1] = '\n|' if row['vod1']~="" then local i = 1 while row['vod' .. i] ~= "" do text[#text+1] = "[" .. row['vod' .. i] .. " " .. i .. "]"					i = i + 1 end while row['vod' .. i] do text[#text+1] = '[http://lol.gamepedia.com ' .. i .. " ]"					i = i + 1 end elseif row['stream'] then text[#text+1] = "[" .. row['stream'] .. " Stream]" end end end text[#text+1] = "\n|}" return table.concat(text) end return p