Basculer le menu
Changer de menu des préférences
Basculer le menu personnel
Non connecté(e)
Votre adresse IP sera visible au public si vous faites des modifications.

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

De Nefald
Hiob (discussion | contributions)
Aucun résumé des modifications
Hiob (discussion | contributions)
m espace insécable
 
(Une version intermédiaire par le même utilisateur non affichée)
Ligne 34 : Ligne 34 :


-- ============================================================
-- ============================================================
-- Construit une icône + valeur via filepath (pas de wikilink)
-- Construit une icône + valeur via wikilink parsé
-- ============================================================
-- ============================================================
local function buildIcon(amount, imageFile, altText, frame)
local function buildIcon(amount, imageFile, altText)
     local url = frame:callParserFunction("filepath", imageFile)
     local img = "[[Fichier:" .. imageFile .. "|24px|link=|alt=" .. altText .. "]]"
    local img = '<img src="' .. url .. '" alt="' .. altText .. '" width="24" height="24" class="monnaie__img" loading="lazy" />'
     return '<span class="monnaie__groupe">'
     return '<span class="monnaie__groupe">'
         .. '<span class="monnaie__valeur">' .. amount .. '</span>'
         .. '<span class="monnaie__valeur">' .. amount .. '&#160;</span>'
         .. '<span class="monnaie__icone">'  .. img    .. '</span>'
         .. '<span class="monnaie__icone">'  .. img    .. '</span>'
         .. '</span>'
         .. '</span>'
Ligne 50 : Ligne 49 :
-- ============================================================
-- ============================================================
local function parseString(input)
local function parseString(input)
    -- Tentative de lecture comme nombre pur (= sols)
     local n = tonumber(input)
     local n = tonumber(input)
     if n then return math.floor(n) end
     if n then return math.floor(n) end
Ligne 121 : Ligne 119 :
     -- Construction du HTML
     -- Construction du HTML
     local parts = {}
     local parts = {}
     if ecus  > 0 then parts[#parts+1] = buildIcon(ecus,  IMAGES.ecu,  "écu",   frame) end
     if ecus  > 0 then parts[#parts+1] = buildIcon(ecus,  IMAGES.ecu,  "écu")   end
     if oboles > 0 then parts[#parts+1] = buildIcon(oboles, IMAGES.obole, "obole", frame) end
     if oboles > 0 then parts[#parts+1] = buildIcon(oboles, IMAGES.obole, "obole") end
     if sols  > 0 then parts[#parts+1] = buildIcon(sols,  IMAGES.sol,  "sol",   frame) end
     if sols  > 0 then parts[#parts+1] = buildIcon(sols,  IMAGES.sol,  "sol")   end
     if #parts == 0 then
     if #parts == 0 then
         parts[#parts+1] = buildIcon(0, IMAGES.sol, "sol", frame)
         parts[#parts+1] = buildIcon(0, IMAGES.sol, "sol")
     end
     end


     return '<span class="monnaie" title="' .. tooltip .. '">'
     local html = '<span class="monnaie" title="' .. tooltip .. '">'
         .. table.concat(parts)
         .. table.concat(parts)
         .. '</span>'
         .. '</span>'
    return frame:preprocess(html)
end
end


return p
return p
Les témoins (''cookies'') nous aident à fournir nos services. En utilisant nos services, vous acceptez notre utilisation de témoins.