请输入您要查询的百科知识:

 

词条 Module:Football box collapsible/sandbox
释义 -- Implements Football box collapsible

local p = {}

local result_modules = 'Module:Football box collapsible/result/'

local labels = {

['penalties'] = 'Penalties',

['pen'] = 'p',

['aet'] = 'a.e.t.',

['agg'] = 'agg.',

['stadium'] = 'Stadium:',

['attendance'] = 'Attendance:',

['referee'] = 'Referee:',

['assistantreferees'] = 'Assistant referees:',

['assistantreferee2'] = 'Assistant referees:',

['fourthofficial'] = 'Fourth official:',

['fifthofficial'] = 'Fifth official:',

['goallineassistants'] = 'Goal-line assistants:',

['goallineassistant2'] = 'Goal-line assistants:',

['motm'] = 'Man of the Match:',

['mvp'] = 'MVP:',

['note'] = 'Note:',

['seealso'] = 'See also:'

}

local tracking =

local function isnotempty(s)

return s and s:match( '^%s*(.-)%s*$' ) ~=

end

local function trim(s)

if isnotempty(s) then

s = s:match('^[\\'"%s]*(.-)[\\'"%s]*$')

return isnotempty(s) and s or nil

end

return nil

end

local function bold(s)

if isnotempty(s) then

return "" .. s .. ""

end

return ""

end

local function italic(s)

if isnotempty(s) then

return "" .. s .. ""

end

return ""

end

local function small(s)

if isnotempty(s) then

return '' .. s .. ''

end

return

end

local function nowrap(s)

if isnotempty(s) then

return '' .. s .. ''

end

return

end

local function background(frame, c, r, bg)

if c ~= 'default' then

if not mw.title.new(result_modules .. c) or not mw.title.new(result_modules .. c).exists then

c = 'default'

tracking = tracking ..

end

end

local data = mw.loadData(result_modules .. c)

local res = data[r:upper()]

if res then

res = '#' .. (data[res] or res)

elseif isnotempty(bg) then

res = '#' .. bg

else

res = 'transparent'

end

return res

end

local function teamname(team)

    if mw.ustring.sub(team,1,3) ~= b and mw.ustring.sub(team,-3) ~= b then        prefix = b .. '';        suffix = "" .. b;    else        if mw.ustring.sub(team,1,3) == b then            prefix = '';            team = mw.ustring.sub(team,4);        else            prefix = '' .. b;        end
        if mw.ustring.sub(team,-3) == b then            suffix = "";            team = mw.ustring.sub(team,1,mw.ustring.len(team)-3);        else            suffix = b .. "";        end    end            return prefix .. team .. suffix;

end

local function score(s, a, ag, p)

s = nowrap(bold(s ~= and s or 'v'))

if a ~= then

s = s .. small(' (' .. labels['aet'] .. ')')

end

if ag ~= then

s = s .. '
' .. small(' (' .. bold(ag) .. ' ' .. labels['agg'] .. ')')

end

if p ~= then

s = s .. '
' .. small(' (' .. bold(p) .. ' ' .. labels['pen'] .. ')')

end

return s

end

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

return tostring(mw.html.create('div'):addClass('plainlist'):newline():wikitext(s))

end

return s

end

local function makelink(s,t)

if s:match('^http') then

return '[' .. s .. ' ' .. t .. ']'

end

return s

end

function p.main(frame)

local args = frame:getParent().args

local id = trim(args['id'])

local bars = (args['nobars'] == nil) or (args['bars'] == )

local class = trim(args['class'] or 'collapsible 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 = nil

local extra = {}

local notes = {}

-- required parameters

for i, k in ipairs({'team1', 'team2'}) do

if args[k] == nil then args[k] = '{{{' .. k .. '}}}' end

end

-- vcard for stadium

if isnotempty(args['stadium']) then

args['stadium'] = tostring(mw.html.create('span'):addClass('location'):wikitext(args['stadium']))

end

-- placement of stadium and location information

if isnotempty(args['location']) then

location = args['location']

if isnotempty(args['stadium']) then

table.insert(extra, labels['stadium'] .. ' ' .. args['stadium'])

end

elseif isnotempty(args['stadium']) then

location = args['stadium']

end

-- remaining extra information

for i, k in ipairs({'attendance', 'referee', 'assistantreferees',

'assistantreferee2', 'fourthofficial', 'fifthofficial',

'goallineassistants', 'goallineassistant2', 'motm', 'mvp'}) do

if isnotempty(args[k]) then

table.insert(extra, labels[k] .. ' ' .. args[k])

end

end

-- notes

if isnotempty(args['note']) then

table.insert(notes, "" .. labels['note'] .. " " .. args['note'] .. "")

end

if isnotempty(args['seealso']) then

table.insert(notes, "" .. labels['seealso'] .. " " .. args['seealso'] .. "")

end

-- check if this is a one row table

if class == or class == 'uncollapsed' then

class =

elseif #extra > 0 or #notes > 0 or isnotempty(args['time']) or isnotempty(args['report']) or

isnotempty(args['goals1']) or isnotempty(args['goals2']) or

isnotempty(args['penalties1']) or isnotempty(args['penalties2']) then

elseif class == 'collapsible collapsed' then

class =

end

-- Start box

local 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 rtable = '{| cellspacing=0'

if class ~= then rtable = rtable .. ' class="' .. class .. '"' end

rtable = rtable .. ' style="'

if bars then

rtable = rtable .. 'border-top:1px solid #999;border-bottom:1px solid #999;margin-bottom:-1px;'

end

rtable = rtable .. 'width:' ..(args['size'] or '100%') .. ';'

local bg = background(frame, args['competition'] or 'default', args['result'] or , args['bg'] or )

if isnotempty(bg) then rtable = rtable .. 'background:' .. bg end

rtable = rtable .. '\'

root:wikitext(rtable)

root:wikitext('|-style="vertical-align:top"\')

-- date and round

local cell = '|style="width:' .. (width1[args['format'] or 'default'] or width1['default']) .. '"|'

if isnotempty(args['date']) then

cell = cell .. tostring(

mw.html.create('span')

:css('white-space', 'nowrap')

:css('float', 'right')

:css('margin-left', '0.5em')

:wikitext(args['date'])) .. ' '

end

if isnotempty(args['round']) then

cell = cell .. small(args['round'])

end

root:wikitext(cell .. '\')

-- team1

root:wikitext('|style="width:' .. (width2[args['format'] or 'default'] or width2['default']) .. ';'

.. 'text-align:right" class="vcard attendee"|' .. teamname(args['team1']) .. '\')

-- score

root:wikitext('|style="width:' .. (width3[args['format'] or 'default'] or width3['default']) .. ';'

.. 'text-align:center"|' .. score(args['score'] or , args['aet'] or , args['aggregatescore'] or , args['penaltyscore'] or )

.. '\')

-- team2

root:wikitext('|style="width:' .. (width4[args['format'] or 'default'] or width4['default']) .. '"'

.. ' class="vcard attendee"|' .. teamname(args['team2']) .. '\')

-- location, stadium

root:wikitext('|style="width:' .. (width5[args['format'] or 'default'] or width5['default']) .. ';'

.. 'font-size:85%"|' .. (location or ) .. '\')

if #extra > 0 or isnotempty(args['time']) or isnotempty(args['report']) or

isnotempty(args['goals1']) or isnotempty(args['goals2']) then

root:wikitext('|-style="vertical-align:top;font-size:85%"\')

-- time

root:wikitext('|style="text-align:right"|' .. (args['time'] or ) .. '\')

-- goals1

root:wikitext('|style="text-align:right"|' .. fmtlist(args['goals1']) .. '\')

-- report

root:wikitext('|style="text-align:center"|' .. makelink(args['report'] or , 'Report') .. '\')

-- goals2

root:wikitext('| ' .. fmtlist(args['goals2']) .. '\')

-- location, stadium

root:wikitext('| ' .. table.concat(extra, '
') .. '\')

end

if isnotempty(args['penalties1']) or isnotempty(args['penalties2']) then

root:wikitext('|-\')

root:wikitext('|rowspan=2|\')

root:wikitext('|colspan=3 style="text-align:center"|' .. bold(labels['penalties']) .. '\')

root:wikitext('|rowspan=2|\')

root:wikitext('|-style="vertical-align:top;font-size:85%"\')

root:wikitext('|style="text-align:right"|' .. fmtlist(args['penalties1']) .. '\')

root:wikitext('|\')

root:wikitext('| ' .. fmtlist(args['penalties2']) .. '\')

end

if #notes > 0 then

root:wikitext('|-\')

root:wikitext('|colspan=5 style="text-align:left;font-size:85%"|' .. table.concat(notes, '
') .. '\')

end

root:wikitext('|}')

return tostring(root) .. tracking

end

return p

1 : Pages using football box collapsible with unknown competition

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/21 16:49:44