Mudanças entre as edições de "Módulo:Larifk"
Ir para navegação
Ir para pesquisar
| Linha 50: | Linha 50: | ||
:attr('data-panel', 'b' .. n) | :attr('data-panel', 'b' .. n) | ||
local rsec = panel:tag('div') | local rsec = panel:tag('div') | ||
rsec:tag('div'):attr('class', 'lk-slabel'):wikitext('Recompensas') | rsec:tag('div'):attr('class', 'lk-slabel'):wikitext('Recompensas') | ||
| Linha 78: | Linha 77: | ||
end | end | ||
if video ~= '' or rota ~= '' then | if video ~= '' or rota ~= '' then | ||
panel:tag('div'):attr('class', 'lk-divider') | panel:tag('div'):attr('class', 'lk-divider') | ||
| Linha 87: | Linha 85: | ||
if video ~= '' then | if video ~= '' then | ||
ctabs:tag('span') | ctabs:tag('span') | ||
:attr('class', | :attr('class', 'lk-ctab active') | ||
:attr('data-ctab', 'v' .. n) | :attr('data-ctab', 'v' .. n) | ||
:wikitext('Vídeo') | :wikitext('Vídeo') | ||
| Linha 98: | Linha 96: | ||
end | end | ||
if video ~= '' then | if video ~= '' then | ||
local vpanel = csec:tag('div') | local vpanel = csec:tag('div') | ||
| Linha 107: | Linha 104: | ||
end | end | ||
if rota ~= '' then | if rota ~= '' then | ||
local rpanel = csec:tag('div') | local rpanel = csec:tag('div') | ||
| Linha 117: | Linha 113: | ||
local imgs = mw.text.split(rota, '%s*,%s*') | local imgs = mw.text.split(rota, '%s*,%s*') | ||
local total = 0 | |||
for _, imgname in ipairs(imgs) do | for _, imgname in ipairs(imgs) do | ||
imgname = mw.text.trim(imgname) | imgname = mw.text.trim(imgname) | ||
| Linha 122: | Linha 119: | ||
local slide = track:tag('div'):attr('class', 'lk-slide') | local slide = track:tag('div'):attr('class', 'lk-slide') | ||
slide:node(mw.html.create(''):wikitext('[[File:' .. imgname .. '|link=]]')) | slide:node(mw.html.create(''):wikitext('[[File:' .. imgname .. '|link=]]')) | ||
total = total + 1 | |||
end | end | ||
end | end | ||
if total > 1 then | if total > 1 then | ||
slider:tag(' | slider:tag('span') | ||
:attr('class', 'lk-slide-btn lk-slide-prev') | :attr('class', 'lk-slide-btn lk-slide-prev') | ||
:attr('aria-label', 'anterior') | :attr('aria-label', 'anterior') | ||
:wikitext(' | :wikitext('<') | ||
slider:tag(' | slider:tag('span') | ||
:attr('class', 'lk-slide-btn lk-slide-next') | :attr('class', 'lk-slide-btn lk-slide-next') | ||
:attr('aria-label', ' | :attr('aria-label', 'proximo') | ||
:wikitext(' | :wikitext('>') | ||
slider:tag(' | slider:tag('span') | ||
:attr('class', 'lk-slide-counter') | :attr('class', 'lk-slide-counter') | ||
:attr('data-total', tostring(total)) | :attr('data-total', tostring(total)) | ||
Edição das 20h47min de 16 de março de 2026
A documentação para este módulo pode ser criada em Módulo:Larifk/doc
local p = {}
local BAU_IMAGENS = {
comum = 'CommonChest.png',
ouro = 'GoldChest.png'
}
function p.render(frame)
local args = frame:getParent().args
local nome = mw.text.trim(args['nome'] or '')
local root = mw.html.create('div'):attr('class', 'lk-wrap')
if nome ~= '' then
root:tag('div'):attr('class', 'lk-titulo'):wikitext(nome)
end
local baus = {}
local i = 1
while true do
local tipo = mw.text.trim(args['bau' .. i .. 'tipo'] or '')
if tipo == '' then break end
baus[#baus + 1] = i
i = i + 1
end
if #baus == 0 then return tostring(root) end
local tabs = root:tag('div'):attr('class', 'lk-tabs')
for idx, n in ipairs(baus) do
local tipo = mw.text.trim(args['bau' .. n .. 'tipo'] or '')
local tabImg = BAU_IMAGENS[tipo] or ''
local tab = tabs:tag('span')
:attr('class', idx == 1 and 'lk-tab active' or 'lk-tab')
:attr('data-tab', 'b' .. n)
if tabImg ~= '' then
tab:node(mw.html.create(''):wikitext('[[File:' .. tabImg .. '|20px|link=]]'))
end
tab:tag('span'):wikitext('Baú ' .. string.format('%02d', n))
end
for idx, n in ipairs(baus) do
local px = 'bau' .. n
local tipo = mw.text.trim(args[px .. 'tipo'] or '')
local video = mw.text.trim(args[px .. 'video'] or '')
local rota = mw.text.trim(args[px .. 'rota'] or '')
local panel = root:tag('div')
:attr('class', idx == 1 and 'lk-panel active' or 'lk-panel')
:attr('data-panel', 'b' .. n)
local rsec = panel:tag('div')
rsec:tag('div'):attr('class', 'lk-slabel'):wikitext('Recompensas')
local grid = rsec:tag('div'):attr('class', 'lk-rewards')
local j = 1
while true do
local qty = mw.text.trim(args[px .. 'reward' .. j] or '')
local rimg = mw.text.trim(args[px .. 'rewardimg' .. j] or '')
if qty == '' and rimg == '' then break end
local item = grid:tag('div'):attr('class', 'lk-reward')
local sprite = item:tag('div'):attr('class', 'lk-rsprite')
if rimg ~= '' then
sprite:node(mw.html.create(''):wikitext('[[File:' .. rimg .. '|36px|link=]]'))
end
if qty ~= '' then
local num, sufixo = qty:match('^(%d+)(.*)')
if num then
local qspan = item:tag('span'):attr('class', 'lk-rqty')
qspan:tag('span'):attr('class', 'lk-rqty-num'):wikitext(num)
qspan:tag('span'):attr('class', 'lk-rqty-x'):wikitext(sufixo ~= '' and sufixo or 'x')
else
item:tag('span'):attr('class', 'lk-rqty'):wikitext(qty)
end
end
j = j + 1
end
if video ~= '' or rota ~= '' then
panel:tag('div'):attr('class', 'lk-divider')
local csec = panel:tag('div')
csec:tag('div'):attr('class', 'lk-slabel'):wikitext('Como chegar')
local ctabs = csec:tag('div'):attr('class', 'lk-ctabs')
if video ~= '' then
ctabs:tag('span')
:attr('class', 'lk-ctab active')
:attr('data-ctab', 'v' .. n)
:wikitext('Vídeo')
end
if rota ~= '' then
ctabs:tag('span')
:attr('class', video ~= '' and 'lk-ctab' or 'lk-ctab active')
:attr('data-ctab', 'r' .. n)
:wikitext('Imagem')
end
if video ~= '' then
local vpanel = csec:tag('div')
:attr('class', 'lk-cpanel active')
:attr('data-cpanel', 'v' .. n)
local mwrap = vpanel:tag('div'):attr('class', 'lk-media-wrap')
mwrap:attr('data-video', video)
end
if rota ~= '' then
local rpanel = csec:tag('div')
:attr('class', video ~= '' and 'lk-cpanel' or 'lk-cpanel active')
:attr('data-cpanel', 'r' .. n)
local slider = rpanel:tag('div'):attr('class', 'lk-slider')
local track = slider:tag('div'):attr('class', 'lk-slider-track')
local imgs = mw.text.split(rota, '%s*,%s*')
local total = 0
for _, imgname in ipairs(imgs) do
imgname = mw.text.trim(imgname)
if imgname ~= '' then
local slide = track:tag('div'):attr('class', 'lk-slide')
slide:node(mw.html.create(''):wikitext('[[File:' .. imgname .. '|link=]]'))
total = total + 1
end
end
if total > 1 then
slider:tag('span')
:attr('class', 'lk-slide-btn lk-slide-prev')
:attr('aria-label', 'anterior')
:wikitext('<')
slider:tag('span')
:attr('class', 'lk-slide-btn lk-slide-next')
:attr('aria-label', 'proximo')
:wikitext('>')
slider:tag('span')
:attr('class', 'lk-slide-counter')
:attr('data-total', tostring(total))
:wikitext('1 / ' .. total)
end
end
end
end
return tostring(root)
end
return p