![](http://upload.wikimedia.org/wikipedia/commons/thumb/4/43/Test_Template_Info-Icon_-_Version_%282%29.svg/50px-Test_Template_Info-Icon_-_Version_%282%29.svg.png)
Implements {{Football box collapsible}}
-- Implements [[Template:Football box collapsible]]local p = {}local labels = {['penalties'] = '[[Penalty shoot-out (association football)|Penalties]]',['shootout'] = '[[Penalty shoot-out (association football)#North American experiments|Shootout]]',['pen'] = '[[Penalty shoot-out (association football)|p]]',['so'] = '[[Penalty shoot-out (association football)|SO]]',['aet'] = '[[Overtime (sports)#Association football|a.e.t.]]',['agg'] = '[[Playoff format#Total points series (aggregate)|agg.]]',['stadium'] = 'Stadium:', ['attendance'] = 'Attendance:',['referee'] = 'Referee:',['assistantreferees'] = 'Assistant referees:',['assistantreferee2'] = '<span style="visibility:hidden">Assistant referees:</span>',['fourthofficial'] = 'Fourth official:',['fifthofficial'] = 'Fifth official:',['goallineassistants'] = 'Goal-line assistants:',['goallineassistant2'] = '<span style="visibility:hidden">Goal-line assistants:</span>',['motm'] = 'Man of the Match:',['potm'] = 'Player of the Match:',['mvp'] = 'MVP:',['note'] = 'Note:',['seealso'] = 'See also:'}local colors = {["W"] = "BBF3BB",["L"] = "FFBBBB",["T"] = "D" , ["D"] = "FFFFBB",["SW"] = "PW", ["PW"] = "BBF3FF",["V"] = "P", ["P"] = "BBBBBB"}local tracking, previewlocal function checkarg(k,v)if k and type(k) == 'string' thenif k == 'id' or k == 'team1' or k == 'team2' or k == 'class' or k == 'nobars' or k == 'size' or k == 'result' or k == 'bg' or k == 'format' or k == 'date' or k == 'scorenote' ork == 'round' or k == 'score' or k == 'aet' or k == 'aggregatescore' or k == 'penaltyscore' or k == 'location' or k == 'stadium' or k == 'time' or k == 'goals1' or k == 'report' or k == 'goals2' or k == 'attendance' or k == 'referee' or k == 'assistantreferees' or k == 'assistantreferee2' or k == 'fourthofficial' or k == 'fifthofficial' or k == 'goallineassistants' or k == 'goallineassistant2' or k == 'potm' or k == 'motm' or k == 'mvp' or k == 'penalties1' or k == 'penalties2' or k == 'note' or k == 'shootoutscore' or k == 'shootout1' or k == 'shootout2' ork == 'seealso' or k == 'stack' or k == 'section' or k == 'transcludedsection' then-- valid and not trackedelse-- invalidlocal vlen = mw.ustring.len(k)k = mw.ustring.sub(k, 1, (vlen < 25) and vlen or 25) k = mw.ustring.gsub(k, '[^%w%-_ ]', '?')table.insert(tracking, '[[Category:Pages using football box collapsible with unknown parameters|' .. k .. ']]')table.insert(preview, '"' .. k .. '"')endendendlocal function isnotempty(s)return s and s:match( '^%s*(.-)%s*$' ) ~= ''endlocal function trim(s)if isnotempty(s) thens = s:match('^[\'"%s]*(.-)[\'"%s]*$')return isnotempty(s) and s or nilendreturn nilendlocal function bold(s)if isnotempty(s) thenreturn "'''" .. s .. "'''"endreturn ""endlocal function italic(s)if isnotempty(s) thenreturn "''" .. s .. "''"endreturn ""endlocal function small(s)if isnotempty(s) thenreturn '<small>' .. s .. '</small>'endreturn ''endlocal function nowrap(s)if isnotempty(s) thenreturn '<span style="white-space:nowrap">' .. s .. '</span>'endreturn ''endlocal function background(frame, c, r, bg)local data = colorslocal res = data[r:upper()]if res thenres = '#' .. (data[res] or res)elseif isnotempty(bg) thenres = '#' .. bgelseres = 'transparent'endreturn resendlocal function teamname(team) local prefix, suffix, b = "", "", "'''"; if mw.ustring.sub(team,1,3) ~= b and mw.ustring.sub(team,-3) ~= b then prefix = '<span class="fn org">' .. b .. ' '; suffix = ' ' .. b .. "</span>"; else if mw.ustring.sub(team,1,3) == b then prefix = '<span class="fn org">'; team = mw.ustring.sub(team,4); else prefix = '<span class="fn org">' .. b; end if mw.ustring.sub(team,-3) == b then suffix = "</span>"; team = mw.ustring.sub(team,1,mw.ustring.len(team)-3); else suffix = b .. "</span>"; end end return prefix .. team .. suffix;endlocal function score(s, a, ag, p, so)s = nowrap(bold(s ~= '' and s or 'v'))if a ~= '' thens = s .. small(' (' .. labels['aet'] .. ')')endif ag ~= '' thens = s .. '<br>' .. small(' (' .. bold(ag) .. ' ' .. labels['agg'] .. ')')endif p ~= '' thens = s .. '<br>' .. small(' (' .. bold(p) .. ' ' .. labels['pen'] .. ')')elseif so ~= '' thens = s .. '<br>' .. small(' (' .. bold(so) .. ' ' .. labels['so'] .. ')')endreturn send local function fmtlist(s)s = mw.ustring.gsub(s or '', '%[%[ *([%?-]) *%]%]', '%1')s = mw.ustring.gsub(s, '%[%[ *[%?-] *| *(.-) *%]%]', '%1')if mw.ustring.sub(s, 1, 1) == '*' then-- could also expand plainlist herereturn mw.getCurrentFrame():extensionTag{name = 'templatestyles', args = { src = 'Plainlist/styles.css' }} .. tostring( mw.html.create('div'):addClass('plainlist'):newline():wikitext(s))endreturn sendlocal function makelink(s,t)if s:match('^[Hh][Tt][Tt][Pp][Ss]?:[^ ]*$') thenreturn '[' .. s .. ' ' .. t .. ']'endreturn sendfunction p.main(frame)-- Exit early if we are using section transclusion for a different sectionlocal tsection = frame:getParent().args['transcludesection'] or frame:getParent().args['section'] or ''local bsection = frame.args['section'] or ''if( tsection ~= '' and bsection ~= '' ) thenif( tsection ~= bsection ) thenreturn ''endendlocal args = (frame.args['team1'] or frame.args['team2']) and frame.args or frame:getParent().argslocal id = trim(args['id'])local bars = (args['nobars'] == nil) or (args['bars'] == '')local class = trim(args['class'] or 'mw-collapsible mw-collapsed') or ''local width1 = {['1'] = '28%', ['1.1'] = '22%', ['1.2'] = '28%', ['default'] = '19%'}local width2 = {['1'] = '19%', ['1.1'] = '25%', ['1.2'] = '19%', ['default'] = '23%'}local width3 = {['1'] = '8%', ['1.1'] = '8%', ['1.2'] = '8%', ['default'] = '12%'}local width4 = {['1'] = '19%', ['1.1'] = '19%', ['1.2'] = '26%', ['default'] = '23%'}local width5 = {['1'] = '26%', ['1.1'] = '26%', ['1.2'] = '19%', ['default'] = '23%'}local location = nillocal extra = {}local notes = {}tracking, preview = {}, {} for k, v in pairs(args) do if v ~= '' then checkarg(k,v) endendif args['class'] thenif args['class'] == 'collapsible' or args['class'] == 'mw-collapsible' or args['class'] == 'uncollapsed' then --validelseif args['class'] == '' thentable.insert(tracking,'[[Category:Pages using football box collapsible with blank class parameter]]')elsetable.insert(tracking,'[[Category:Pages using football box collapsible with class parameter]]')endendif isnotempty(args['stack']) thentable.insert(tracking, '[[Category:Pages using football box collapsible with unsupported stack parameter]]')end-- required parametersfor i, k in ipairs({'team1', 'team2'}) doif args[k] == nil then args[k] = '{{{' .. k .. '}}}' endend-- vcard for stadiumif isnotempty(args['stadium']) thenargs['stadium'] = tostring(mw.html.create('span'):addClass('location'):wikitext(args['stadium']))end-- placement of stadium and location informationif isnotempty(args['location']) thenlocation = args['location']if isnotempty(args['stadium']) thentable.insert(extra, labels['stadium'] .. ' ' .. args['stadium'])endelseif isnotempty(args['stadium']) thenlocation = args['stadium']end-- remaining extra informationfor i, k in ipairs({'attendance', 'referee', 'assistantreferees', 'assistantreferee2', 'fourthofficial', 'fifthofficial', 'goallineassistants', 'goallineassistant2', 'potm', 'motm', 'mvp'}) doif isnotempty(args[k]) thentable.insert(extra, labels[k] .. ' ' .. args[k])endend-- scorelocal scorestr = ''if args['score1'] or args['score2'] thenscorestr = (args['score1'] or '0') .. '–' .. (args['score2'] or '0')elseif args['score'] thenscorestr = args['score']endif args['scorenote'] thenscorestr = scorestr .. '<br>' .. args['scorenote']end-- notesif isnotempty(args['note']) thentable.insert(notes, "''" .. labels['note'] .. " " .. args['note'] .. "''")endif isnotempty(args['seealso']) thentable.insert(notes, "''" .. labels['seealso'] .. " " .. args['seealso'] .. "''")end-- check if this is a one row tableif class == '' or class == 'uncollapsed' thenclass = ''elseif #extra > 0 or #notes > 0 or isnotempty(args['time']) or isnotempty(args['report']) or isnotempty(args['goals1']) or isnotempty(args['goals2']) orisnotempty(args['penalties1']) or isnotempty(args['penalties2']) orisnotempty(args['shootout1']) or isnotempty(args['shootout2']) thenelseif class == 'collapsible collapsed' or class == 'mw-collapsible mw-collapsed' thenclass = ''end-- Start boxlocal root = mw.html.create('div'):addClass('vevent'):attr('id', id)root:tag('span'):addClass('summary'):css('display', 'none'):wikitext(args['team1'] .. ' v ' .. args['team2'])root:newline()-- Start table local rClassName = 'vevent tmpl-football-box-collapsible' local rbg = background(frame, 'default', args['result'] or '', args['bg'] or '') if rbg == 'transparent' then rClassName = rClassName .. ' tmpl-football-box-collapsible-transparent' endlocal rtable = root:tag('table'):attr('cellspacing', 0):addClass(class ~= '' and class or nil):addClass(rClassName):css('border-top', bars and '1px solid #999' or nil):css('border-bottom', bars and '1px solid #999' or nil):css('margin-bottom', bars and '-1px' or nil):css('width', args['size'] or '100%'):css('color', 'inherit'):css('background', rbg)local row = rtable:tag('tr'):css('vertical-align', 'top')-- date and roundlocal cell = row:tag('td'):css('width', width1[args['format'] or 'default'] or width1['default'])if isnotempty(args['date']) thencell:tag('span'):css('white-space', 'nowrap'):css('float', 'right'):css('margin-left', '0.5em'):wikitext(args['date'])cell:wikitext(' ')endif isnotempty(args['round']) thencell:wikitext(small(args['round']))end-- team1row:tag('td'):css('width', width2[args['format'] or 'default'] or width2['default']):css('text-align', 'right'):addClass('vcard attendee'):wikitext(teamname(args['team1']))-- scorerow:tag('td'):css('width', width3[args['format'] or 'default'] or width3['default']):css('text-align', 'center'):wikitext(score(scorestr, args['aet'] or '', args['aggregatescore'] or '', args['penaltyscore'] or '', args['shootoutscore'] or ''))-- team2row:tag('td'):css('width', width4[args['format'] or 'default'] or width4['default']):addClass('vcard attendee'):wikitext(teamname(args['team2']))-- location, stadiumrow:tag('td'):css('width', width5[args['format'] or 'default'] or nil):css('font-size', location and '85%' or nil):wikitext(location)if #extra > 0 or isnotempty(args['time']) or isnotempty(args['report']) or isnotempty(args['goals1']) or isnotempty(args['goals2']) thenlocal row = rtable:tag('tr'):css('vertical-align','top'):css('font-size','85%')-- timerow:tag('td'):css('text-align', isnotempty(args['time']) and 'right' or nil):wikitext(args['time'])row:newline()-- goals1row:tag('td'):css('text-align', isnotempty(args['goals1']) and 'right' or nil):wikitext(fmtlist(args['goals1']))row:newline()-- reportrow:tag('td'):css('text-align', isnotempty(args['report']) and 'center' or nil):wikitext(makelink(args['report'] or '', 'Report'))row:newline()-- goals2row:tag('td'):wikitext(fmtlist(args['goals2']))row:newline()-- location, stadiumrow:tag('td'):wikitext(table.concat(extra, '<br>'))endif isnotempty(args['penalties1']) or isnotempty(args['penalties2']) thenrow = rtable:tag('tr')row:tag('td'):attr('rowspan', 2)row:tag('td'):attr('colspan', 3):css('text-align', 'center'):wikitext(bold(labels['penalties']))row:tag('td'):attr('rowspan', 2)row = rtable:tag('tr'):css('vertical-align','top'):css('font-size','85%')row:newline()row:tag('td'):css('text-align', isnotempty(args['penalties1']) and 'right' or nil):wikitext(fmtlist(args['penalties1']))row:newline()row:tag('td')row:newline()row:tag('td'):wikitext(fmtlist(args['penalties2']))row:newline()elseif isnotempty(args['shootout1']) or isnotempty(args['shootout2']) thenrow = rtable:tag('tr')row:tag('td'):attr('rowspan', 2)row:tag('td'):attr('colspan', 3):css('text-align', 'center'):wikitext(bold(labels['shootout']))row:tag('td'):attr('rowspan', 2)row = rtable:tag('tr'):css('vertical-align','top'):css('font-size','85%')row:newline()row:tag('td'):css('text-align', isnotempty(args['shootout1']) and 'right' or nil):wikitext(fmtlist(args['shootout1']))row:newline()row:tag('td')row:newline()row:tag('td'):wikitext(fmtlist(args['shootout2']))row:newline()endif #notes > 0 thenrow = rtable:tag('tr'):css('font-size', '85%')row:tag('td'):attr('colspan', 5):wikitext(table.concat(notes, '<br>'))row:newline()endlocal trackstr = (#tracking > 0) and table.concat(tracking, '') or ''if #preview > 0 thentrackstr = require('Module:If preview')._warning({'Unknown parameters ' .. table.concat(preview, '; ') .. '.'}) .. trackstrendreturn tostring(root) .. trackstrendreturn p
🔥 Top keywords: Main PageSpecial:SearchPage 3Wikipedia:Featured picturesHouse of the DragonUEFA Euro 2024Bryson DeChambeauJuneteenthInside Out 2Eid al-AdhaCleopatraDeaths in 2024Merrily We Roll Along (musical)Jonathan GroffJude Bellingham.xxx77th Tony AwardsBridgertonGary PlauchéKylian MbappéDaniel RadcliffeUEFA European Championship2024 ICC Men's T20 World CupUnit 731The Boys (TV series)Rory McIlroyN'Golo KantéUEFA Euro 2020YouTubeRomelu LukakuOpinion polling for the 2024 United Kingdom general electionThe Boys season 4Romania national football teamNicola CoughlanStereophonic (play)Gene WilderErin DarkeAntoine GriezmannProject 2025