Content deleted Content added
S.A. Julio (talk | contribs) improve logic |
S.A. Julio (talk | contribs) use templatestyles for styling |
||
Line 78:
-- Function to determine the winner based on scores within parentheses (first) or regular format (second)
local function determineWinner(cleanAggregate, team1, team2, boldWinner, colorWinner, aggregate, isFBRStyle, legs, leg1Score, leg2Score, disableAwayGoals, skipAutoWinner)
local team1Winner, team2Winner = false, false
local score1, score2
Line 140:
-- Regular winner determination logic if manual bolding or coloring is not conclusive
if not team1Winner and not team2Winner and not isDraw and not skipAutoWinner and (boldWinner or colorWinner or isFBRStyle) then
local parenthetical = cleanAggregate:match('%((%d+%-+%d+)%)')
local outsideParenthetical = cleanAggregate:match('^(%d+%-+%d+)')
Line 246:
-- Remove opening and closing HTML tags
str = str:gsub("</?%w+[^>]*>", "")
-- Remove apostrophes
str = str:gsub("''+", "")
-- Remove all whitespace
Line 259 ⟶ 262:
-- Function to format the dashes and winning notes for aggregate/leg score parameters, and divide the score from references/notes/superscripts
local function format_and_extract_score(s,
if not s then return '', '' end -- Return empty strings if input is nil
Line 276 ⟶ 279:
-- Format winning notes in brackets
local
s = mw.ustring.gsub(s, '(%(%d+%s*–%s*%d+)%s+[Pp]%.?[EeSs]?%.?[NnOo]?%.?%)', '%1 [[Penalty shoot-out (association football)|p]])')▼
s = mw.ustring.gsub(s, '%([Aa]%.?[Ee]%.?[Tt]%.?%)', '([[Overtime (sports)#Association football|a.e.t.]])')▼
else▼
s = mw.ustring.gsub(s, '(%(%d+%s*–%s*%d+)%s+[Pp]%.?[EeSs]?%.?[NnOo]?%.?%)', '<span class="nowrap">%1 [[Penalty shoot-out (association football)|p]])</span>')
s = mw.ustring.gsub(s, '%([Aa]%.?[Ee]%.?[Tt]%.?%)', '<span class="nowrap">([[Overtime (sports)#Association football|a.e.t.]])</span>')
▲ else
▲ s = mw.ustring.gsub(s, '(%(%d+%s*–%s*%d+)%s+[Pp]%.?[EeSs]?%.?[NnOo]?%.?%)', '%1 [[Penalty shoot-out (association football)|p]])')
▲ s = mw.ustring.gsub(s, '%([Aa]%.?[Ee]%.?[Tt]%.?%)', '([[Overtime (sports)#Association football|a.e.t.]])')
end
s = mw.ustring.gsub(s, '%([Aa]%.?[Gg]?%.?[Rr]?%.?%)', '([[Away goals rule|a]])')
Line 431 ⟶ 437:
local divContent = mw.html.create('div')
:
:css('margin-bottom', '0.5em')▼
if isFBRStyle and legs == 0 then
Line 461 ⟶ 466:
if externalNotes then
local hiddenRefs = mw.html.create('span')
:
:wikitext(table.concat(noteDefinitions))
if isFBRStyle and legs == 0 then
Line 511 ⟶ 516:
local root = mw.html.create()
local templatestyles = frame:extensionTag{
name = 'templatestyles',
args = { src = 'Module:Sports series/styles.css' }
root:wikitext(templatestyles)
local noFlagIcons = false
local fillBlanks = isTrue(args.fill_blanks)
Line 516 ⟶ 527:
local solidCell = isTrue(args.solid_cell) or args.solid_cell == 'grey' or args.solid_cell == 'gray'
local baselink = frame:getParent():getTitle()
if currentPageTitle == baselink then baselink = '' end
local notes = {}
local noteGroup = args.note_group or 'lower-alpha'
Line 573 ⟶ 585:
local noWrap = isTrue(args.nowrap)
local disableNoWrap = isFalse(args.nowrap)
▲ local doWrap = not noWrap and not disableNoWrap
local tableClass = 'wikitable sports-series'
if isTrue(args.collapsed) then
tableClass = tableClass .. '
end
if isTrue(args.center_table) then
▲ end
▲ if noWrap then
end
if fontSize then
end
Line 597 ⟶ 603:
if args.id then
table:attr('id', args.id) -- Optional id parameter to allow anchor to table
elseif not disableNoWrap then
end
Line 618 ⟶ 629:
-- Create the header row with team and score columns
local header = table:tag('tr')
▲ if doWrap then
▲ end
local defaultTeam1 = isHA and 'Home team' or 'Team 1'
local defaultTeam2 = isHA and 'Away team' or 'Team 2'
header:tag('th'):attr('scope', 'col'):css('width',
header:tag('th'):attr('scope', 'col'):css('width', scoreWidth):wikitext(args['aggregate'] or legs == 0 and 'Score' or '[[Aggregate score|<abbr title="Aggregate score">Agg.</abbr>]]<span class="sports-series-sr-only">Tooltip Aggregate score</span>')
▲ :attr('scope', 'col')
header:tag('th'):attr('scope', 'col'):css('width',
▲ :wikitext(args['team1'] or defaultTeam1)
▲ :wikitext(args['team2'] or defaultTeam2)
-- Add columns for each leg if applicable
Line 654 ⟶ 651:
end
header:tag('th'):attr('scope', 'col'):css('width', scoreWidth):wikitext(legHeading)
end
end
Line 688 ⟶ 682:
-- Add a heading above a given row in the table
if headingParam and not showCountry then
local headingRow = table:tag('tr'):addClass('heading-row')
headingRow:tag('td')
:attr('colspan', colCount)
:wikitext('<strong>' .. headingParam .. '</strong>')
end
Line 710 ⟶ 703:
-- Clean the aggregate score
local cleanAggregate = cleanScore(aggregateScore)
-- Format
aggregateScore, aggregateEndText = format_and_extract_score(aggregateScore,
aggregateEndText, notes = processNote(frame, notes, 'agg', aggNote, aggregateEndText, rowIndex, rand_val, noteGroup)
if generateLinks and legs == 0 then
aggregateScore = cleanAndGenerateLinks(team1, team2, aggregateScore, false)
end
local
-- Determine the winning team on aggregate
▲ local skipDetermineWinner = legs == 0 and aggregateScore ~= '' and checkSmallText(aggregateScore)
▲ team1, team2, team1Winner, team2Winner, manualBold, manualColor, isDraw, aggregateScore = determineWinner(cleanAggregate, team1, team2, boldWinner, colorWinner, aggregateScore, isFBRStyle, legs, leg1Score, leg2Score, disableAwayGoals)
end▼
-- Function to create flag template parameters
Line 758 ⟶ 739:
local aggregateContent
if not disableSmallText and
aggregateContent = '<span
else
aggregateContent = aggregateScore .. aggregateEndText
Line 765 ⟶ 746:
-- Create aggregate score cell with conditional styling
local
if doWrap and not (cleanAggregate:match("%(.*%(")) then▼
if isFBRStyle and legs == 0 then
if team1Winner then
elseif team2Winner then
elseif isDraw then
end
elseif isDraw then
▲ end
aggregateClass = aggregateClass .. ' allow-wrap'
end
-- Create rows for aggregate score and team names, bolded if set by user
row:tag('td'):
row:tag('td'):
row:tag('td'):
-- Add columns for each leg score if applicable
Line 795 ⟶ 776:
if legScore == "null" then
if solidCell then
row:tag('td'):
else
legScore = '—'
Line 802 ⟶ 783:
if legScore ~= "null" then
-- Format
local cleanLeg = cleanScore(legScore)
legScore, legEndText = format_and_extract_score(legScore,
legEndText, notes = processNote(frame, notes, 'leg' .. leg, legNote, legEndText, rowIndex, rand_val, noteGroup)
if generateLinks and not aggregateContent:lower():find("bye") then
Line 815 ⟶ 796:
local legContent
if not disableSmallText and legScore ~= '' and checkSmallText(legScore) then
legContent = '<span
else
legContent = legScore .. legEndText
end
local
if
end
-- Write cells for legs
row:tag('td'):
end
end
Line 844 ⟶ 825:
tableCode = mw.ustring.gsub(tableCode, '(%[%[)(#[^%[%]]*%|)', '%1' .. baselink .. '%2')
end
local escapedTitle = currentPageTitle:gsub("([%(%)%.%%%+%-%*%?%[%^%$])", "%%%1")
local titlePattern = '%[%[' .. escapedTitle .. '(#[^%[%]]*%|)'
tableCode = mw.ustring.gsub(tableCode, titlePattern, '[[%1')
return tableCode
|