Sari la conținut

Modul:Infocasetă: Diferență între versiuni

De la Enciclopedia Trimeria
Pagină înlocuită cu „local p = {} function p.infobox(frame) local args = frame.args local title = args.title or args.nume or mw.title.getCurrentTitle().text local image = args.image or "" local caption = args.caption or "" local rows = args.rows or "" local root = mw.html.create("table") :addClass("infocaseta") :css("width", "320px") :css("float", "right") :css("margin", "0 0 1em 1em") :css("border", "1px solid #5b8...”
Etichetă: Înlocuit
mFără descriere a modificării
 
(Nu s-au afișat 8 versiuni intermediare efectuate de același utilizator)
Linia 2: Linia 2:


function p.infobox(frame)
function p.infobox(frame)
     local args = frame.args
     local args = frame.args


     local title = args.title or args.nume or mw.title.getCurrentTitle().text
     local title = args.title or mw.title.getCurrentTitle().text
     local image = args.image or ""
     local image = args.image or ""
     local caption = args.caption or ""
     local caption = args.caption or ""
    local rows = args.rows or ""


     local root = mw.html.create("table")
     local root = mw.html.create("table")
Linia 17: Linia 15:
         :css("border", "1px solid #5b8a3c")
         :css("border", "1px solid #5b8a3c")
         :css("background", "#f8fff5")
         :css("background", "#f8fff5")
        :css("border-collapse", "collapse")
        :css("font-size", "88%")


     root:tag("tr")
     root:tag("tr")
Linia 25: Linia 25:
         :css("font-size", "120%")
         :css("font-size", "120%")
         :css("padding", "8px")
         :css("padding", "8px")
        :css("text-align", "center")
         :wikitext(title)
         :wikitext(title)


     if image ~= "" then
     if image ~= "" then
 
         local tr = root:tag("tr")
         local row = root:tag("tr")
         local td = tr:tag("td")
 
         row:tag("td")
             :attr("colspan", "2")
             :attr("colspan", "2")
             :css("text-align", "center")
             :css("text-align", "center")
             :css("padding", "5px")
             :css("padding", "8px")
            :wikitext(image)
 
        td:wikitext(image)


         if caption ~= "" then
         if caption ~= "" then
             row:tag("div")
             td:tag("div")
                 :css("font-size", "90%")
                 :css("font-size", "90%")
                 :css("color", "#666")
                 :css("color", "#666")
                :css("margin-top", "4px")
                :css("text-align", "center")
                 :wikitext(caption)
                 :wikitext(caption)
         end
         end
     end
     end


     root:wikitext(rows)
 
     local function addRow(label, value)
        if value and value ~= "" and value ~= "nil" then
            local tr = root:tag("tr")
            tr:tag("th")
                :css("text-align", "left")
                :css("padding", "5px")
                :css("width", "40%")
                :css("font-weight", "bold")
                :wikitext(label)
 
            tr:tag("td")
                :css("padding", "5px")
                :wikitext(value)
        end
    end
 
    if args.rows and args.rows ~= "" then
        for linie in string.gmatch(args.rows, "[^\r\n]+") do
            local eticheta, valoare = string.match(linie, "^%s*(.-)%s*//%s*(.-)%s*$")
            if eticheta and valoare then
                addRow(eticheta, valoare)
            end
        end
    end


     return tostring(root)
     return tostring(root)
end
end


return p
return p

Versiunea curentă din 7 iunie 2026 16:43

Documentația acestui modul poate fi creată la Modul:Infocasetă/doc

local p = {}

function p.infobox(frame)
    local args = frame.args

    local title = args.title or mw.title.getCurrentTitle().text
    local image = args.image or ""
    local caption = args.caption or ""

    local root = mw.html.create("table")
        :addClass("infocaseta")
        :css("width", "320px")
        :css("float", "right")
        :css("margin", "0 0 1em 1em")
        :css("border", "1px solid #5b8a3c")
        :css("background", "#f8fff5")
        :css("border-collapse", "collapse")
        :css("font-size", "88%")

    root:tag("tr")
        :tag("th")
        :attr("colspan", "2")
        :css("background", "#6aa84f")
        :css("color", "white")
        :css("font-size", "120%")
        :css("padding", "8px")
        :css("text-align", "center")
        :wikitext(title)

    if image ~= "" then
        local tr = root:tag("tr")
        local td = tr:tag("td")
            :attr("colspan", "2")
            :css("text-align", "center")
            :css("padding", "8px")

        td:wikitext(image)

        if caption ~= "" then
            td:tag("div")
                :css("font-size", "90%")
                :css("color", "#666")
                :css("margin-top", "4px")
                :css("text-align", "center")
                :wikitext(caption)
        end
    end


    local function addRow(label, value)
        if value and value ~= "" and value ~= "nil" then
            local tr = root:tag("tr")
            tr:tag("th")
                :css("text-align", "left")
                :css("padding", "5px")
                :css("width", "40%")
                :css("font-weight", "bold")
                :wikitext(label)

            tr:tag("td")
                :css("padding", "5px")
                :wikitext(value)
        end
    end

    if args.rows and args.rows ~= "" then
        for linie in string.gmatch(args.rows, "[^\r\n]+") do
            local eticheta, valoare = string.match(linie, "^%s*(.-)%s*//%s*(.-)%s*$")
            if eticheta and valoare then
                addRow(eticheta, valoare)
            end
        end
    end

    return tostring(root)
end

return p