Modul:Sports series: Perbedaan antara revisi
Konten dihapus Konten ditambahkan
tim pemenang otomatis cetak tebal |
penyederhanaan pranala jangkar; konversi otomatis "-" menjadi "–" (en dashes); hapus kode-kode duplikat |
||
Baris 8:
return frame:expandTemplate{ title = templateName, args = params }
end
-- Function to check the existence of
local function templateExists(templateName)
local title = mw.title.new('Templat:' .. templateName)
Baris 189:
end
-- Function to add a legend to below the table when
local function createFBRLegend()
return mw.html.create('div')
Baris 195:
:css('margin-bottom', '0.5em')
:wikitext("Legenda: Biru = tim kandang menang; Kuning = imbang; Merah = tim tandang menang.")
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
-- Function to rewrite anchor links of match scores
local function rewriteAnchorLinks(text, baselink)
if not text then
return text
end
return text:gsub('(%[%[)(#[^%[%]]*%|)', '%1' .. baselink .. '%2')
end
Baris 216 ⟶ 235:
local noFlagIcons = false
local fillBlanks = args.fill_blanks and (args.fill_blanks == 'y' or args.fill_blanks == 'yes' or args.fill_blanks == '1' or args.fill_blanks == 'true')
local baselink = frame:getParent():getTitle()
if mw.title.getCurrentTitle().text == baselink then baselink = '' end
-- Process the font size parameter
Baris 386 ⟶ 407:
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
Baris 409 ⟶ 429:
team2, team2Variant = processIcon(args[i+2])
end
else
team1 = args[i]
if noFlagIcons then
aggregateScore = args[i+1]
team2 = args[i+2]
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
if legs == 2 then
if matchType == 'NT' or noFlagIcons then
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 "")
Baris 431 ⟶ 484:
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">[[Berkas:Flag placeholder.svg|25x17px|link=]]</span>'
Baris 439 ⟶ 498:
team2Text = '<span class="flagicon">[[Berkas:Flag placeholder.svg|25x17px|link=]]</span> ' .. team2Text
end
team1Text = team1Text .. ' <span class="flagicon">[[Berkas:Flag placeholder.svg|25x17px|link=]]</span>'
end
team2Text = '<span class="flagicon">[[Berkas:Flag placeholder.svg|25x17px|link=]]</span> ' .. team2Text
end
end
end
-- Create aggregate score cell with conditional styling 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
Baris 525 ⟶ 533:
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
|