Module:Box

From JoJo's Bizarre Encyclopedia - JoJo Wiki
Revision as of 10:30, 31 May 2024 by Vish (talk | contribs) (Created page with "local p = {} function p.render(frame) local args = frame:getParent().args local title = args.Title or "Title" local icon = args.Icon or "" local bg = args.bg or "#7b9cd1" local bg2 = args.bg2 or "#e7bafd4d" local width = args.width or "auto" local align = args.align or "" local height = args.height or "auto" local style = args.Style or "" local color = args.Color or "white" local rows = {} for i = 1, 100 do if arg...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Box/doc

local p = {}

function p.render(frame)
    local args = frame:getParent().args
    local title = args.Title or "Title"
    local icon = args.Icon or ""
    local bg = args.bg or "#7b9cd1"
    local bg2 = args.bg2 or "#e7bafd4d"
    local width = args.width or "auto"
    local align = args.align or ""
    local height = args.height or "auto"
    local style = args.Style or ""
    local color = args.Color or "white"

    local rows = {}
    for i = 1, 100 do
        if args["r"..i] then
            table.insert(rows, args["r"..i])
        end
    end

    local rowItems = ""
    for _, row in ipairs(rows) do
        if style == "2" then
            rowItems = rowItems .. row .. "\n"
        else
            rowItems = rowItems .. "<li>" .. row .. "</li>\n"
        end
    end

    local boxContent = '<div class="boxTemplate" style="width:'..width..'; display: flow-root; '
    if align == "center" then
        boxContent = boxContent .. 'margin:auto;'
    elseif align == "left" then
        boxContent = boxContent .. 'margin-left:0; margin-right:auto; display:inline-table;'
    elseif align == "right" then
        boxContent = boxContent .. 'margin-left:auto; margin-right:0; display:inline-table;'
    end
    boxContent = boxContent .. ' background-color: '..bg2..';">'
    boxContent = boxContent .. '<div class="boxTemplateTitle diamond" style="background-color:'..bg..'; color: '..color..';'
    if style == "capital" then
        boxContent = boxContent .. ' text-transform:uppercase;'
    end
    boxContent = boxContent .. '">'
    if icon ~= "" then
        boxContent = boxContent .. '[[File:'..icon..'|20px|link=]]'
    end
    boxContent = boxContent .. " '''"..title.."'''</div>"
    boxContent = boxContent .. '<div class="boxTemplate2 volume" style="max-height:'..height..';">'
    boxContent = boxContent .. '<ul class="'
    if style == "2" then
        boxContent = boxContent .. 'boxTemplateList2'
    else
        boxContent = boxContent .. 'boxTemplateList'
    end
    boxContent = boxContent .. '">'
    boxContent = boxContent .. rowItems
    boxContent = boxContent .. '</ul></div></div>'

    return boxContent
end

return p