Module:Available

-- -- Lua script to display Latest Items Info on Main Page -- --

local p = {}

local LatestData = mw.loadData( 'Module:LatestInfo/data' ) local lastLTE = require ("Module:LTEvent").getLastLTE local lastUpdate = require("Module:UpdateNumber").getLastVer local lastME = require("Module:MiniEvent").getLastME local upcomingME = require("Module:MiniEvent").getUpcomingME local date = require("Dev:Date")

local function strDate(sDate) local theDate = date(sDate)

return string.gsub(theDate:fmt("%d"), "^0", "") .. theDate:fmt(" %B %Y") end

local function Characters(count) local limit = count local tIndex = {} if not limit or limit == 0 then limit = 3 end

local today = os.date("%Y/%m/%d") for idx, data in ipairs(LatestData) do       if data[3] and today >= data[3] then table.insert(tIndex, data) end end

table.sort(tIndex, function(a,b) return a[3] > b[3] end) local outText = "" --   for i, ver in ipairs(tIndex) do --        outText = outText .. singleEvent(ver[2], ver[3], "L", "") --       if i >= count then break end --   end

local retText = ""

for i, v in ipairs(tIndex) do       local today = os.date("%Y/%m/%d")

local linkText = v[1] and "" or "Work In Progress"

if v[2] then linkText = ""                       .. (v[1] or "")                        .. "" else local space = ""

for cName in mw.text.gsplit(v[1], "%s*%$%s*") do               linkText = linkText .. space .. "" .. cName .. "" space = ", " end end

retText = retText .. "* "               .. linkText .. " "               .. strDate(v[3]) .. " \n"

if i>= limit then break end end return retText end

function p.latest(frame)

local tArgs

if frame == mw.getCurrentFrame then fParent = frame:getParent tArgs = fParent.args

if (fParent.args[1]) then tArgs = fParent.args else tArgs = frame.args end else tArgs = frame end

local headerlast = '{|width="100%"\n' .. '|- valign="top" cellpadding="0px"' .. ' cellspacing="0px"\n' .. '|style="width:50%; padding: .0em;'                   .. ' border: 1px solid #cbcbcb;'                    .. ' color: #000;'                    .. ' background-color: #e5e5ea;"|\n' local headerupcoming = '{|width="100%"\n' .. '|- valign="top" cellpadding="0px"' .. ' cellspacing="0px"\n' .. '|style="width:50%; padding: .0em;'                   .. ' border: 3px solid #F94444;'                    .. ' color: #000;'                    .. ' background-color: #e5e5ea;"|\n' local foot1 = '' .. ' For more '

local foot2 = '|here]] \n|}\n'

local outText = "==Upcoming Events ==\n" .. headerupcoming .. upcomingME({"5"}) .. "\n|}\n"

outText = outText .. '{| class="" style="background-color:transparent;'                   .. ' color:inherit; width:100%;"\n' .. '|-\n' .. '| valign="top" style="width:50%;" |\n\n' outText = outText .. "==Latest Major Events==\n" .. headerlast .. lastLTE({"5"}) .. foot1 .. "events, click [[:Category:Events"                   .. foot2

outText = outText .. "==Latest Mini Events==\n" .. headerlast .. lastME({"5"}) .. foot1 .. "events, click [[:Category:Mini Events"                   .. foot2

outText = outText .. '\n| valign="top" style="width:50%;" |\n\n'

outText = outText .. "==Latest Updates==\n" .. headerlast .. lastUpdate({"5"}) .. foot1 .. "updates, click [[Content Updates"                   .. foot2

outText = outText .. "==Latest Characters==\n" .. headerlast .. Characters(5) .. foot1 .. "characters, click [[:Category:Character Collections"                   .. foot2

outText = outText .. "|}\n"

return outText end

return p

-- --