Homepage
Games
News
News βΎ
All
Transfers
Drama
Business
Sponsors
Mergers
Investors
Hires
Companies
More
People
Tournaments
Brands
Brands βΎ
Companies
Organizations
Sponsors
Other
Locations
Search
Editing
Module:Infobox/Widget/Tournaments
From TwogPedia
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local getArgs = require('Module:Arguments').getArgs local cargo = mw.ext.cargo local func = require('Module:Functions') local UpcomingMatches = require('Module:Infobox/Widget/Upcoming matches').get local Subheader = require('Module:Infobox/Widget/Subheader') local Functions = require('Module:Functions') local stringifyDate = Functions.stringifyDate local getTeamLogo = Functions.getTeamLogo local timeUntil = Functions.timeUntil local colorModeDiv = Functions.colorModeDiv local p = {} function p.get(frame) local args = getArgs(frame) local team = args.team local currentDate = os.date('%Y-%m-%d') -- Get live tournaments local tables = 'Tournaments, Participants' local fields = 'Tournaments._pageName=_pageName, Tournaments.start=start, Tournaments.end=end, Tournaments.logoAll=logoAll, Tournaments.logoLight=logoLight, Tournaments.logoDark=logoDark, Tournaments.iconAll=iconAll, Tournaments.iconLight=iconLight, Tournaments.iconDark=iconDark, Participants.team=team' local currentPage = mw.title.getCurrentTitle().text local cargoArgs = { join = 'Tournaments._pageName=Participants._pageName' } if not team then cargoArgs.where = '(Participants.players HOLDS "' .. currentPage .. '" OR Participants.coaches HOLDS "' .. currentPage .. '" OR Participants.analysts HOLDS "' .. currentPage .. '" OR Participants.managers HOLDS "' .. currentPage .. '") AND (Tournaments.start is NOT NULL AND Tournaments.start <= "' .. currentDate .. '") AND (Tournaments.end IS NOT NULL AND Tournaments.end >= "' .. currentDate .. '")' else cargoArgs.where = 'Participants.team = "' .. currentPage .. '" AND (Tournaments.start is NOT NULL AND Tournaments.start <= "' .. currentDate .. '") AND (Tournaments.end IS NOT NULL AND Tournaments.end >= "' .. currentDate .. '")' end local playerLiveResults = cargo.query(tables, fields, cargoArgs) local container = mw.html.create('div'):addClass('ib') local hasContents = false if #playerLiveResults > 0 then hasContents = true container:node(Subheader.make('Live tournaments')):node(p.tournamentWrapper(playerLiveResults, true)) end -- Get upcoming tournaments if not team then cargoArgs.where = '(Participants.players HOLDS "' .. currentPage .. '" OR Participants.coaches HOLDS "' .. currentPage .. '" OR Participants.analysts HOLDS "' .. currentPage .. '" OR Participants.managers HOLDS "' .. currentPage .. '") AND (Tournaments.start is NOT NULL AND Tournaments.start > "' .. currentDate .. '")' else cargoArgs.where = 'Participants.team = "' .. currentPage .. '" AND (Tournaments.start is NOT NULL AND Tournaments.start > "' .. currentDate .. '")' end local playerUpcomingResults = cargo.query(tables, fields, cargoArgs) if #playerUpcomingResults > 0 then hasContents = true container:node(Subheader.make('Upcoming tournaments')):node(p.tournamentWrapper(playerUpcomingResults)) end if not team and #playerUpcomingResults == 0 and #playerLiveResults == 0 then -- Get live tournaments for talent tables = 'Tournaments, Talent' fields = 'Tournaments._pageName=_pageName, Tournaments.start=start, Tournaments.end=end, Tournaments.logoAll=logoAll, Tournaments.logoLight=logoLight, Tournaments.logoDark=logoDark, Tournaments.iconAll=iconAll, Tournaments.iconLight=iconLight, Tournaments.iconDark=iconDark' cargoArgs = { join = 'Tournaments._pageName=Talent._pageName', where = 'Talent.people HOLDS "' .. currentPage .. '" AND (Tournaments.start is NOT NULL AND Tournaments.start <= "' .. currentDate .. '") AND (Tournaments.end IS NOT NULL AND Tournaments.end >= ' .. currentDate .. ')' } local talentLiveResults = cargo.query(tables, fields, cargoArgs) if #talentLiveResults > 0 then container:node(Subheader.make('Live tournaments')):node(p.tournamentWrapper(talentLiveResults, true)) end end if hasContents then return container else return end end function p.tournamentWrapper(results, live) local wrapper = mw.html.create('div'):attr('style', 'padding: 10px;') for i = 1, #results do local result = results[i] local dateDiv = mw.html.create('div') if live then if result['end'] then dateDiv:wikitext('Until ' ..stringifyDate(result['end']) ) else dateDiv:wikitext('Until TBD') end else dateDiv:wikitext('Starts on ' .. stringifyDate(result.start)) end local logoDiv = mw.html.create('div') local nameDiv = mw.html.create('div'):wikitext('[[' .. result._pageName .. ']]') local tournamentInfo = mw.html.create('div'):attr('style', 'display: flex; gap: 0.5rem; justify-content: center; align-items: center;'):node(dateDiv):node(logoDiv):node(nameDiv) local matches = mw.html.create('div') local tournamentContainer = mw.html.create('div'):node(tournamentInfo):node(matches) local iconSize = '30px' if result.iconAll then logoDiv:node('[[File:' .. result.iconAll .. '|' .. iconSize .. '|link=' .. result._pageName .. ']]') elseif result.iconLight and result.iconDark then logoDiv:node(colorModeDiv('[[File:' .. result.iconLight .. '|' .. iconSize .. '|link=' .. result._pageName .. ']]', '[[File:' .. result.iconDark .. '|' .. iconSize .. '|link=' .. result._pageName .. ']]')) elseif result.logoAll then logoDiv:node('[[File:' .. result.logoAll .. '|' .. iconSize .. '|link=' .. result._pageName .. ']]') elseif result.logoLight and result.logoDark then logoDiv:node(colorModeDiv('[[File:' .. result.logoLight .. '|' .. iconSize .. '|link=' .. result._pageName .. ']]', '[[File:' .. result.logoDark .. '|' .. iconSize .. '|link=' .. result._pageName .. ']]')) else local logo = result.iconLight or result.iconDark or result.logoLight or result.logoDark logoDiv:node('[[File:' .. logo .. '|' .. iconSize .. '|link=' .. result._pageName .. ']]') end -- Check if any upcoming or live matches for this tournament and player tournamentContainer:node(UpcomingMatches(result._pageName, result.team)) wrapper:node(tournamentContainer) end return wrapper end return p
Summary:
Please note that all contributions to TwogPedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
TwogPedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Template used on this page:
Module:Infobox/Widget/Tournaments/doc
(
edit
)
No categories
Edit