Module:Event

From The Obey Me Wiki
Jump to: navigation, search

local cardList = {}

function cardList.add(frame)
    -- iterate input into array
    local contact = {}
    for i = 1, 100 do
		contact[i] = frame.args[i]
    end

    -- starts the table
    local html = '<div class="flex-container">\n'
    -- starting from first element of the array
    for card = 1, table.getn(contact), 7 do
        -- opens a new row
        html = html .. "\n"

        -- iterates between 1~7
        for count = 0, 6 do
            html =
                html ..
                "<div class=\"event-gallery\"><span class=\"desktop-ver\"><div class=\"eventflex\">[[File:" ..
                    string.gsub(string.gsub(string.gsub(contact[card+count], "\n", ""), ":", " -"), "?", " -") ..
                        ".png|center|195px|class=cardimage|link=" .. string.gsub(contact[card+count], "\n", "") .. "]]</div></span>\n<span class=\"mobile-ver\"><div class=\"eventflex\">[[File:" ..
                    string.gsub(string.gsub(string.gsub(contact[card+count], "\n", ""), ":", " -"), "?", " -") ..
                        ".png|center|155px|class=cardimage|link=" .. string.gsub(contact[card+count], "\n", "") .. "]]</div></span>\n[[" .. string.gsub(frame.args[card+count], "\n", "") .. "]]</div>\n"

            if card + count + 1 > table.getn(contact) then
                break
            end
        end

        -- completes one row of card
        html = html .. "\n"
    end
    return html .. "</div>"
end
return cardList

--[[File:{{{1}}}.png|center|class="cardlistimage"|link={{{1}}}]]