Content deleted Content added
S.A. Julio (talk | contribs) allow for simplified anchor links |
S.A. Julio (talk | contribs) automatically convert to en dashes, remove duplicate code |
||
Line 9:
end
-- Function to check the existence of
local function templateExists(templateName)
local title = mw.title.new('Template:' .. templateName)
Line 194:
end
-- Function to add a legend to below the table when
local function createFBRLegend()
return mw.html.create('div')
Line 200:
:css('margin-bottom', '0.5em')
:wikitext("Legend: Blue = home team win; Yellow = draw; Red = away team win.")
end
-- Function to format the dashes for aggregate/leg score parameters
local function format_score(s)
s = mw.ustring.gsub(s or '', '^%s*([%d%.]+)%s*[–−—%-]%s*([%d%.]+)', '%1–%2')
s = mw.ustring.gsub(s, '^%s*([%d%.]+)%s*&[MmNn][Dd][Aa][Ss][Hh];%s*([%d%.]+)', '%1–%2')
s = mw.ustring.gsub(s, '^%s*(%[%[[^%[%]]*%|[%d%.]+)%s*%-%s*([%d%.]+)', '%1–%2')
s = mw.ustring.gsub(s, '^%s*(%[[^%[%]%s]*%s+[%d%.]+)%s*%-%s*([%d%.]+)', '%1–%2')
s = mw.ustring.gsub(s, '^%s*(%[%[[^%[%]]*%|[%d%.]+)%s*&[MmNn][Dd][Aa][Ss][Hh];%s*([%d%.]+)', '%1–%2')
s = mw.ustring.gsub(s, '^%s*(%[[^%[%]%s]*%s+[%d%.]+)%s*&[MmNn][Dd][Aa][Ss][Hh];%s*([%d%.]+)', '%1–%2')
return s
end
Line 401 ⟶ 412:
local row = table:tag('tr')
local team1, team2, aggregateScore,
local team1Winner, team2Winner, manualBold, manualColor, isDraw = false, false, false, false, false
local leg1Score, leg2Score = false, false
local team1Asterick, team2Asterick = false, false
-- Process rows for both national team and club matches
if matchType == 'NT' then
team1 = args[i]
if team1 and team1:match("^%s*%*") then
Line 424 ⟶ 434:
team2, team2Variant = processIcon(args[i+2])
end
else
else
team1Icon, team1Variant = processIcon(args[i+1])
aggregateScore = args[i+2]
team2 = args[i+3]
team2Icon, team2Variant = processIcon(args[i+4])
end
end
-- Name the 1st/2nd leg scores for two-legged ties
if legs == 2 then
if matchType == 'NT' or noFlagIcons then
leg1Score = args[i+3]
leg2Score = args[i+4]
else
leg1Score = args[i+5]
leg2Score = args[i+6]
end
end
-- Clean the aggregate score
local cleanAggregate = cleanScore(aggregateScore)
-- Format and rewrite anchor links for aggregate score
aggregateScore = format_score(aggregateScore)
if baselink ~= ''
aggregateScore = rewriteAnchorLinks(aggregateScore, baselink)
end
-- Determine the winning team on aggregate
team1, team2, team1Winner, team2Winner, manualBold, manualColor, isDraw, aggregateScore = determineWinner(cleanAggregate, matchType, team1, team2, boldWinner, colorWinner, aggregateScore, isFBRStyle, legs, leg1Score, leg2Score, disableAwayGoals)
-- Add background-color for winning team if set by user
local team1Style = 'text-align: right;'
local team2Style = 'text-align: left;'
if team1Winner and (colorWinner or manualColor) then
team1Style = team1Style .. ' background-color: #CCFFCC;'
end
if team2Winner and (colorWinner or manualColor) then
team2Style = team2Style .. ' background-color: #CCFFCC;'
end
-- Generate text to display for each team
local team1Text, team2Text
if matchType == 'NT' then
if flagParam1 then -- Check whether youth team flag template with age level is used
team1Text = (not team1Asterick and team1 ~= "" and team1 ~= nil) and (expandTemplate(frame, flagTemplate .. '-rt', {flagParam1, team1, variant = team1Variant})) or (team1 ~= nil and team1 or "")
Line 450 ⟶ 489:
team2Text = (not team2Asterick and team2 ~= "" and team2 ~= nil) and (expandTemplate(frame, flagTemplate, {team2, variant = team2Variant})) or (team2 ~= nil and team2 or "")
end
else
team1Text = noFlagIcons and (team1 or '') or ((team1Icon ~= "" and team1Icon ~= nil) and ((team1 or '') .. ' ' .. expandTemplate(frame, flagTemplate, {team1Icon, variant = team1Variant})) or (team1 or ''))
team2Text = noFlagIcons and (team2 or '') or ((team2Icon ~= "" and team2Icon ~= nil) and (expandTemplate(frame, flagTemplate, {team2Icon, variant = team2Variant}) .. ' ' .. (team2 or '')) or (team2 or ''))
end
-- When set by user, adds blank flags when string is used for a team instead of national team flag template
if fillBlanks then
if matchType == 'NT' then
if team1Asterick then
team1Text = team1Text .. ' <span class="flagicon">[[File:Flag placeholder.svg|25x17px|link=]]</span>'
Line 458 ⟶ 503:
team2Text = '<span class="flagicon">[[File:Flag placeholder.svg|25x17px|link=]]</span> ' .. team2Text
end
team1Text = team1Text .. ' <span class="flagicon">[[File:Flag placeholder.svg|25x17px|link=]]</span>'
end
team2Text = '<span class="flagicon">[[File:Flag placeholder.svg|25x17px|link=]]</span> ' .. team2Text
end
end
end
-- Create aggregate score cell with conditional styling
local aggregateStyle = 'text-align: center;'
if isFBRStyle and legs == 0 then
if team1Winner then
aggregateStyle = aggregateStyle .. '; background-color: #BBF3FF;'
elseif team2Winner then
aggregateStyle = aggregateStyle .. '; background-color: #FFBBBB;'
elseif isDraw then
aggregateStyle = aggregateStyle .. '; background-color: #FFFFBB;'
end
elseif isDraw then
aggregateStyle = aggregateStyle .. '; background-color: #FFFFBB;'
end
-- Create rows for aggregate score and team names, bolded if set by user
row:tag('td'):cssText(team1Style):wikitext((team1Winner and (boldWinner or manualBold) and team1Text ~= '') and ('<strong>' .. team1Text .. '</strong>') or team1Text)
row:tag('td'):cssText(aggregateStyle):wikitext(aggregateScore)
row:tag('td'):cssText(team2Style):wikitext((team2Winner and (boldWinner or manualBold) and team2Text ~= '') and ('<strong>' .. team2Text .. '</strong>') or team2Text)
-- Add columns for each leg score if applicable
Line 548 ⟶ 538:
local legScore = args[legIndex]
if legScore ~= "null" then
-- Format and rewrite anchor links for leg scores
legScore = format_score(legScore)
if baselink ~= '' then
legScore = rewriteAnchorLinks(legScore, baselink)
end
-- Write cells for legs
row:tag('td'):css('text-align', 'center'):wikitext(legScore)
end
|