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

-- <pre>
local p = {}

function p.load()
    return mw.loadData("Module:CEvents/Data")
end

function p.table( frame )
    local ce_data = p.load()
    
    local year = frame.args[1]

    local table = mw.html.create("table")
        :addClass("wikitable")
        :css("width", "100%")
        :css("text-align", "center")
        :tag("tr")
            :tag("th"):wikitext("Picture"):done()
            :tag("th"):wikitext("Period"):done()
            :tag("th"):wikitext("Description"):done()
            :done()
    
    for _, data in ipairs(ce_data) do
        local d, m, y = data.date:match '(%d+)/(%d+)/(%d+)'
        
        if y == year then
            local start_date = os.time{year=y, month=m, day=d}
            local end_date = os.time{year=y, month=m, day=d + 6}
            
            table:tag("tr")
                :tag("td"):wikitext("[[File:" .. data.imag .. "|link=" .. data.link .. "|350px]]"):done()
                :tag("td"):wikitext(os.date("%d/%m/%Y", start_date) .. " - " .. os.date("%d/%m/%Y", end_date)):done()
                :tag("td"):wikitext("[" .. data.link .. " " .. data.desc .. "]"):done()
                :done()
        end
    end
    
    return tostring(table)
end

function p.slider( frame )
    local ce_data = p.load()
    
    local qty = frame.args[1] - 1
    
    local count = 0
    for i, _ in ipairs(ce_data) do
        count = count + 1
    end
    
    local output = {}
    for i = 0, qty do
        local e = ce_data[count-i]
        table.insert(output, e.imag .. "|" .. e.desc .. "|linktext=Celebration Events Info|link=" .. e.link)
    end
    
    return table.concat(output,"\n")
end

return p
-- </pre>
-- [[Category:Lua Modules]]
Community content is available under CC-BY-SA unless otherwise noted.