Module:Events

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\" style=\"min-width: 320px; margin: 5px auto 20px auto; text-align: center;\">\n'
	local imageName = ''
    -- starting from first element of the array
    for card = 1, table.getn(contact), 10 do
        -- opens a new row
        html = html .. "\n"

        -- iterates between 1~10
        for count = 0, 9 do
        	imageName = string.gsub(contact[card+count], ":", " -")
            html =
                html ..
                "<div class=\"event-wrap\"><div class=\"event-frame\"><span class=\"event-desktop\">[[File:" ..
                    string.gsub(imageName, "\n", "") ..
                        ".png|center|290px|link=" .. string.gsub(contact[card+count], "\n", "") .. "]]</span>\n<span class=\"event-mobile\">[[File:" ..
                    string.gsub(imageName, "\n", "") ..
                        ".png|center|200px|link=" .. string.gsub(contact[card+count], "\n", "") .. "]]</span></div>\n<small>" .. contact[card + count] .. "</small></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}}} Devilgram.png|center|link={{{1}}}/Devilgram]]