Module:Main Page
Documentation for this module may be created at Module:Main Page/Documentation
local p = {}
local cargo = mw.ext.cargo
local tab2 = require("Module:Tab2")
local utilsCode = require("Module:UtilsCode")
function p._DisplayGameList(frame)
return p.DisplayGameList()
end
function p.DisplayGameList()
local tabCaptions = {
{type = "main", caption = "Main Series"},
{type = "remake", caption = "Remakes"},
{type = "spinoff", caption = "Spin-Offs"},
}
-- Get all stored games
local tables = "Games"
local fields = "name, subtitle, initialism, mainrelease, type"
local args = {
orderBy = "mainrelease ASC"
}
local games = cargo.query(tables, fields, args)
-- Generate tabs
local maingames = mw.html.create("div")
:addClass("game-container main-games")
local remakes = mw.html.create("div")
:addClass("game-container remakes")
local spinoffs = mw.html.create("div")
:addClass("game-container spin-offs")
local frame = mw.getCurrentFrame()
for key, game in ipairs(games) do
if game["type"] == "main" then
maingames:node(mw.html.create("div")
:addClass("game")
:wikitext("<span class='year'>" .. string.sub(game["mainrelease"], 1, 4) .. "</span>" .. frame:expandTemplate{title = game["initialism"]} .. "[[File:" .. game["initialism"] .. " Tile.png|link=]]"))
end
end
local tabs = {}
table.insert(tabs, 1, {tabName = "Main Series", tabCaption = "", tabContent = tostring(maingames)})
table.insert(tabs, 2, {tabName = "Remakes", tabCaption = "", tabContent = tostring(remakes)})
table.insert(tabs, 3, {tabName = "Spin-Offs", tabCaption = "", tabContent = tostring(spinoffs)})
return tab2.Main(tabs, 1, "top", 3, "", "100%", "", "center")
end
return p