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 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 header = '{|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 foot1 = '' .. ' For more '

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

local outText = '\n' .. '{| class="" style="background-color:transparent;'                   .. ' color:inherit; width:100%;"\n' .. '|-\n' .. '| valign="top" style="width:50%;" |\n\n'

outText = outText .. "==Latest Major Events==\n" .. header .. lastLTE({"5"}) .. foot1 .. "events, click [[:Category:Events"                   .. foot2

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

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

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

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

outText = outText .. "|}\n"

return outText end

return p

-- --