-- Implements local p =
local labels = local colors =
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 nilend
local function getbackground(result, bg) result = result or local color = colors[result:upper] if color then color = '#' .. color elseif isnotempty(bg) then color = '#' .. bg else color = 'transparent' end return colorend
local function getscore(score, other) if not score then local details = for i, k in ipairs do if other[k] then table.insert(details, "" .. labels[k] .. " " .. other[k]) end end return table.concat(details, '
') end return score or end
local function getextra(attendance, referee) local extra = if attendance then table.insert(extra, labels['attendance'] .. ' ' .. attendance) end if referee then table.insert(extra, labels['referee'] .. ' ' .. referee) end return table.concat(extra, '
')end
function p.main(frame) local getArgs = require('Module:Arguments').getArgs local args = getArgs(frame) -- Defaults and arg processing local class = trim(args.class or 'mw-collapsible mw-collapsed') local width = trim(args.width or '100%') local note_width = trim(args['note-width'] or '8%') local date_width = trim(args['date-width'] or '15%') local team_width = trim(args['team-width'] or '22%') local score_width = trim(args['score-width'] or '11%') local stadium_width = trim(args['stadium-width'] or '18%') local team1 = args['team1'] and args['team1'] or args['home'] or local team2 = args['team2'] and args['team2'] or args['away'] or local score = args['score'] and args['score'] or 'v' if args['score'] and args['aet'] then score = score .. ' ' .. labels['aet'] end local score1 = getscore(args['homescore'],) local score2 = getscore(args['awayscore'],) local extra = getextra(args['attendance'], args['referee'])
-- Styles local small = 'font-size:85%;' local left = 'text-align:left;' local right = 'text-align:right;' local center = 'text-align:center;' -- Start box local t = table.insert(t, '
- style="vertical-align:top;"\n') table.insert(t, ' | style="width:' .. note_width .. ';' .. left .. small .. '"' .. ' | ' .. (args['note'] or ) .. '\n') table.insert(t, ' | style="width:' .. date_width .. ';' .. right .. small .. '"' .. ' | ' .. (args['date'] or ) .. '\n') table.insert(t, ' | style="width:' .. team_width .. ';' .. right .. '"' .. ' | ' .. team1 .. '\n') table.insert(t, ' | style="width:' .. score_width .. ';' .. center .. 'font-weight:bold;"' .. ' | ' .. score .. '\n') table.insert(t, ' | style="width:' .. team_width .. ';' .. left .. '"' .. ' | ' .. team2 .. '\n') table.insert(t, ' | style="width:' .. stadium_width .. ';' .. small .. '"' .. ' | ' .. (args['stadium'] or ) .. '\n') table.insert(t, '! style="width:4%" rowspan="2" | \n') -- show/hide spacer -- Second row table.insert(t, ' | - style="vertical-align:top;' .. small .. '"\n') table.insert(t, ' | ' .. (args['note2'] or ) .. '\n') table.insert(t, ' | ' .. (args['time'] or ) .. '\n') table.insert(t, ' | ' .. (score1 or ) .. '\n') table.insert(t, ' | ' .. (args['report'] or ) .. '\n') table.insert(t, ' | ' .. (score2 or ) .. '\n') table.insert(t, ' | ' .. (extra or ) .. '\n') table.insert(t, ' |
return p