Modul:Sports series: Perbedaan antara revisi

Konten dihapus Konten ditambahkan
opsi sel skor warna abu-abu
huruf kecil untuk pertandingan mendatang; hapus perataan teks rata tengah (text-align:center)
Baris 39:
end
 
-- Function to cleanreplace andwiki processlinks thewith aggregatetheir scoredisplay fortext comparisonor link text
local function cleanScore(score)
-- Return an empty string if score is nil or empty to avoid errors
if not score or score:match("^%s*$") then
return ''
end
 
-- Function to replace wiki links with their display text or link text
local function replaceLink(match)
local pipePos = match:find("|")
Baris 56 ⟶ 49:
end
 
-- Function to clean and process the aggregate score for comparison
local function cleanScore(score)
-- Return an empty string if score is nil or empty to avoid errors
if not score or score:match("^%s*$") then
return ''
end
-- Replace wiki links
score = score:gsub("%[%[.-%]%]", replaceLink)
 
-- Remove MediaWiki's unique placeholder sequences for references
score = score:gsub('\127%\'"`UNIQ.-QINU`"%\'\127', '')
 
-- Remove superscript tags and their contents
Baris 66:
 
-- Convert dashes to a standard format
score = score:gsub('[–—―‒−]+', '-')
 
-- Strip all characters except numbers, dashes and parentheses
Baris 195:
:css('margin-bottom', '0.5em')
:wikitext("Legenda: Biru = tim kandang menang; Kuning = imbang; Merah = tim tandang menang.")
end
 
-- Function to check whether to reduce font size for upcoming matches
local function checkSmallText(str)
-- Check for font size or small/big HTML tags
if str:match("font%s?%-?size") or str:match("<small>") or str:match("<big>") then
return false
end
-- Remove MediaWiki's unique placeholder sequences for references
str = str:gsub('\127%\'"`UNIQ.-QINU`"%\'\127', '')
-- Remove superscript tags and their contents
str = str:gsub('<sup.->.-</sup>', '')
-- Function to replaceReplace wiki links with their display text or link text
str = str:gsub("%[%[.-%]%]", replaceLink)
-- Remove all text inside parentheses
str = str:gsub("%b()", "")
if str == "—" or str == "–" then
return false
end
-- Convert dashes to a standard format
str = str:gsub('[–—―‒−]+', '-')
-- Remove opening and closing HTML tags
str = str:gsub("</?%w+[^>]*>", "")
-- Remove all whitespace
str = str:gsub("%s+", "")
-- Check if the string matches only a scoreline
if str:match("^%d+-%d+$") then
return false
else
return true
end
end
 
Baris 240 ⟶ 280:
-- Process the font size parameter
local sizefontSize
if args.font_size then
-- Remove trailing '%' if present and convert to number
sizefontSize = tonumber((args.font_size:gsub('%s*%%$', '')))
if sizefontSize then
sizefontSize = math.max(size, 85) -- Ensure sizefont is at least 85
end
end
-- Calculate the font size for small text
 
local smallFontSize
if fontSize then
smallFontSize = math.floor(((fontSize / 100) * 0.85) * 100)
else
smallFontSize = 85
end
-- Process flag parameter to determine flag template and variant
if args.flag and args.flag:find('+') then
Baris 295 ⟶ 342:
local isHA = args.h_a == 'y' or args.h_a == 'yes' or args.h_a == '1' or args.h_a == 'true'
local disableAwayGoals = args.away_goals == 'n' or args.away_goals == 'no' or args.away_goals == '0' or args.away_goals == 'false' or args.away_goals == 'null'
local disableSmallText = args.small_text == 'n' or args.small_text == 'no' or args.small_text == '0' or args.small_text == 'false' or args.small_text == 'null'
 
local tableClass = 'wikitable'
local tableStyle = 'text-align: center;'
if args.collapsed and (args.collapsed == 'y' or args.collapsed == 'yes' or args.collapsed == '1' or args.collapsed == 'true') then
tableClass = 'wikitable mw-collapsible mw-collapsed'
tableStyle = tableStyle .. ' width: 100%; text-align: center;'
end
if args.nowrap and (args.nowrap == 'y' or args.nowrap == 'yes' or args.nowrap == '1' or args.nowrap == 'true') then
tableStyle = tableStyle .. ' white-space: nowrap;'
end
if sizefontSize then
tableStyle = tableStyle .. ' font-size: ' .. sizefontSize .. '%;'
end
 
Baris 337 ⟶ 385:
:attr('colspan', colCount)
:attr('scope', 'colgroup')
:css('text-align', 'center')
:wikitext(args.title)
end
Baris 510 ⟶ 557:
 
-- Create aggregate score cell with conditional styling
local aggregateStyle = 'text-align: center;'
if legs == 0 and not disableSmallText and checkSmallText(aggregateScore) then
aggregateStyle = 'font-size: ' .. smallFontSize .. '%;'
end
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 ~= '' and aggregateStyle or nil):wikitext(aggregateScore)
row:tag('td'):cssText(team2Style):wikitext((team2Winner and (boldWinner or manualBold) and team2Text ~= '') and ('<strong>' .. team2Text .. '</strong>') or team2Text)
 
Baris 538 ⟶ 588:
row:tag('td'):css('background', '#BBBBBB')
else
row:tag('td'):css('text-align', 'center'):wikitext('—')
end
else
Baris 545 ⟶ 595:
if baselink ~= '' then
legScore = rewriteAnchorLinks(legScore, baselink)
end
local legStyle = ''
if not disableSmallText and checkSmallText(legScore) then
legStyle = 'font-size: ' .. smallFontSize .. '%;'
end
-- Write cells for legs
row:tag('td'):csscssText('text-align',legStyle ~= 'center' and legStyle or nil):wikitext(legScore)
end
end