FANDOM


local p = {}
 
-- function to output the appropriate icon for each article
local function icon(code, px, blank)
    local image
    if code == "FA" then
        image = "[[File:LinkFA-star.png|%dpx]]"
    elseif code == "GA" then
        image = "[[File:GoodIcon.png|%dpx]]"
    elseif code == "CA" then
        image = "[[File:30px-ComprehensiveArticle.png|%dpx]]"
    elseif code == "FFA" then
        image = "[[File:LinkDFA-Star.png|%dpx]]"
    elseif code == "FGA" then
        image = "[[File:30px-FormerGAicon.png|%dpx]]"
    elseif code == "FCA" then
        image = "[[File:30px-FormerCAIcon.png|%dpx]]"
    else
        image = blank or "[[File:Blank.svg|%dpx]]"
    end
    return image:format(px)
end
 
-- primary function called by template
function p._main(args)
 
    -- initialize main variables from parameters
    local topictype = (args.type or ""):upper()            -- topic type
    local title = args.title or " "                        -- topic title
    local titlestatus = (args.titlestatus or ""):upper()   -- status of title article
    local fullcategory = args.fullcategory                 -- category for full list of possible articles
 
    -- process unnamed parameters, which alternate between status and article
    local statuslist = {}                                  -- table that will contain list of statuses
    local articlelist = {}                                 -- table that will contain list of articles
    for n, value in ipairs(args) do
        if n % 2 == 1 then
            statuslist[#statuslist + 1] = value:upper()
        else
            articlelist[#articlelist + 1] = value
        end
    end
 
    local linecount = #articlelist
    if fullcategory then
        linecount = linecount + 1
    end
 
    local columns
    if linecount <= 2 then
        columns = 1
    elseif linecount <= 8 then
        columns = 2
    else
        columns = 3
    end
 
    -- declare variable that will contain background color
    local bgcolor
    -- determines background color based on topictype
    if topictype == "FT" then
        bgcolor = "FAFAD2"
    elseif topictype == "GT" then
        bgcolor = "ADDFAD"
    elseif topictype == "CT" then
        bgcolor = "FAB09E"
    else
        bgcolor = "FFFFFF" -- default to white if topictype is unrecognized
    end
 
    -- build finished product
    local ret = {}
    ret[#ret + 1] = string.format('<div style="margin: 1em 0; padding: 7px; background-color: #%s; border: 1px solid #999; ', bgcolor)
    ret[#ret + 1] = 'box-shadow: 0.1em 0.1em 0.5em rgba(0,0,0,0.75); -moz-box-shadow: 0.1em 0.1em 0.5em rgba(0,0,0,0.75); -webkit-box-shadow: 0.1em 0.1em 0.5em rgba(0,0,0,0.75); '
    ret[#ret + 1] = 'border-radius: 1em; -moz-border-radius: 1em; -webkit-border-radius: 1em; width: auto;">\n'
    ret[#ret + 1] = string.format("<big><center>%s '''%s'''</center></big>\n", icon(titlestatus, 20, ""), title)
    ret[#ret + 1] = string.format('<div style="column-count: %d; -moz-column-count: %d; -webkit-column-count: %d;">\n', columns, columns, columns)
    -- this CSS creates a proper HTML list without bullets or indentation
    ret[#ret + 1] = '<ul style="list-style: none; padding-left: 0; margin-top: 0;">\n'
 
    -- combine statuslist entries with the corresponding articlelist entries, calling icon() function to convert code into image
    for n, article in ipairs(articlelist) do
        ret[#ret + 1] = string.format("<li>%s %s</li>\n", icon(statuslist[n], 15), article)
    end
    -- if a category is provided, add an extra line with the category link
    if fullcategory then
        ret[#ret + 1] = string.format("<li>(''[[:Category:%s|Full list of possible articles]]'')</li>\n", fullcategory)
    end
 
    ret[#ret + 1] = "</ul></div></div>"
 
    return table.concat(ret)
end
 
function p.main(frame)
    local args = {}
    for k, v in pairs(frame:getParent().args) do
        v = v:match('^%s*(.-)%s*$') -- trim whitespace
        if v ~= '' or type(k) == 'number' then
            args[k] = v
        end
    end
    return p._main(args)
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.