Modul:Football box: Perbedaan antara revisi

Konten dihapus Konten ditambahkan
kTidak ada ringkasan suntingan
+"Berkas" fn makeanchor
 
(9 revisi perantara oleh 3 pengguna tidak ditampilkan)
Baris 1:
-- ImplementsImplementasi [[TemplateTemplat:Football boxKsb1]]
local p = {}
local lang = nil
local delink = require('ModuleModul:Delink')._delink
local eventschema = "http://schema.org/SportsEvent"
local teamschema = "http://schema.org/SportsTeam"
local placeschema = "http://schema.org/Place"
local penalties = '[[adu penalti|Adu penalti]]'
local aet = '[[Perpanjangan waktu (sepak bola)|p.w.]]'
local asdet = '[[:en:Sudden death (sport)#Association football|p.w.s.d.]]'
local agget = '[[Perpanjangan waktu (sepak bola)|p.w.]]/[[Gol emas|g.e.]]'
local asget = '[[Perpanjangan waktu (sepak bola)|p.w.]]/[[Gol perak|g.p.]]'
local attendance = 'Penonton:'
local referee = 'Wasit:'
local templatestyles = 'Modul:Football box/styles.css'
 
local tracking, preview
 
local function checkarg(k,v)
if not k andor type(k) =~= 'string' then return end
if k == 'assistantreferees2' then
if k == 'assistantreferees2' then
table.insert(tracking, '[[Category:Pages using football box with assistantreferees|2]]')
elseif k ==table.insert(tracking, 'aggregatescore'[[Kategori:Halaman ormenggunakan kksb ==dengan 'assistantreferees|2]]' or )
k == 'fourthofficial' or elseif k == 'gameaggregatescore' or k == 'motmassistantreferees' or
k == 'nobarsfourthofficial' or k == 'notegame' or k == 'resultmotm' thenor
k == 'nobars' or k == 'note' or k == 'result' then
-- valid and tracked
-- valid dan terlacak
table.insert(tracking, '[[Category:Pages using football box with ' .. k .. ']]')
table.insert(tracking, '[[Kategori:Halaman menggunakan ksb dengan ' .. k .. ']]')
elseif k == 'size' or k == 'bg' or k == 'id' or k == 'event' or
elseif k == 'datesize' or k == 'timebg' or k == 'roundid' or k == 'team1event' or
k == 'team2date' or k == 'score1time' or k == 'score2round' or k == 'scoreteam1' or k == 'scorenote' or
k == 'aetteam2' or k == 'goals1score1' or k == 'reportscore2' or k == 'goals2score' or k == 'scorenote' or
k == 'penaltyscoreaet' or k == 'penalties1asdet' or k == 'penalties2agget' or k == 'asget' or k == 'goals1' or k == 'report' or k == 'goals2' or
k == 'stadiumpenaltyscore' or k == 'locationpenalties1' or k == 'attendancepenalties2' or
k == 'refereestadium' or k == 'stacklocation' or k == 'skorattendance' or k == 'std' or k == 'org' then
k == 'referee' or k == 'stack' or k == 'section' or k == 'transcludesection' then
-- valid and not tracked
-- valid dan tidak dilacak
else
else
-- invalid
-- tidak valid
local vlen = mw.ustring.len(k)
k = mw.ustring.sub(k, 1, (vlen < 25) and vlen or 25)
k = mw.ustring.gsub(k, '[^%w\%-_ ]', '?')
table.insert(tracking, '[[CategoryKategori:PagesKsb usingperlu football box with unknown parametersperbaikan|' .. k .. ']]')
table.insert(preview, '"' .. k .. '"')
end
end
end
 
local function timestamp(d, t)
if not d then return nil end
lang = lang or mw.language.getContentLanguage() -- lazy initialize
lang = lang or mw.language.getContentLanguage() -- lazy initialize
local success, timestamp = pcall(lang.formatDate, lang, 'c', delink({d .. ' ' .. (t or '')}))
local success, timestamp = pcall(lang.formatDate, lang, 'c', delink({d .. ' ' .. (t or '')}))
if success then
if success then
return timestamp
return timestamp
else
else
return nil
return nil
end
end
return nil
end
 
Baris 59 ⟶ 61:
s = mw.ustring.gsub(s, '%[%[ *[%?-] *| *(.-) *%]%]', '%1')
if mw.ustring.sub(s, 1, 1) == '*' then
-- juga dapat mengembangkan plainlist di sini
return tostring(mw.html.create('div'):addClass('plainlist'):newline():wikitext(s))
return mw.getCurrentFrame():extensionTag{
name = 'templatestyles', args = { src = 'Plainlist/styles.css' }
} .. tostring( mw.html.create('div'):addClass('plainlist'):newline():wikitext(s))
end
return s
Baris 65 ⟶ 70:
 
local function makelink(s,t)
if s:match('^http[Hh][Tt][Tt][Pp][Ss]?:[^ ]*$') then
return '[' .. s .. ' ' .. t .. ']'
end
Baris 81 ⟶ 86:
end
return nil
end
 
local function makeanchor(s)
s = mw.ustring.gsub(s, '%[%[[Ff][Ii][Ll][Ee]:[^%[%]]*%]%]', '')
s = mw.ustring.gsub(s, '%[%[[Bb][Ee][Rr][Kk][Aa][Ss]:[^%[%]]*%]%]', '')
s = mw.ustring.gsub(s, '<[Ss][Pp][Aa][Nn][^<>]*>', '')
s = mw.ustring.gsub(s, '</[Ss][Pp][Aa][Nn][^<>]*>', '')
s = mw.ustring.gsub(s, '<[Aa][Bb][Bb][Rr][^>]*>([^<]*)</[Aa][Bb][Bb][Rr]>', '%1')
s = mw.ustring.gsub(s, '[\'"]', '')
s = mw.ustring.gsub(s, '%s*&nbsp;%s*', ' ')
s = mw.ustring.gsub(s, '%[%[[^%[%]%|]*%|([^%[%]]*)%]%]', '%1')
s = mw.ustring.gsub(s, '%[%[([^%[%]]*)%]%]', '%1')
s = mw.ustring.gsub(s, '\127[^\127]*UNIQ%-%-[^\127]*%-%x+%-QINU[^\127]*\127', '')
s = mw.ustring.gsub(s, '<[Ss][Uu][Pp]>[^<>]*</[Ss][Uu][Pp]>', '')
s = mw.ustring.gsub(s, '%s%s*', ' ')
return s
end
 
local function checkTitle()
local pageTitle = mw.title.getCurrentTitle().text
local titlePhrases = {
"babak grup", "babak penyisihan grup", "fase grup", "babak gugur", "fase gugur", "babak final", "fase final", "putaran final", "babak kualifikasi", "babak liga", "fase liga",
"babak", "putaran", "kualifikasi", "play%-off", "babak perebutan tempat", "perebutan tempat", "liga negara [a-d]", "liga [a-d] liga negara-negara", "intertoto", "piala dunia antarklub"
}
for _, phrase in ipairs(titlePhrases) do
if mw.ustring.match(mw.ustring.lower(pageTitle), phrase) then
return true
end
end
return false
end
 
function p.main(frame)
-- Keluar lebih awal jika menggunakan transklusi bagian untuk bagian yang berbeda
local args = require('Module:Arguments').getArgs(frame)
local tsection = frame:getParent().args['transcludesection'] or frame:getParent().args['section'] or ''
local bsection = frame.args['section'] or ''
if( tsection ~= '' and bsection ~= '' ) then
if( tsection ~= bsection ) then
return ''
end
end
 
local args = require('Modul:Arguments').getArgs(frame)
local id = getid(args['id'])
local d = timestamp(args['date'], args['time'])
Baris 96 ⟶ 142:
end
 
local score = 'vvs.'
if args['score1'] or args['score2'] or args['skor1'] or args['skor2'] then
score = (args['score1'] or args['skor1'] or '0') .. '&ndash;' .. (args['score2'] or args['skor2'] or '0')
elseif (args['score'] and args['score']) or (args['skor'] and args['skor']) ~= '' then
score = args['score'] or args['skor']
end
if args['aet'] then
score = score .. ' (' .. aet .. ')'
elseif args['asdet'] then
score = score .. ' (' .. asdet .. ')'
elseif args['agget'] then
score = score .. ' (' .. agget .. ')'
elseif args['asget'] then
score = score .. ' (' .. asget .. ')'
end
if args['scorenote'] then
Baris 109 ⟶ 161:
end
-- StartHasilkan boxjangkar
if id and id == 'event' and args['event'] then
id = makeanchor(args['event'])
end
if (id and id == 'auto') or (not id and checkTitle()) then
id = makeanchor((args['team1'] or 'Team 1') .. ' v ' .. (args['team2'] or 'Team 2'))
end
 
-- Kotak mulai
local root =
mw.html.create('div')
Baris 126 ⟶ 186:
end
-- StartMulai leftblok blocksebelah kiri
block = root:tag('div')
:addClass('mobile-float-reset')
:addClass('fleft')
Baris 136 ⟶ 195:
timetag:tag('div')
:addClass('mobile-float-reset')
:addClass('fdate')
:wikitext(args['date'])
Baris 142 ⟶ 200:
if args['time'] then
timetag:tag('div')
:addClass('mobile-float-reset')
:addClass('ftime')
:wikitext(args['time'])
Baris 149 ⟶ 206:
if args['round'] then
block:tag('div')
:addClass('mobile-float-reset')
:addClass('frnd')
:wikitext(args['round'])
end
-- EndAkhir blockblok
-- StartTabel tablemulai
local rtable = root:tag('table')
:addClass('fevent')
Baris 217 ⟶ 273:
row:newline()
end
-- EndAkhir tabletabel
-- StartMulai rightblok blocksebelah kanan
block = root:tag('div')
:addClass('mobile-float-reset')
:addClass('fright')
if args['stadium'] or args['std'] then
local sdiv = block:tag('div')
:attr('itemprop', 'location')
Baris 232 ⟶ 287:
sdiv:tag('span')
:attr('itemprop', 'name')
:wikitext(args['stadium'] or args['std'])
sdiv:wikitext(', ')
sdiv:tag('span')
Baris 240 ⟶ 295:
sdiv:tag('span')
:attr('itemprop', 'name address')
:wikitext(args['stadium'] or args['std'])
end
end
if args['attendance'] or args['org'] then
block:tag('div'):wikitext(attendance ..' ' .. args['attendance'] or args['org'])
end
if args['referee'] then
Baris 252 ⟶ 307:
 
local trackstr = (#tracking > 0) and table.concat(tracking, '') or ''
if #preview > 0 and frame:preprocess( "{{REVISIONID}}" ) == "" then
trackstr = tostring(mw.html.createrequire('divModul:If preview')._warning({
'Unknown parameters ' .. table.concat(preview, '; ') .. '.'
:addClass('hatnote')
}) .. trackstr
:css('color','red')
:tag('strong'):wikitext('Warning:'):done()
:wikitext('Unknown parameters: ' .. table.concat(preview, '; ')))
end