(Created page with "local cargo = mw.ext.cargo local p = {} local getTeamLogo = require('Module:Functions').getTeamLogo local prizeToString = require('Module:Functions').prizeToString function p.upcomingMatches(game) local tables = 'AllMatches' local fields = '_pageName, date, p1, p2, winner' local currentDate = os.date('%Y-%m-%d') local cargoArgs = { where = '_pageName LIKE "' .. game .. '/%" AND ( date > "' .. currentDate .. '" OR winner=0)', orderBy = 'date ASC', limit = 10...") |
mNo edit summary |
||
Line 1: | Line 1: | ||
local cargo = mw.ext.cargo | local cargo = mw.ext.cargo | ||
local p = {} | local p = {} | ||
local | local Functions = require('Module:Functions') | ||
local prizeToString = | local getTeamLogo = Functions.getTeamLogo | ||
local prizeToString = Functions.prizeToString | |||
local timeUntil = Functions.timeUntil | |||
Line 31: | Line 33: | ||
local team2 = mw.html.create('div') | local team2 = mw.html.create('div') | ||
time:wikitext(timeUntil(result.date)) | |||
team1:node(mw.html.create('div'):addClass('transfer__player'):node(getTeamLogo(result.p1, game)):node('[[' .. result.p1 .. '|' .. string.gsub(result.p1, game .. '/', '') .. ']]')) | team1:node(mw.html.create('div'):addClass('transfer__player'):node(getTeamLogo(result.p1, game)):node('[[' .. result.p1 .. '|' .. string.gsub(result.p1, game .. '/', '') .. ']]')) |
Revision as of 08:38, 9 October 2023
Documentation for this module may be created at Module:GameLanding/Upcoming matches/doc
local cargo = mw.ext.cargo
local p = {}
local Functions = require('Module:Functions')
local getTeamLogo = Functions.getTeamLogo
local prizeToString = Functions.prizeToString
local timeUntil = Functions.timeUntil
function p.upcomingMatches(game)
local tables = 'AllMatches'
local fields = '_pageName, date, p1, p2, winner'
local currentDate = os.date('%Y-%m-%d')
local cargoArgs = {
where = '_pageName LIKE "' .. game .. '/%" AND ( date > "' .. currentDate .. '" OR winner=0)',
orderBy = 'date ASC',
limit = 10
}
local results = cargo.query(tables, fields, cargoArgs)
if #results > 0 then
local list = ''
local header = mw.html.create('div'):addClass('transfer__header transfer__row'):node(mw.html.create('div'):wikitext('Time')):node(mw.html.create('div'):wikitext('Team 1')):node(mw.html.create('div'):wikitext('')):node(mw.html.create('div'):wikitext('Team 2'))
local wrapper = mw.html.create('div'):addClass('transfer__container'):node(header)
local header = mw.html.create('div'):addClass('transfer__header'):node(mw.html.create('div'):wikitext('Time')):node(mw.html.create('div'):wikitext('Team 1')):node(mw.html.create('div'):wikitext('')):node(mw.html.create('div'):wikitext('Team 2'))
local container = mw.html.create('div'):addClass('box__container'):node(mw.html.create('div'):addClass('box__title'):wikitext('Upcoming matches')):node(wrapper)
for i = 1, #results do
local result = results[i]
local row = mw.html.create('div'):addClass('transfer__row')
local time = mw.html.create('div')
local team1 = mw.html.create('div')
local vs = mw.html.create('div'):wikitext('[[' .. result._pageName .. '|vs]]')
local team2 = mw.html.create('div')
time:wikitext(timeUntil(result.date))
team1:node(mw.html.create('div'):addClass('transfer__player'):node(getTeamLogo(result.p1, game)):node('[[' .. result.p1 .. '|' .. string.gsub(result.p1, game .. '/', '') .. ']]'))
team2:node(mw.html.create('div'):addClass('transfer__player'):node(getTeamLogo(result.p2, game)):node('[[' .. result.p2 .. '|' .. string.gsub(result.p2, game .. '/', '') .. ']]'))
row:node(time):node(team1):node(vs):node(team2)
wrapper:node(row)
end
return container
end
return nil
end
return p