Module:Video game release table
Implements {{Video game release table}}
require('strict')
local getArgs = require('Module:Arguments').getArgs
local p = {}
local function usedRow(args, maxLine)
local usedRow = {}
for lineNum = 1, 3 do -- rowHeader has 3 items
local row = string.char(lineNum + 64) -- 1 => 'A', 2 => 'B'
for line = 1, maxLine do
if args[line .. row] then
table.insert(usedRow, row)
break
end
end
end
return usedRow
end
local function row(builder, args, usedRow, line)
if args[line] == nil then return end
local tr = builder:tag('tr')
local th = tr:tag('th')
th
:wikitext(args[line])
:attr('scope', 'row')
if args[line .. 'W'] then -- 'W' for worldwide
tr:tag('td')
:attr('colspan', table.maxn(usedRow))
:wikitext(args[line .. 'W'])
return
end
for index, row in ipairs(usedRow) do
local text = args[line .. row] or ''
if string.lower(text) ~= 'left' then
local colspan = 1
for flag = index + 1, table.maxn(usedRow) do
if string.lower(args[line .. usedRow[flag]] or '') == 'left' then
colspan = colspan + 1
else
break
end
end
local td = tr:tag('td')
if string.lower(text) == 'n/a' then
td:wikitext('N/A')
:addClass('table-na')
:css('background-color', '#ececec')
:css('color', '#2C2C2C')
else
td:wikitext(text)
end
if colspan > 1 then
td:attr('colspan', colspan)
end
end
end
end
local function abbr(full_text, abbreviation)
return string.format('<abbr title="%s">%s</abbr>', full_text, abbreviation)
end
function p._main(args)
-- Main module code goes here.
local builder = mw.html.create('table')
local maxLine = 24
local usedRow = usedRow(args, maxLine)
local rowHeader = {
A = abbr('Japan', 'JP'),
B = abbr('North America', 'NA'),
C = abbr('Europe and/or Australasia', 'EU'),
}
builder
:addClass('video-game-release-table wikitable plainrowheaders floatright')
:css('text-align', 'center')
local title = ''
if args.title and args.title ~= '' then
title = args.title
else
title = 'Release years by platforms'
end
builder:tag('caption'):wikitext(title)
local tr = builder:tag('tr')
tr:tag('th'):attr('scope', 'col'):wikitext('Platform')
for _, row in ipairs(usedRow) do
if args['region' .. row] then
rowHeader[row] = args['region' .. row]
end
tr:tag('th'):wikitext(rowHeader[row]):attr('scope', 'col')
end
for line = 1, maxLine do
row(builder, args, usedRow, line)
end
return builder
end
function p.main(frame)
local args = getArgs(frame)
return p._main(args)
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.