Modul:Football box: Perbedaan antara revisi
Konten dihapus Konten ditambahkan
kTidak ada ringkasan suntingan |
+'babak kualifikasi' pada fn checkTitle |
||
(7 revisi perantara oleh 2 pengguna tidak ditampilkan) | |||
Baris 1:
--
local p = {}
local lang = nil
local delink = require('
local eventschema = "http://schema.org/SportsEvent"
local teamschema = "http://schema.org/SportsTeam"
local placeschema = "http://schema.org/Place"
local penalties = '[[
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
if k == 'assistantreferees2' then
k == 'nobars' or k == 'note' or k == 'result' then
-- valid dan terlacak
table.insert(tracking, '[[Kategori:Halaman menggunakan ksb dengan ' .. k .. ']]')
k == 'referee' or k == 'stack' or k == 'section' or k == 'transcludesection' then
-- valid dan tidak dilacak
else
-- tidak valid
local vlen = mw.ustring.len(k) end
end
local function timestamp(d, t)
if not d then return nil end
lang = lang or mw.language.getContentLanguage() -- lazy initialize
local success, timestamp = pcall(lang.formatDate, lang, 'c', delink({d .. ' ' .. (t or '')}))
if success then
return timestamp
else
return nil
end
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 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('^
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, '<[Ss][Pp][Aa][Nn][^<>]*>', '')
s = mw.ustring.gsub(s, '</[Ss][Pp][Aa][Nn][^<>]*>', '')
s = mw.ustring.gsub(s, '[\'"]', '')
s = mw.ustring.gsub(s, '%s* %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", "Liga Negara-Negara"
}
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 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 ⟶ 140:
end
local score = '
if args['score1'] or args['score2
score = (args['score1
elseif
score = args['score
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 ⟶ 159:
end
--
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 ⟶ 184:
end
--
block = root:tag('div')
:addClass('fleft')
Baris 136 ⟶ 193:
timetag:tag('div')
:addClass('fdate')
:wikitext(args['date'])
Baris 142 ⟶ 198:
if args['time'] then
timetag:tag('div')
:addClass('ftime')
:wikitext(args['time'])
Baris 149 ⟶ 204:
if args['round'] then
block:tag('div')
:addClass('frnd')
:wikitext(args['round'])
end
--
--
local rtable = root:tag('table')
:addClass('fevent')
Baris 217 ⟶ 271:
row:newline()
end
--
--
block = root:tag('div')
:addClass('fright')
if args['stadium
local sdiv = block:tag('div')
:attr('itemprop', 'location')
Baris 232 ⟶ 285:
sdiv:tag('span')
:attr('itemprop', 'name')
:wikitext(args['stadium
sdiv:wikitext(', ')
sdiv:tag('span')
Baris 240 ⟶ 293:
sdiv:tag('span')
:attr('itemprop', 'name address')
:wikitext(args['stadium
end
end
Baris 252 ⟶ 305:
local trackstr = (#tracking > 0) and table.concat(tracking, '') or ''
if #preview > 0
trackstr =
'Unknown parameters ' .. table.concat(preview, '; ') .. '.'
}) .. trackstr
end
|