Module:Series overview: Difference between revisions
NeonWabbit (talk | contribs) Created page with "-- This module implements {{Series overview}}. require('strict') 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, ke..." |
NeonWabbit (talk | contribs) No edit summary |
||
| Line 4: | Line 4: | ||
local yesno = require('Module:Yesno') | local yesno = require('Module:Yesno') | ||
local HTMLcolor = mw.loadData( 'Module:Color contrast/colors' ) | local HTMLcolor = mw.loadData( 'Module:Color contrast/colors' ) | ||
local tableEmptyCellModule = require('Module:Table empty cell') | |||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
| Line 23: | Line 24: | ||
local entry = SeasonEntries[SeasonEntries_ordered[i]] | local entry = SeasonEntries[SeasonEntries_ordered[i]] | ||
-- Split season, then regular season | -- Split season, then regular season | ||
if entry.startA then | if entry.startA or entry.releasedA then | ||
if not entry[key..'A'] then spanlength = spanlength + 1 | if not entry[key..'A'] then spanlength = spanlength + 1 | ||
else break end | else break end | ||
| Line 97: | Line 98: | ||
local categories = '' | local categories = '' | ||
local title = mw.title.getCurrentTitle() | local title = mw.title.getCurrentTitle() | ||
local | |||
local oldDateSupport = true | |||
-- Create series overview table | -- Create series overview table | ||
| Line 174: | Line 176: | ||
local noColors = true | local noColors = true | ||
local setNetwork = false | local setNetwork = false | ||
local allReleased = true | |||
local noEndDates = true | |||
if (args.multiseries and args.network) then setNetwork = true end | if (args.multiseries and args.network) then setNetwork = true end | ||
if (args.multiseries) then allReleased = false end | |||
for i = 1, #SeasonEntries_ordered do | for i = 1, #SeasonEntries_ordered do | ||
local season, entry = SeasonEntries_ordered[i], SeasonEntries[SeasonEntries_ordered[i]] | local season, entry = SeasonEntries_ordered[i], SeasonEntries[SeasonEntries_ordered[i]] | ||
| Line 182: | Line 189: | ||
if entry['color' .. j] then noColors = false end | if entry['color' .. j] then noColors = false end | ||
if entry['network' .. j] then setNetwork = true end | if entry['network' .. j] then setNetwork = true end | ||
if entry['start' .. j] then allReleased = false end | |||
if entry['end' .. j] then noEndDates = false end | |||
end | end | ||
end | |||
if title.namespace == 0 and not args.multiseries and not allReleased and noEndDates then | |||
categories = categories .. '[[Category:Articles using Template:Series overview with deprecated start-parameter format]]' | |||
end | end | ||
| Line 201: | Line 214: | ||
headerRow | headerRow | ||
:css('text-align', 'center') | :css('text-align', 'center') | ||
-- Base series/season content on the format of the first date; Series = D M Y, Season = M D, Y | -- Base series/season content on the format of the first date; Series = D M Y, Season = M D, Y | ||
local matchDMY = false | local matchDMY = false | ||
local thisStart = firstRow.start or firstRow.startA | local thisStart = firstRow.start or firstRow.startA or firstRow.released or firstRow.releasedA | ||
if thisStart then | if thisStart then | ||
if string.match(thisStart:gsub(" "," "), '(%d+)%s(%a+)%s(%d+)') then | if string.match(thisStart:gsub(" "," "), '(%d+)%s(%a+)%s(%d+)') then | ||
| Line 254: | Line 265: | ||
:attr('colspan', 2) | :attr('colspan', 2) | ||
:css('padding', cellPadding) | :css('padding', cellPadding) | ||
:wikitext('Episodes') | :wikitext(args.episodesT or 'Episodes') | ||
end | end | ||
end | end | ||
| Line 265: | Line 276: | ||
end | end | ||
headerRow:tag('th') | headerRow:tag('th') | ||
:attr('scope', 'col') | :attr('scope', (setNetwork and allReleased) and 'col' or 'colgroup') | ||
:attr('colspan', OriginallyColspan) | :attr('colspan', OriginallyColspan) | ||
:wikitext('Originally ' | :wikitext('Originally released' .. countryBlurb) | ||
-- Network subheader for released series | -- Network subheader for released series | ||
| Line 300: | Line 311: | ||
subheaderRow:tag('th') | subheaderRow:tag('th') | ||
:attr('scope', 'col') | :attr('scope', 'col') | ||
:wikitext('First ' | :wikitext('First released') | ||
-- Last aired subheader | -- Last aired subheader | ||
subheaderRow:tag('th') | subheaderRow:tag('th') | ||
:attr('scope', 'col') | :attr('scope', 'col') | ||
:wikitext('Last ' | :wikitext('Last released') | ||
-- Network subheader for aired series | -- Network subheader for aired series | ||
| Line 342: | Line 353: | ||
local splits = 0 | local splits = 0 | ||
for i = string.byte('A'), string.byte('Z') do | for i = string.byte('A'), string.byte('Z') do | ||
local | local paramS = 'start' .. string.char(i) | ||
if entry[ | local paramR = 'released' .. string.char(i) | ||
if entry[paramS] or entry[paramR] then splits = splits + 1 end | |||
end | end | ||
if splits == 0 then splits = 1 end | if splits == 0 then splits = 1 end | ||
| Line 355: | Line 367: | ||
local splits = 0 | local splits = 0 | ||
for i = string.byte('A'), string.byte('Z') do | for i = string.byte('A'), string.byte('Z') do | ||
local | local paramS = 'start' .. string.char(i) | ||
if entry[ | local paramR = 'released' .. string.char(i) | ||
if entry[paramS] or entry[paramR] then splits = splits + 1 end | |||
end | end | ||
local splitSeason = (splits > 1) | local splitSeason = (splits > 1) | ||
| Line 371: | Line 384: | ||
-- New season row | -- New season row | ||
local seasonRow = (entry['start' .. k] or entry['released' .. k]) and root:tag('tr') or mw.html.create('tr') | |||
seasonRow:css('height', '100%') | seasonRow:css('height', '100%') | ||
| Line 417: | Line 429: | ||
-- Overall table cell | -- Overall table cell | ||
local cellRow = mw.html.create(args.series and 'td' or 'th') | local cellRow = mw.html.create(args.series and 'td' or 'th') | ||
:attr('scope', 'row') | :attr('scope', splitSeason and 'rowgroup' or '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) | ||
| Line 437: | Line 449: | ||
:css('width', colorWidth) | :css('width', colorWidth) | ||
:css('background', cellColor) | :css('background', cellColor) | ||
:css('color', '#202122') | |||
:css('height', '100%') | :css('height', '100%') | ||
:css('float', 'left') | :css('float', 'left') | ||
| Line 498: | Line 511: | ||
seasonRow:node(thisCell) | seasonRow:node(thisCell) | ||
elseif not entry.special then | elseif not entry.special then | ||
local infoCell = SeriesOverview.series_attributes( | local infoCell = SeriesOverview.series_attributes( tableEmptyCellModule._main({}) ) | ||
infoCell | infoCell | ||
:attr('colspan', (splitSeason and entry.episodesA ~= 'hide') and 1 or 2) | :attr('colspan', (splitSeason and entry.episodesA ~= 'hide') and 1 or 2) | ||
| Line 511: | Line 524: | ||
seasonRow:node(thisCell) | seasonRow:node(thisCell) | ||
else | else | ||
local infoCell = SeriesOverview.series_attributes( | local infoCell = SeriesOverview.series_attributes( tableEmptyCellModule._main({}) ) | ||
:attr('colspan', (entry.episodes ~= 'hide') and 1 or 2) | :attr('colspan', (entry.episodes ~= 'hide') and 1 or 2) | ||
seasonRow:node(infoCell) | seasonRow:node(infoCell) | ||
| Line 518: | Line 531: | ||
end | end | ||
end | end | ||
-- Start date | -- Start date | ||
if entry['start' .. k] then | if entry['start' .. k] or entry['released' .. k] then | ||
local thisCell = SeriesOverview.season_cell(entry['start' .. k], frame) | local thisCell = oldDateSupport and ( | ||
SeriesOverview.season_cell(entry['start' .. k] or entry['released' .. k], frame) | |||
) or ( | |||
SeriesOverview.season_cell((not allReleased or entry['end' .. k]) and entry['start' .. k] or entry['released' .. k], frame) | |||
) | |||
thisCell:attr('colspan', oldDateSupport and ( | |||
((not entry.special and entry['released' .. k]) or (entry.special and not entry['end' .. k]) or allReleased) and 2 or 1 | |||
) or ( | |||
(entry['released' .. k] or allReleased) and 2 or 1 | |||
)) | |||
:css('padding',basePadding) | :css('padding',basePadding) | ||
seasonRow:node(thisCell) | seasonRow:node(thisCell) | ||
else | else | ||
local infoCell = SeriesOverview.series_attributes( | local infoCell = SeriesOverview.series_attributes( tableEmptyCellModule._main({}) ) | ||
infoCell:css('padding',basePadding) | infoCell:css('padding',basePadding) | ||
seasonRow:node(infoCell) | seasonRow:node(infoCell) | ||
| Line 532: | Line 553: | ||
-- End date | -- End date | ||
local canIncludeEnd = oldDateSupport and ( | |||
(not allReleased and not entry['released' .. k] and ((entry.special and entry['end' .. k]) or not entry.special)) and 'yes' or 'no' | |||
) or ( | |||
(not allReleased and not entry['released' .. k] and ((entry.special and entry['end' .. k]) or not entry.special)) and 'yes' or 'no' | |||
) | |||
if canIncludeEnd == 'yes' then | |||
if entry['end' .. k] then | if entry['end' .. k] then | ||
local thisCell = SeriesOverview.season_cell(entry['end' .. k], frame) | local thisCell = SeriesOverview.season_cell(entry['end' .. k], frame) | ||
| Line 538: | Line 564: | ||
seasonRow:node(thisCell) | seasonRow:node(thisCell) | ||
else | else | ||
local infoCell = SeriesOverview.series_attributes( | local infoCell = SeriesOverview.series_attributes( tableEmptyCellModule._main({}) ) | ||
infoCell:css('padding',cellPadding) | infoCell:css('padding',cellPadding) | ||
seasonRow:node(infoCell) | seasonRow:node(infoCell) | ||
| Line 584: | Line 610: | ||
else | else | ||
if not args.series then | if not args.series then | ||
local infoCell = SeriesOverview.series_attributes( | local infoCell = SeriesOverview.series_attributes( tableEmptyCellModule._main({}) ) | ||
infoCell:attr('rowspan', rowspan) | infoCell:attr('rowspan', rowspan) | ||
seasonRow:node(infoCell) | seasonRow:node(infoCell) | ||
| Line 591: | Line 617: | ||
elseif not entry[param0 .. 'spanning'] then | elseif not entry[param0 .. 'spanning'] then | ||
if not args.series then | if not args.series then | ||
local infoCell = SeriesOverview.series_attributes( | local infoCell = SeriesOverview.series_attributes( tableEmptyCellModule._main({}) ) | ||
infoCell:attr('rowspan', rowspan) | infoCell:attr('rowspan', rowspan) | ||
seasonRow:node(infoCell) | seasonRow:node(infoCell) | ||