Aller au contenu

« Module:Fonctions » : différence entre les versions

De Wikiquestia
Aucun résumé des modifications
Aucun résumé des modifications
Balise : Révoqué
Ligne 1 : Ligne 1 :
local p = {}
local p = {}
local charteModule = mw.loadModule('Charte')


function p.multipleSuccession(frame)
function p.multipleSuccession(frame)
     local args = frame.args
     local args = frame.args
     local result = {}
     local result = {}
    -- Debug temporaire
    if not args["Titre1"] then
        return "Pas de Titre1 reçu"
    end


     for i = 1, 5 do
     for i = 1, 5 do
Ligne 23 : Ligne 20 :
             end
             end


             -- Pour tester, couleur fixe (évite la syntaxe #invoke dans chaîne)
             local couleurFond = charteModule.couleur(charte, "titre")
            local couleurTexte = charteModule.couleur(charte, "texte")
 
             local bloc =  
             local bloc =  
                 '<div style="margin: 0.5em 0; border: 1px solid #ccc; border-radius: 10px; overflow: hidden; font-size: 90%;">' ..
                 '<div style="margin: 0.5em 0; border: 1px solid #ccc; border-radius: 10px; overflow: hidden; font-size: 90%;">' ..
                 '<div style="background-color: #3366cc; color: white; text-align: center; padding: 0.5em; font-weight: bold;">' ..
                 '<div style="background-color: ' .. couleurFond .. '; color: ' .. couleurTexte .. '; text-align: center; padding: 0.5em; font-weight: bold;">' ..
                 mw.text.encode(titre) .. mandatBlock ..  
                 mw.text.encode(titre) .. mandatBlock ..  
                 '</div>' ..
                 '</div>' ..

Version du 1 juin 2025 à 07:20

La documentation pour ce module peut être créée à Module:Fonctions/doc

local p = {}

local charteModule = mw.loadModule('Charte')

function p.multipleSuccession(frame)
    local args = frame.args
    local result = {}

    for i = 1, 5 do
        local titre = args["Titre"..i]
        local mandat = args["Mandat"..i]
        local charte = args["Charte"..i] or args["Charte"] or "defaut"
        local predecesseur = args["Prédécesseur"..i]
        local successeur = args["Successeur"..i]

        if titre and predecesseur and successeur then
            local mandatBlock = ""
            if mandat and mandat ~= "" then
                mandatBlock = '<div style="font-weight: normal; font-size: 90%;">' .. mw.text.encode(mandat) .. '</div>'
            end

            local couleurFond = charteModule.couleur(charte, "titre")
            local couleurTexte = charteModule.couleur(charte, "texte")

            local bloc = 
                '<div style="margin: 0.5em 0; border: 1px solid #ccc; border-radius: 10px; overflow: hidden; font-size: 90%;">' ..
                '<div style="background-color: ' .. couleurFond .. '; color: ' .. couleurTexte .. '; text-align: center; padding: 0.5em; font-weight: bold;">' ..
                mw.text.encode(titre) .. mandatBlock .. 
                '</div>' ..
                '<div style="display: flex; justify-content: space-between; align-items: center; padding: 0.5em;">' ..
                '<div style="text-align: left; flex: 1;">← [[' .. mw.text.encode(predecesseur) .. ']]</div>' ..
                '<div style="flex: 0 0 auto; padding: 0 1em;">·</div>' ..
                '<div style="text-align: right; flex: 1;">[[' .. mw.text.encode(successeur) .. ']] →</div>' ..
                '</div></div>'

            table.insert(result, bloc)
        end
    end

    return table.concat(result, "\n")
end

return p