VOOZH about

URL: https://en.wikipedia.org/wiki/Module:Football_box

⇱ Module:Football box - Wikipedia


Jump to content
From Wikipedia, the free encyclopedia
👁 Image
Module documentation
[view] [edit] [history] [purge]
👁 Warning
This Lua module is used on approximately 29,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them.
👁 Image
This module depends on the following other modules:
👁 CSS
This module uses TemplateStyles:

Implements {{Football box}}

-- Implements [[Template:Football box]]
localp={}
locallang=nil
localdelink=require('Module:Delink')._delink
localeventschema="http://schema.org/SportsEvent"
localteamschema="http://schema.org/SportsTeam"
localplaceschema="http://schema.org/Place"
localpenalties='[[Penalty shoot-out (association football)|Penalties]]'
localaet='[[Overtime (sports)#Association football|a.e.t.]]'
localasdet='[[Sudden death (sport)#Association football|a.s.d.e.t.]]'
localagget='[[Overtime (sports)#Association football|a.e.t.]]/[[Golden goal#Association football|g.g.]]'
localasget='[[Overtime (sports)#Association football|a.e.t.]]/[[Silver goal|s.g.]]'
localattendance='Attendance:'
localreferee='Referee:'
localtemplatestyles='Module:Football box/styles.css'
localtracking,preview
localfunctioncheckarg(k,v)
ifnotkortype(k)~='string'thenreturnend
ifk=='assistantreferees2'then
table.insert(tracking,'[[Category:Pages using football box with assistantreferees|2]]')
elseifk=='aggregatescore'ork=='assistantreferees'or
k=='fourthofficial'ork=='game'ork=='motm'or
k=='nobars'ork=='note'ork=='result'then
-- valid and tracked
table.insert(tracking,'[[Category:Pages using football box with '..k..']]')
elseifk=='size'ork=='bg'ork=='id'ork=='event'or
k=='date'ork=='time'ork=='round'ork=='team1'or
k=='team2'ork=='score1'ork=='score2'ork=='score'ork=='scorenote'or
k=='aet'ork=='asdet'ork=='agget'ork=='asget'ork=='goals1'ork=='report'ork=='goals2'or
k=='penaltyscore'ork=='penalties1'ork=='penalties2'or
k=='stadium'ork=='location'ork=='attendance'or
k=='referee'ork=='stack'ork=='section'ork=='transcludesection'then
-- valid and not tracked
else
-- invalid
localvlen=mw.ustring.len(k)
k=mw.ustring.sub(k,1,(vlen<25)andvlenor25)
k=mw.ustring.gsub(k,'[^%w%-_ ]','?')
table.insert(tracking,'[[Category:Pages using football box with unknown parameters|'..k..']]')
table.insert(preview,'"'..k..'"')
end
end
localfunctiontimestamp(d,t)
ifnotdthenreturnnilend
lang=langormw.language.getContentLanguage()-- lazy initialize
localsuccess,timestamp=pcall(lang.formatDate,lang,'c',delink({d..' '..(tor'')}))
ifsuccessthen
returntimestamp
else
returnnil
end
end
localfunctionfmtlist(s)
s=mw.ustring.gsub(sor'','%[%[ *([%?-]) *%]%]','%1')
s=mw.ustring.gsub(s,'%[%[ *[%?-] *| *(.-) *%]%]','%1')
ifmw.ustring.sub(s,1,1)=='*'then
-- could also expand plainlist here
returnmw.getCurrentFrame():extensionTag{
name='templatestyles',args={src='Plainlist/styles.css'}
}..tostring(mw.html.create('div'):addClass('plainlist'):newline():wikitext(s))
end
returns
end
localfunctionmakelink(s,t)
ifs:match('^[Hh][Tt][Tt][Pp][Ss]?:[^ ]*$')then
return'['..s..' '..t..']'
end
returns
end
localfunctiontrim(s)
returns:match('^[\'"%s]*(.-)[\'"%s]*$')
end
localfunctiongetid(s)
s=trim(sor'')
ifsands~=''then
returns
end
returnnil
end
localfunctionmakeanchor(s)
s=mw.ustring.gsub(s,'<[Ss][Uu][Pp].-</[Ss][Uu][Pp]>','')
s=mw.ustring.gsub(s,"</?%w+[^>]*>","")
s=mw.ustring.gsub(s,'\127[^\127]*UNIQ%-%-[^\127]*%-%x+%-QINU[^\127]*\127','')
s=mw.ustring.gsub(s,"%[%[[Ff][Ii][Ll][Ee]:[^%[%]]*%]%]","")
s=mw.ustring.gsub(s,"%[%[[Ii][Mm][Aa][Gg][Ee]:[^%[%]]*%]%]","")
s=mw.ustring.gsub(s,'%[%[[^%[%]%|]*%|([^%[%]]*)%]%]','%1')
s=mw.ustring.gsub(s,'%[%[([^%[%]]*)%]%]','%1')
s=mw.ustring.gsub(s,'%s*&nbsp;%s*',' ')
s=mw.ustring.gsub(s,'%s%s*',' ')
returns
end
localfunctioncheckTitle()
localpageTitle=mw.title.getCurrentTitle().text
localtitlePhrases={
"group stage","knockout stage","knockout phase","final phase","league phase","club world cup",
"round","league stage","qualifying","qualification","play%-off","nations league [a-d]","intertoto","domestic champions path"
}
for_,phraseinipairs(titlePhrases)do
ifmw.ustring.match(mw.ustring.lower(pageTitle),phrase)then
returntrue
end
end
returnfalse
end
functionp.main(frame)
-- Exit early if we are using section transclusion for a different section
localtsection=frame:getParent().args['transcludesection']orframe:getParent().args['section']or''
localbsection=frame.args['section']or''
if(tsection~=''andbsection~='')then
if(tsection~=bsection)then
return''
end
end
localargs=require('Module:Arguments').getArgs(frame)
localid=getid(args['id'])
locald=timestamp(args['date'],args['time'])
localblock
tracking,preview={},{}
fork,vinpairs(args)do
ifv~=''then
checkarg(k,v)
end
end
localscore='v'
ifargs['score1']orargs['score2']then
score=(args['score1']or'0')..'&ndash;'..(args['score2']or'0')
elseifargs['score']andargs['score']~=''then
score=args['score']
end
ifargs['aet']then
score=score..' ('..aet..')'
elseifargs['asdet']then
score=score..' ('..asdet..')'
elseifargs['agget']then
score=score..' ('..agget..')'
elseifargs['asget']then
score=score..' ('..asget..')'
end
ifargs['scorenote']then
score=score..'<br>'..args['scorenote']
end
-- Generate an anchor
ifidandid=='event'andargs['event']then
id=makeanchor(args['event'])
end
if(idandid=='auto')or(notidandcheckTitle())then
id=makeanchor((args['team1']or'Team 1')..' v '..(args['team2']or'Team 2'))
end
-- Start box
localroot=
mw.html.create('div')
:attr('itemscope','')
:attr('itemtype',eventschema)
:addClass('footballbox')
:css('width',args['size'])
:css('background-color',args['bg'])
:css('color','inherit')
:attr('id',id)
root:newline()
ifargs['event']then
root:tag('div')
:addClass('ftitle')
:wikitext(args['event'])
end
-- Start left block
block=root:tag('div')
:addClass('fleft')
localtimetag=block:tag('time')
:attr('itemprop',dand'startDate'ornil)
:attr('datetime',d)
timetag:tag('div')
:addClass('fdate')
:wikitext(args['date'])
ifargs['time']then
timetag:tag('div')
:addClass('ftime')
:wikitext(args['time'])
end
ifargs['round']then
block:tag('div')
:addClass('frnd')
:wikitext(args['round'])
end
-- End block
-- Start table
localrtable=root:tag('table')
:addClass('fevent')
localrow=rtable:tag('tr')
:attr('itemprop','name')
row:newline()
row:tag('th')
:addClass('fhome')
:attr('itemprop','homeTeam')
:attr('itemscope','')
:attr('itemtype',teamschema)
:tag('span')
:attr('itemprop','name')
:wikitext(args['team1'])
row:tag('th')
:addClass('fscore')
:wikitext(score)
row:tag('th')
:addClass('faway')
:attr('itemprop','awayTeam')
:attr('itemscope','')
:attr('itemtype',teamschema)
:tag('span')
:attr('itemprop','name')
:wikitext(args['team2'])
row=rtable:tag('tr')
:addClass('fgoals')
:newline()
row:tag('td')
:addClass('fhgoal')
:wikitext(fmtlist(args['goals1']))
row:newline()
row:tag('td')
:wikitext(makelink(args['report']or'','Report'))
row:newline()
row:tag('td')
:addClass('fagoal')
:wikitext(fmtlist(args['goals2']))
row:newline()
ifargs['penaltyscore']then
rtable
:tag('tr')
:tag('th')
:attr('colspan',3)
:wikitext(penalties)
row=rtable:tag('tr')
:addClass('fgoals')
row:newline()
row:tag('td')
:addClass('fhgoal')
:wikitext(fmtlist(args['penalties1']))
row:newline()
row:tag('th')
:wikitext(args['penaltyscore'])
row:newline()
row:tag('td')
:addClass('fagoal')
:wikitext(fmtlist(args['penalties2']))
row:newline()
end
-- End table
-- Start right block
block=root:tag('div')
:addClass('fright')
ifargs['stadium']then
localsdiv=block:tag('div')
:attr('itemprop','location')
:attr('itemscope','')
:attr('itemtype',placeschema)
ifargs['location']then
sdiv:tag('span')
:attr('itemprop','name')
:wikitext(args['stadium'])
sdiv:wikitext(', ')
sdiv:tag('span')
:attr('itemprop','address')
:wikitext(args['location'])
else
sdiv:tag('span')
:attr('itemprop','name address')
:wikitext(args['stadium'])
end
end
ifargs['attendance']then
block:tag('div'):wikitext(attendance..' '..args['attendance'])
end
ifargs['referee']then
block:tag('div'):wikitext(referee..' '..args['referee'])
end
localtrackstr=(#tracking>0)andtable.concat(tracking,'')or''
if#preview>0then
trackstr=require('Module:If preview')._warning({
'Unknown parameters '..table.concat(preview,'; ')..'.'
})..trackstr
end
returnframe:extensionTag{name='templatestyles',args={src=templatestyles}}..tostring(root)..trackstr
end
returnp