« Module:MinecraftConnect » : différence entre les versions
De Nefald
Autres actions
m preprocess |
m test Balise : Révoqué |
||
| Ligne 1 : | Ligne 1 : | ||
local p = {} | |||
function p.test(frame) | |||
local html = mw.html.create('div') | |||
:attr('style', 'background: red; padding: 20px; color: white;') | |||
:wikitext('TEST MODULE LUA') | |||
return tostring(html) | |||
end | |||
function p.render(frame) | |||
-- ... (le code ci-dessus) | |||
end | |||
local p = {} | local p = {} | ||
Version du 10 novembre 2025 à 08:41
La documentation pour ce module peut être créée à Module:MinecraftConnect/doc
local p = {}
function p.test(frame)
local html = mw.html.create('div')
:attr('style', 'background: red; padding: 20px; color: white;')
:wikitext('TEST MODULE LUA')
return tostring(html)
end
function p.render(frame)
-- ... (le code ci-dessus)
end
local p = {}
function p.render(frame)
local args = frame:getParent().args
local serveur = mw.text.trim(args.serveur or '')
local port = mw.text.trim(args.port or ':25565')
local texte = mw.text.trim(args.texte or "Copier l'adresse")
local image = mw.text.trim(args.image or 'Minecraft-icon.svg')
local color = mw.text.trim(args.color or 'minecraft')
local align = mw.text.trim(args.align or '')
local classWrapper = 'mc-connect-wrapper mc-connect--' .. color
if align ~= '' then
classWrapper = classWrapper .. ' mc-connect--align-' .. align
end
local serverAddress = serveur .. port
-- Image Wikitext
local imageWikitext = frame:preprocess('[[Fichier:' .. image .. '|40px|link=|alt=Minecraft]]')
-- Construction HTML
local html = mw.html.create('div')
:addClass(classWrapper)
:attr('data-server', serverAddress)
:node(
mw.html.create('button')
:addClass('mc-connect-btn')
:attr('onclick', 'copyMinecraftServer(this)')
:attr('aria-label', "Copier l'adresse du serveur")
:node(
mw.html.create('div')
:addClass('mc-connect-content')
:wikitext(imageWikitext .. " '''" .. texte .. "'''")
)
)
:node(
mw.html.create('span')
:addClass('mc-connect-feedback')
:wikitext('✓ Copié !')
)
local styles = frame:extensionTag('templatestyles', '', {src='MinecraftConnect/styles.css'})
return styles .. tostring(html)
end
return p