Modul:Ikhtisar serial: Perbedaan antara revisi

Dari Wikipedia bahasa Indonesia, ensiklopedia bebas
Konten dihapus Konten ditambahkan
k update
k Mengembalikan suntingan oleh Baloo Official (bicara) ke revisi terakhir oleh Dan1zch
Tag: Pengembalian
Baris 1: Baris 1:
-- This module implements {{Ikhtisar serial}}.
-- This module implements {{Ikhtisar serial}}.


require('strict')
require('Module:No globals')
local yesno = require('Modul:Yesno')
local yesno = require('Module:Yesno')
local HTMLcolor = mw.loadData( 'Modul:Color contrast/colors' )
local HTMLcolor = mw.loadData( 'Module:Color contrast/colors' )


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Baris 12: Baris 12:
local SeriesOverview = {}
local SeriesOverview = {}


function SeriesOverview.cellspan(SeasonEntries, SeasonEntries_ordered, key, cell, multipart, setspan)
function SeriesOverview.cellspan(SeasonEntries, SeasonEntries_ordered, key, cell, multipart)
if setspan ~= nil then return setspan end
local spanlength = 1
local spanlength = 1
Baris 29: Baris 27:
else break end
else break end
else
else
if not entry[key] and (key == 'network' or ((string.sub(key,0,7) == 'postaux' or string.sub(key,0,3) == 'aux') and (not entry.special or entry.episodes)) or (string.sub(key,0,4) == 'info') and multipart) then
if not entry[key] and (key == 'network' or (string.sub(key,0,3) == 'aux' and (not entry.special or entry.episodes)) or (string.sub(key,0,4) == 'info') and multipart) then
spanlength = spanlength + 1
spanlength = spanlength + 1
else break end
else break end
Baris 85: Baris 83:
return infoCell
return infoCell
end

function SeriesOverview.endtable()
return "</table></div>"
end
end


function SeriesOverview.new(frame, args)
function SeriesOverview.new(frame, args)
args = args or {}
args = args or {}
local initialArticle = args['1'] or ''
local initialArticle = args['1'] or ''
local categories = ''
local categories = ''
Baris 108: Baris 101:
:addClass('plainrowheaders')
:addClass('plainrowheaders')
:css('text-align', 'center')
:css('text-align', 'center')

:css('height', '1px')
:css('display', 'table')
-- Sortable
-- Sortable
if args.sortable then
if args.sortable then
root:addClass('sortable');
root:addClass('sortable');
end
-- "Series overview" ID
if args.id then
root:attr('id', 'Series overview')
end
end
Baris 126: Baris 112:
end
end


-- Caption
-- Summary
if args.caption then
if args.summary then
root:tag('caption'):wikitext(frame:expandTemplate{title='Screen reader-only',args={args.caption}})
root:attr('summary'):wikitext(args.summary)
end
end

-- Extract seasons info and place into a 3D array
-- Extract seasons info and place into a 3D array
local SeasonEntries = {}
local SeasonEntries = {}
for k,v in pairs(args) do
for k,v in pairs(args) do
local str, num, str2 = string.match(k, '([^%d]*)(%d*)(%a*)')
local str, num, str2 = string.match(k, '([^%d]*)(%d*)(%a*)')
if tonumber(k) ~= 1 and num ~= '' then
if num ~= '' then
-- Special
-- Special
local special = false
local special = false
Baris 169: Baris 155:
local param = 'info' .. string.char(i)
local param = 'info' .. string.char(i)
if args[param] then numInfoCells = numInfoCells + 1 end
if args[param] then numInfoCells = numInfoCells + 1 end
end
-- Use of colors and network
local noColors = true
local setNetwork = false
if (args.multiseries and args.network) then setNetwork = true end
for i = 1, #SeasonEntries_ordered do
local season, entry = SeasonEntries_ordered[i], SeasonEntries[SeasonEntries_ordered[i]]
for j0 = string.byte('A')-1, string.byte('Z') do
local j = string.char(j0)
if j0 == string.byte('A')-1 then j = '' end
if entry['color' .. j] then noColors = false end
if entry['network' .. j] then setNetwork = true end
end
end
end
Baris 188: Baris 160:
-- @ = string.char(64), A = string.char(65)
-- @ = string.char(64), A = string.char(65)
local topInfoCell = numInfoCells > 0 and string.char(numInfoCells + (string.byte('A') - 1)) or '@'
local topInfoCell = numInfoCells > 0 and string.char(numInfoCells + (string.byte('A') - 1)) or '@'

-- Networks are included if the very first entry sets the first network
-- Networks are included if the very first entry sets the first network
local setNetwork = (args.multiseries and args.network) or firstRow.network or firstRow.networkA
local networkTransclude = args.network_transclude
local networkTransclude = args.network_transclude
if (networkTransclude == 'onlyinclude' and title.fullText == initialArticle) or (networkTransclude == 'noinclude' and title.fullText ~= initialArticle) then
if (networkTransclude == 'onlyinclude' and title.fullText == initialArticle) or (networkTransclude == 'noinclude' and title.fullText ~= initialArticle) then
Baris 230: Baris 203:
:wikitext(args.seriesT or args.seasonT or (matchDMY and 'Musim') or 'Musim')
:wikitext(args.seriesT or args.seasonT or (matchDMY and 'Musim') or 'Musim')
for _a = 1, 3 do
-- Aux headers
for i = string.byte('A'), string.byte('Z') do
if _a == 1 or _a == 3 then
local param = 'aux' .. string.char(i)
-- Aux headers
if args[param] then
local auxtype = (_a == 3 and 'post' or '') .. 'aux'
numAuxCells = numAuxCells + 1
for i = string.byte('A'), string.byte('Z') do
local param = auxtype .. string.char(i)
if args[param] then
numAuxCells = numAuxCells + 1
headerRow:tag('th')
:attr('scope', 'col')
:css('padding', cellPadding)
:attr('rowspan', allReleased and 1 or 2)
:wikitext(args[param])
end
end
end

if _a == 2 then
-- Episodes header
headerRow:tag('th')
headerRow:tag('th')
:attr('scope', 'col')
:attr('scope', 'col')
:attr('rowspan', allReleased and 1 or 2)
:attr('colspan', 2)
:css('padding', cellPadding)
:css('padding', cellPadding)
:wikitext(args.episodesT or 'Episode')
:attr('rowspan', allReleased and 1 or 2)
:wikitext(args[param])
end
end
end
end

-- Episodes header
headerRow:tag('th')
:attr('scope', 'col')
:attr('rowspan', allReleased and 1 or 2)
:attr('colspan', 2)
:css('padding', cellPadding)
:wikitext('Episode')


-- Originally aired header
-- Originally aired header
local OriginallyColspan = (not allReleased and setNetwork) and 3 or 2
local OriginallyColspan = (not allReleased and setNetwork) and 3 or 2
local countryBlurb = ''
if args.country then
countryBlurb = ' (' .. args.country .. ')'
end
headerRow:tag('th')
headerRow:tag('th')
:attr('scope', 'col')
:attr('scope', 'col')
:attr('colspan', OriginallyColspan)
:attr('colspan', OriginallyColspan)
:wikitext('Waktu ' .. releasedBlurb .. countryBlurb)
:wikitext('Waktu ' .. releasedBlurb)
-- Network subheader for released series
-- Network subheader for released series
if setNetwork and allReleased then
if setNetwork and allReleased then
Baris 278: Baris 240:
end
end
-- Information headers
-- Subheader row
local subheaderRow = mw.html.create('tr')

-- Info header
if topInfoCell ~= '@' then
if topInfoCell ~= '@' then
for i = string.byte('A'), string.byte(topInfoCell) do
for i = string.byte('A'), string.byte(topInfoCell) do
Baris 292: Baris 257:
end
end
end
end
-- Subheader row
local subheaderRow = mw.html.create('tr')


if not allReleased then
if not allReleased then
Baris 301: Baris 263:
:attr('scope', 'col')
:attr('scope', 'col')
:wikitext('Awal ' .. releasedBlurb)
:wikitext('Awal ' .. releasedBlurb)

-- Last aired subheader
-- Last aired subheader
subheaderRow:tag('th')
subheaderRow:tag('th')
:attr('scope', 'col')
:attr('scope', 'col')
:wikitext('Akhir ' .. releasedBlurb)
:wikitext('Akhir ' .. releasedBlurb)
-- Network subheader for aired series
-- Network subheader for aired series
if setNetwork then
if setNetwork then
Baris 364: Baris 326:
local k = string.char(k0)
local k = string.char(k0)
if k0 == string.byte('A')-1 then k = '' end
if k0 == string.byte('A')-1 then k = '' end
-- Part header
if entry.part and k == '' then
root:node(entry.part)
end
-- New season row
-- New season row
-- local seasonRow = (entry['color' .. k] or entry['episodes' .. k] or entry['start' .. k] or entry['end' .. k]) and root:tag('tr') or mw.html.create('tr')
local seasonRow = entry['start' .. k] and root:tag('tr') or mw.html.create('tr')
local seasonRow = entry['start' .. k] and root:tag('tr') or mw.html.create('tr')
seasonRow:css('height', '100%')
local borderBottom = '2px solid #8D939A'
-- Series name for group overviews
-- Series name for group overviews
if X == 1 and (k == '' or k == 'A') and args.series then
if X == 1 and (k == '' or k == 'A') and args.series then
Baris 383: Baris 336:
:attr('rowspan', SeasonEntriesRows)
:attr('rowspan', SeasonEntriesRows)
:wikitext(args.series)
:wikitext(args.series)
:css('border-bottom', borderBottom)
end
end
if X == #SeasonEntries_ordered and args.series then
-- Coloured cell
seasonRow:css('border-bottom', borderBottom)
if entry['color' .. k] ~= nil and HTMLcolor[entry['color' .. k]] == nil then
entry['color' .. k] = '#'..(mw.ustring.match(entry['color' .. k], '^[%s#]*([a-fA-F0-9]*)[%s]*$') or '')
end
end
if splitSeason and entry.color then
if k == 'A' then
-- Season number link, included only in the first row
seasonRow:tag('td')
local cellColor
:attr('rowspan', entry.color and splits or 1)
if not noColors then
:css('background', entry.color)
if entry['color' .. k] ~= nil and HTMLcolor[entry['color' .. k]] == nil then
:css('width','10px')
entry['color' .. k] = '#'..(mw.ustring.match(entry['color' .. k], '^[%s#]*([a-fA-F0-9]*)[%s]*$') or '')
end
if splitSeason then
if entry.color then
cellColor = entry.color
else
cellColor = "linear-gradient(to bottom"
for i = 0, splits-1 do
local _color = 'color' .. string.upper(string.char(i+97))
cellColor = cellColor .. ", " .. (entry[_color] or 'rgba(0,0,0,0)') .. " " .. (100/splits *i) .. "%"
.. ", " .. (entry[_color] or 'rgba(0,0,0,0)') .. " " .. (100/splits *(i+1)) .. "%"
end
cellColor = cellColor .. ")"
end
else
cellColor = entry['color' .. k]
end
end
else
seasonRow:tag('td')
:css('background',entry['color' .. k])
:css('width','10px')
end
end
-- Season number link, included only in the first row
if k == '' or k == 'A' then
if k == '' or k == 'A' then
local colorWidth = '14px'
seasonRow:tag('th')
-- Overall table cell
local cellRow = mw.html.create(args.series and 'td' or 'th')
:attr('scope', 'row')
:attr('scope', 'row')
:attr('rowspan', splitSeason and splits or nil)
:attr('rowspan', splitSeason and splits or nil)
:attr('colspan', entry.special and not entry.episodes and 3+numAuxCells or 1)
:attr('colspan', entry.special and not entry.episodes and 3+numAuxCells or 1)
:css('height', 'inherit')
:css('padding', '0')
-- Overall inner span
local spanRow = mw.html.create('span')
spanRow
:css('width: 100%')
:css('text-align', 'center')
:css('text-align', 'center')
:wikitext((entry.link and '[[' .. entry.link .. '|' .. (entry.linkT or season) .. ']]' or (entry.linkT or season)) .. (entry.linkR or ''))
:css('float', 'left')
end
:css('width', '100%')
:css('height', '100%')
-- Aux cells
for i = string.byte('A'), string.byte('Z') do
-- Coloured nested span
local spanRow2 = mw.html.create('span')
local param = 'aux' .. string.char(i)
if entry[param .. k] then
spanRow2
local thisCell = SeriesOverview.season_cell(entry[param .. k], frame)
:css('width', colorWidth)
:css('background', cellColor)
:attr('scope', 'col')
:attr('rowspan', SeriesOverview.cellspan(SeasonEntries, SeasonEntries_ordered, param, X, (args.series and true or false)))
:css('height', '100%')
:css('float', 'left')
:css('padding', cellPadding)
seasonRow:node(thisCell)
:css('box-shadow', 'inset -1px 0 #A2A9B1')
-- Link nested span
local spanRow3 = mw.html.create('span')
spanRow3
:css('height', '100%')
:css('width', not noColors and 'calc(100% - ' .. colorWidth .. ' - 8px)' or '100%')
:css('display', 'flex')
:css('vertical-align', 'middle')
:css('align-items', 'center')
:css('justify-content', 'center')
:css('padding', not noColors and '0 4px' or '')
local spanRow4 = mw.html.create('span')
spanRow4
:addClass('nowrap')
-- Coloured span first into the overall span
if not noColors then
spanRow:node(spanRow2)
end
end
-- Link into the blank span
spanRow4:wikitext((entry.link and '[[' .. entry.link .. '|' .. (entry.linkT or season) .. ']]' or (entry.linkT or season)) .. (entry.linkR or ''))
-- Blank span into the Link nested span
spanRow3:node(spanRow4)
-- Link span second into the overall span
spanRow:node(spanRow3)
-- Overall span into the actual cell
cellRow:node(spanRow)
-- The actual cell into the season row
seasonRow:node(cellRow)
end
end
for _a = 1, 3 do
-- Episodes counts
if _a == 1 or _a == 3 then
if ((splitSeason and k == 'A' and entry.episodes ~= 'hide') or not splitSeason) then
-- Aux headers
if entry.episodes then
local thisCell = SeriesOverview.season_cell(entry.episodes, frame)
local auxtype = (_a == 3 and 'post' or '') .. 'aux'
:attr('colspan', splitSeason and 1 or 2)
-- Aux cells
:attr('rowspan', splitSeason and splits or nil)
for i = string.byte('A'), string.byte('Z') do
seasonRow:node(thisCell)
local param = auxtype .. string.char(i)
if entry[param .. k] then
elseif not entry.special then
local thisCell = SeriesOverview.season_cell(entry[param .. k], frame)
local infoCell = SeriesOverview.series_attributes( frame:expandTemplate{title='N/A',args={'TBA'}} )
:attr('scope', 'col')
infoCell
:attr('colspan', splitSeason and 1 or 2)
:attr('rowspan', SeriesOverview.cellspan(SeasonEntries, SeasonEntries_ordered, param, X, (args.series and true or false), entry[param .. k .. 'span'] or nil))
:css('padding', cellPadding)
:attr('rowspan', splitSeason and splits or nil)
seasonRow:node(thisCell)
seasonRow:node(infoCell)
end
end
end
end
end
if _a == 2 then
if splitSeason then
-- Episodes counts
if entry['episodes' .. k] then
local thisCell = SeriesOverview.season_cell(entry['episodes' .. k], frame)
if ((splitSeason and k == 'A' and entry.episodes ~= 'hide') or not splitSeason) then
if entry.episodes then
:attr('colspan', (entry.episodes ~= 'hide') and 1 or 2)
seasonRow:node(thisCell)
local thisCell = SeriesOverview.season_cell(entry.episodes, frame)
else
:attr('colspan', (splitSeason and entry.episodesA ~= 'hide') and 1 or 2)
local infoCell = SeriesOverview.series_attributes( frame:expandTemplate{title='N/A',args={'TBA'}} )
:attr('rowspan', splitSeason and splits or nil)
:attr('colspan', (entry.episodes ~= 'hide') and 1 or 2)
seasonRow:node(thisCell)
seasonRow:node(infoCell)
elseif not entry.special then
local infoCell = SeriesOverview.series_attributes( frame:expandTemplate{title='N/A',args={'TBA'}} )
infoCell
:attr('colspan', (splitSeason and entry.episodesA ~= 'hide') and 1 or 2)
:attr('rowspan', splitSeason and splits or nil)
seasonRow:node(infoCell)
end
end
if splitSeason and entry.episodesA ~= 'hide' then
if entry['episodes' .. k] then
local thisCell = SeriesOverview.season_cell(entry['episodes' .. k], frame)
:attr('colspan', (entry.episodes ~= 'hide') and 1 or 2)
seasonRow:node(thisCell)
else
local infoCell = SeriesOverview.series_attributes( frame:expandTemplate{title='N/A',args={'TBA'}} )
:attr('colspan', (entry.episodes ~= 'hide') and 1 or 2)
seasonRow:node(infoCell)
end
end
end
end
end
end
Baris 545: Baris 430:
-- Network
-- Network
if entry['network' .. k] and setNetwork then
if entry['network' .. k] then
local thisCell = SeriesOverview.season_cell(entry['network' .. k], frame)
local thisCell = SeriesOverview.season_cell(entry['network' .. k], frame)
:attr('rowspan', SeriesOverview.cellspan(SeasonEntries, SeasonEntries_ordered, 'network', X, (args.series and true or false), entry['network' .. k .. 'span'] or nil))
:attr('rowspan', SeriesOverview.cellspan(SeasonEntries, SeasonEntries_ordered, 'network', X, (args.series and true or false)))
seasonRow:node(thisCell)
seasonRow:node(thisCell)
end
end
Baris 558: Baris 443:
local infoTransclude = args[param .. '_transclude']
local infoTransclude = args[param .. '_transclude']
if (infoTransclude == 'onlyinclude' and title.fullText == initialArticle) or (infoTransclude == 'noinclude' and title.fullText ~= initialArticle) then else
if (infoTransclude == 'onlyinclude' and title.fullText == initialArticle) or (infoTransclude == 'noinclude' and title.fullText ~= initialArticle) then else
local infoParam = entry[param]
local infoParam = entry[param]
if infoParam and splitSeason and k == '' and not entry[param .. 'A'] then
if infoParam and splitSeason and k == '' and not entry[param .. 'A'] then
entry[param .. 'A'] = entry[param]
entry[param .. 'A'] = entry[param]
entry[param .. 'spanning'] = 'y'
entry[param .. 'span'] = 'y'
end
end
local rowspan = (entry[param0 .. 'spanning'] and splits) or
local rowspan = (entry[param0 .. 'span'] and splits) or
(args.series and SeriesOverview.cellspan(SeasonEntries, SeasonEntries_ordered, param0, X, (args.series and true or false), entry[param0 .. 'span'] or nil))
(args.series and SeriesOverview.cellspan(SeasonEntries, SeasonEntries_ordered, param0, X, (args.series and true or false)))
or nil
or nil
if k == 'A' or (k ~= 'A' and not entry[param0 .. 'spanning']) then
if k == 'A' or (k ~= 'A' and not entry[param0 .. 'span']) then
-- Cells with {{N/A|...}} already expanded
-- Cells with {{N/A|...}} already expanded
if infoParam then
if infoParam then
Baris 589: Baris 474:
end
end
end
end
elseif not entry[param0 .. 'spanning'] then
elseif not entry[param0 .. 'span'] then
if not args.series then
if not args.series then
local infoCell = SeriesOverview.series_attributes( frame:expandTemplate{title='N/A',args={'TBA'}} )
local infoCell = SeriesOverview.series_attributes( frame:expandTemplate{title='N/A',args={'TBA'}} )
Baris 603: Baris 488:
end -- End 'if' multiseries
end -- End 'if' multiseries
end -- End 'do' season rows
end -- End 'do' season rows
return (args.dontclose and mw.ustring.gsub(tostring(root), "</table>", "") or tostring(root)) .. categories
local rootdiv
if args.multiseries or not args.series then
rootdiv = mw.html.create('div')
rootdiv
:css('display', 'block')
:css('overflow-x', 'auto')
rootdiv:node(root)
rootdiv = tostring(rootdiv)
else
rootdiv = tostring(root)
end
if args.dontclose then
rootdiv = mw.ustring.gsub(rootdiv, "</div>", "")
rootdiv = mw.ustring.gsub(rootdiv, "</table>", "")
end

return rootdiv .. categories
end
end


Baris 635: Baris 502:
})
})
return SeriesOverview.new(frame, args)
return SeriesOverview.new(frame, args)
end

function p._end(frame)
return SeriesOverview.endtable()
end
end



Revisi per 10 Januari 2024 04.17

-- This module implements {{Ikhtisar serial}}.

require('Module:No globals')
local yesno = require('Module:Yesno')
local HTMLcolor = mw.loadData( 'Module:Color contrast/colors' )

--------------------------------------------------------------------------------
-- SeriesOverview class
-- The main class.
--------------------------------------------------------------------------------

local SeriesOverview = {}

function SeriesOverview.cellspan(SeasonEntries, SeasonEntries_ordered, key, cell, multipart)
	local spanlength = 1
	
	local firstEntry = SeasonEntries[SeasonEntries_ordered[cell]]
	if key == 'network' and firstEntry.networkA and not firstEntry.networkB then spanlength = 2 end
	
	for i = cell+1, #SeasonEntries_ordered do
		local entry = SeasonEntries[SeasonEntries_ordered[i]]
		-- Split season, then regular season
		if entry.startA then
			if not entry[key..'A'] then spanlength = spanlength + 1
			else break end
			if not entry[key..'B'] then spanlength = spanlength + 1
			else break end
		else
			if not entry[key] and (key == 'network' or (string.sub(key,0,3) == 'aux' and (not entry.special or entry.episodes)) or (string.sub(key,0,4) == 'info') and multipart) then
				spanlength = spanlength + 1
			else break end
		end
	end
	return spanlength
end

-- Sorting function
function SeriesOverview.series_sort(op1, op2)
	local n1,s1 = string.match(op1,"(%d+)(%a*)")
	local n2,s2 = string.match(op2,"(%d+)(%a*)")
	local n1N,n2N = tonumber(n1),tonumber(n2)

	if n1N == n2N then
		return s1 < s2
	else
		return n1N < n2N
	end
end

-- Function to add either text or {{N/a}} to cell
function SeriesOverview.season_cell(text, frame)
	local cell
	
	if string.find(text or '', 'table-na', 0, true) ~= nil then
		local findpipe = string.find(text, ' | ', 0, true)
		if findpipe ~= nil then
			cell = SeriesOverview.series_attributes( frame:expandTemplate{title='N/A',args={string.sub(text,findpipe+3)}} )
		else
			cell = SeriesOverview.series_attributes( frame:expandTemplate{title='N/A'} )
		end
	else
		cell = mw.html.create('td'):wikitext(text)
	end
	
	return cell
end

-- Allow usages of {{N/A}} cells
function SeriesOverview.series_attributes(infoParam)
	local entries = {}
	local infoCell = mw.html.create('td')
	local attrMatch = '([%a-]*)="([^"]*)"'
	
	while true do
		local a,b = string.match(infoParam,attrMatch)
		if a == nil or b == nil then break end
		infoCell:attr(a,b)
		infoParam = string.gsub(infoParam,attrMatch,'',1)
	end

	infoParam = string.gsub(infoParam,'%s*|%s*','',1)
	infoCell:wikitext(infoParam)
	
	return infoCell
end

function SeriesOverview.new(frame, args)
	args = args or {}
	local initialArticle = args['1'] or ''
	local categories = ''
	local title = mw.title.getCurrentTitle()
	local allReleased = yesno(args.allreleased)

	-- Create series overview table
	local root = mw.html.create((args.multiseries or not args.series) and 'table' or '')
	local cellPadding = '0 8px'
	local basePadding = '0.2em 0.4em'

	root
		:addClass('wikitable')
		:addClass('plainrowheaders')
		:css('text-align', 'center')

	-- Sortable
	if args.sortable then
		root:addClass('sortable');
	end
	
	-- Width
	if args.width then
		root:css('width', args.width)
	end

	-- Summary
	if args.summary then
		root:attr('summary'):wikitext(args.summary)
	end
	
	-- Extract seasons info and place into a 3D array
	local SeasonEntries = {}
	for k,v in pairs(args) do
		local str, num, str2 = string.match(k, '([^%d]*)(%d*)(%a*)')
		if num ~= '' then 
			-- Special
			local special = false
			if string.sub(str2,1,1) == 'S' then
				special = true
				num = num .. str2
				str2 = ''
			end
			-- Add to entries, create if necessary
			if not SeasonEntries[num] then
				SeasonEntries[num] = {}
			end
			SeasonEntries[num][str .. str2] = v
			if special then
				SeasonEntries[num]['special'] = 'y'
			end
		end
	end

	-- Order table by season number
	local SeasonEntries_ordered = {}
	for k in pairs(SeasonEntries) do
		table.insert(SeasonEntries_ordered, k)
	end
	table.sort(SeasonEntries_ordered,SeriesOverview.series_sort)
	
	local firstRow = args.multiseries and {} or SeasonEntries[SeasonEntries_ordered[1]]
	
	-- Colspan calculation for information cells (0 = no info set)
	local numAuxCells = 0
	local numInfoCells = 0
	for i = string.byte('A'), string.byte('Z') do
		local param = 'info' .. string.char(i)
		if args[param] then numInfoCells = numInfoCells + 1 end
	end
	
	-- Top info cell
	-- @ = string.char(64), A = string.char(65)
	local topInfoCell = numInfoCells > 0 and string.char(numInfoCells + (string.byte('A') - 1)) or '@'

	-- Networks are included if the very first entry sets the first network
	local setNetwork = (args.multiseries and args.network) or firstRow.network or firstRow.networkA
	local networkTransclude = args.network_transclude
	if (networkTransclude == 'onlyinclude' and title.fullText == initialArticle) or (networkTransclude == 'noinclude' and title.fullText ~= initialArticle) then
		setNetwork = false
	end

	-- Headers
	do
		if args.multiseries or not args.series then
			local headerRow = root:tag('tr')
			headerRow
				:css('text-align', 'center')
	
			local releasedBlurb = args.released and 'rilis' or 'tayang'
			
			-- Base series/season content on the format of the first date; Series = D M Y, Season = M D, Y
			local matchDMY = false
			local thisStart = firstRow.start or firstRow.startA
			if thisStart then
				if string.match(thisStart:gsub("&nbsp;"," "), '(%d+)%s(%a+)%s(%d+)') then
					matchDMY = true
				end
			end
			
			-- Multiple series header
			if args.multiseries then
				headerRow:tag('th')
					:attr('scope', 'col')
					:css('padding', cellPadding)
					:attr('rowspan', allReleased and 1 or 2)
					:wikitext('Seri')
			end
		
			-- Season header
			headerRow:tag('th')
				:attr('scope', 'col')
				:attr('rowspan', allReleased and 1 or 2)
				:attr('colspan', 2)
				:css('padding', cellPadding)
				:wikitext(args.seriesT or args.seasonT or (matchDMY and 'Musim') or 'Musim')
			
			-- Aux headers
			for i = string.byte('A'), string.byte('Z') do
				local param = 'aux' .. string.char(i)
				if args[param] then
					numAuxCells = numAuxCells + 1
					headerRow:tag('th')
						:attr('scope', 'col')
						:css('padding', cellPadding)
						:attr('rowspan', allReleased and 1 or 2)
						:wikitext(args[param])
				end
			end

			-- Episodes header
			headerRow:tag('th')
				:attr('scope', 'col')
				:attr('rowspan', allReleased and 1 or 2)
				:attr('colspan', 2)
				:css('padding', cellPadding)
				:wikitext('Episode')

			-- Originally aired header
			local OriginallyColspan = (not allReleased and setNetwork) and 3 or 2
			headerRow:tag('th')
				:attr('scope', 'col')
				:attr('colspan', OriginallyColspan)
				:wikitext('Waktu ' .. releasedBlurb)
		
			-- Network subheader for released series
			if setNetwork and allReleased then
				headerRow:tag('th')
					:attr('scope', 'col')
					:attr('rowspan', allReleased and 1 or 2)
					:css('padding', cellPadding)
					:wikitext('Jaringan')
			end
		
			-- Subheader row
			local subheaderRow = mw.html.create('tr')

			-- Info header
			if topInfoCell ~= '@' then
				for i = string.byte('A'), string.byte(topInfoCell) do
					local param = 'info' .. string.char(i)
					local infoTransclude = args[param .. '_transclude']
					if (infoTransclude == 'onlyinclude' and title.fullText == initialArticle) or (infoTransclude == 'noinclude' and title.fullText ~= initialArticle) then else
						headerRow:tag('th')
							:attr('scope', 'col')
							:attr('rowspan', allReleased and 1 or 2)
							:css('padding', cellPadding)
							:wikitext(args[param])
					end
				end
			end

			if not allReleased then
				-- First aired subheader
				subheaderRow:tag('th')
					:attr('scope', 'col')
					:wikitext('Awal ' .. releasedBlurb)
	
				-- Last aired subheader
				subheaderRow:tag('th')
					:attr('scope', 'col')
					:wikitext('Akhir ' .. releasedBlurb)
			
				-- Network subheader for aired series
				if setNetwork then
					subheaderRow:tag('th')
						:attr('scope', 'col')
						:css('padding', cellPadding)
						:wikitext('Jaringan')
				end
			end
	
			-- Check for scenarios with an empty subheaderRow
			if not allReleased or numInfoCells > 0 then
				root:node(subheaderRow)
			end
		end	
	end

	-- Season rows
	do
		if args.multiseries then
			-- Multi series individual entries
			if args.multiseries ~= "y" then
				root:node(args.multiseries)
			end
		else
			-- One row entries, only categorized in the mainspace
			if title.namespace == 0 and #SeasonEntries == 1 then
				categories = categories .. '[[Category:Articles using Template:Series overview with only one row]]'
			end
			
			-- Determine number of rows in the whole overview
			local SeasonEntriesRows = 0
			for X = 1, #SeasonEntries_ordered do
				local season, entry = SeasonEntries_ordered[X], SeasonEntries[SeasonEntries_ordered[X]]
				local splits = 0
				for i = string.byte('A'), string.byte('Z') do
					local param = 'start' .. string.char(i)
					if entry[param] then splits = splits + 1 end
				end
				if splits == 0 then splits = 1 end
				SeasonEntriesRows = SeasonEntriesRows + splits
			end
		
			for X = 1, #SeasonEntries_ordered do
				local season, entry = SeasonEntries_ordered[X], SeasonEntries[SeasonEntries_ordered[X]]
				
				-- Determine number of splits in a season
				local splits = 0
				for i = string.byte('A'), string.byte('Z') do
					local param = 'start' .. string.char(i)
					if entry[param] then splits = splits + 1 end
				end
				local splitSeason = (splits > 1)
				
				-- Season rows for each season
				for k0 = string.byte('A')-1, string.byte('Z') do
					local k = string.char(k0)
					if k0 == string.byte('A')-1 then k = '' end
					
					-- New season row
					local seasonRow = entry['start' .. k] and root:tag('tr') or mw.html.create('tr')
				
					-- Series name for group overviews
					if X == 1 and (k == '' or k == 'A') and args.series then
						seasonRow:tag('th')
							:attr('scope', 'row')
							:attr('rowspan', SeasonEntriesRows)
							:wikitext(args.series)
					end
					
					-- Coloured cell
					if entry['color' .. k] ~= nil and HTMLcolor[entry['color' .. k]] == nil then 
						entry['color' .. k] = '#'..(mw.ustring.match(entry['color' .. k], '^[%s#]*([a-fA-F0-9]*)[%s]*$') or '')
					end
					if splitSeason and entry.color then
						if k == 'A' then
							seasonRow:tag('td')
								:attr('rowspan', entry.color and splits or 1)
								:css('background', entry.color)
								:css('width','10px')
						end
					else
						seasonRow:tag('td')
							:css('background',entry['color' .. k])
							:css('width','10px')
					end
					
					-- Season number link, included only in the first row
					if k == '' or k == 'A' then
						seasonRow:tag('th')
							:attr('scope', 'row')
							:attr('rowspan', splitSeason and splits or nil)
							:attr('colspan', entry.special and not entry.episodes and 3+numAuxCells or 1)
							:css('text-align', 'center')
							:wikitext((entry.link and '[[' .. entry.link .. '|' .. (entry.linkT or season) .. ']]' or (entry.linkT or season)) .. (entry.linkR or ''))
					end
					
					-- Aux cells
					for i = string.byte('A'), string.byte('Z') do
						local param = 'aux' .. string.char(i)
						if entry[param .. k] then
							local thisCell = SeriesOverview.season_cell(entry[param .. k], frame)
								:attr('scope', 'col')
								:attr('rowspan', SeriesOverview.cellspan(SeasonEntries, SeasonEntries_ordered, param, X, (args.series and true or false)))
								:css('padding', cellPadding)
							seasonRow:node(thisCell)
						end
					end
					
					-- Episodes counts
					if ((splitSeason and k == 'A' and entry.episodes ~= 'hide') or not splitSeason) then
						if entry.episodes then
							local thisCell = SeriesOverview.season_cell(entry.episodes, frame)
								:attr('colspan', splitSeason and 1 or 2)
								:attr('rowspan', splitSeason and splits or nil)
							seasonRow:node(thisCell)
						elseif not entry.special then
							local infoCell = SeriesOverview.series_attributes( frame:expandTemplate{title='N/A',args={'TBA'}} )
							infoCell
								:attr('colspan', splitSeason and 1 or 2)
								:attr('rowspan', splitSeason and splits or nil)
							seasonRow:node(infoCell)
						end
					end
					if splitSeason then
						if entry['episodes' .. k] then
							local thisCell = SeriesOverview.season_cell(entry['episodes' .. k], frame)
								:attr('colspan', (entry.episodes ~= 'hide') and 1 or 2)
							seasonRow:node(thisCell)
						else
							local infoCell = SeriesOverview.series_attributes( frame:expandTemplate{title='N/A',args={'TBA'}} )
								:attr('colspan', (entry.episodes ~= 'hide') and 1 or 2)
							seasonRow:node(infoCell)
						end
					end
				
					-- Start date
					if entry['start' .. k] then
						local thisCell = SeriesOverview.season_cell(entry['start' .. k], frame)
							:attr('colspan',((not entry.special and entry['end' .. k] == 'start') or (entry.special and not entry['end' .. k]) or allReleased) and 2 or 1)
							:css('padding',basePadding)
						seasonRow:node(thisCell)
					else
						local infoCell = SeriesOverview.series_attributes( frame:expandTemplate{title='N/A',args={'TBA'}} )
						infoCell:css('padding',basePadding)
						seasonRow:node(infoCell)
					end
					
					-- End date
					if not allReleased and entry['end' .. k] ~= 'start' and ((entry.special and entry['end' .. k]) or not entry.special) then
						if entry['end' .. k] then
							local thisCell = SeriesOverview.season_cell(entry['end' .. k], frame)
								:css('padding',cellPadding)
							seasonRow:node(thisCell)
						else
							local infoCell = SeriesOverview.series_attributes( frame:expandTemplate{title='N/A',args={'TBA'}} )
							infoCell:css('padding',cellPadding)
							seasonRow:node(infoCell)
						end
					end
					
					-- Network
					if entry['network' .. k] then
						local thisCell = SeriesOverview.season_cell(entry['network' .. k], frame)
							:attr('rowspan', SeriesOverview.cellspan(SeasonEntries, SeasonEntries_ordered, 'network', X, (args.series and true or false)))
						seasonRow:node(thisCell)
					end
					
					-- Information
					for i = string.byte('A'), string.byte(topInfoCell) do
						local param0 = 'info' .. string.char(i)
						local param = 'info' .. string.char(i) .. k
						
						local infoTransclude = args[param .. '_transclude']
						if (infoTransclude == 'onlyinclude' and title.fullText == initialArticle) or (infoTransclude == 'noinclude' and title.fullText ~= initialArticle) then else
						
							local infoParam = entry[param]
							if infoParam and splitSeason and k == '' and not entry[param .. 'A'] then
								entry[param .. 'A'] = entry[param]
								entry[param .. 'span'] = 'y'
							end
							
							local rowspan = (entry[param0 .. 'span'] and splits) or
											(args.series and SeriesOverview.cellspan(SeasonEntries, SeasonEntries_ordered, param0, X, (args.series and true or false)))
											or nil
							
							if k == 'A' or (k ~= 'A' and not entry[param0 .. 'span']) then
								-- Cells with {{N/A|...}} already expanded
								if infoParam then
									if string.sub(infoParam,1,5) == 'style' then
										local infoCell = SeriesOverview.series_attributes(infoParam)
										infoCell:attr('rowspan', rowspan)
										seasonRow:node(infoCell)
									else
										-- Unstyled content info cell
										local thisCell = SeriesOverview.season_cell(infoParam, frame)
											:attr('rowspan', rowspan)
										seasonRow:node(thisCell)
									end
								else
									if not args.series then
										local infoCell = SeriesOverview.series_attributes( frame:expandTemplate{title='N/A',args={'TBA'}} )
										infoCell:attr('rowspan', rowspan)
										seasonRow:node(infoCell)
									end
								end
							elseif not entry[param0 .. 'span'] then
								if not args.series then
									local infoCell = SeriesOverview.series_attributes( frame:expandTemplate{title='N/A',args={'TBA'}} )
									infoCell:attr('rowspan', rowspan)
									seasonRow:node(infoCell)
								end
							end
						end
					end
				
				end -- End k0 string.byte
			end -- End 'for' SeasonEntries_ordered
		end -- End 'if' multiseries
	end -- End 'do' season rows
	return (args.dontclose and mw.ustring.gsub(tostring(root), "</table>", "") or tostring(root)) .. categories
end

--------------------------------------------------------------------------------
-- Exports
--------------------------------------------------------------------------------

local p = {}

function p.main(frame)
	local args = require('Modul:Arguments').getArgs(frame, {
		wrappers = 'Templat:Ikhtisar serial'
	})
	return SeriesOverview.new(frame, args)
end

return p