Module:Episode list: Difference between revisions

Created page with "local p = {} -- This module requires the use of the following modules: local colorContrastModule = require('Module:Color contrast') local htmlColor = mw.loadData('Module:Color contrast/colors') local delinkModule = require('Module:Delink') local langModule = require("Module:Lang") local mathModule = require('Module:Math') local tableEmptyCellModule = require('Module:Table empty cell') local yesNoModule = require('Module:Yesno') -- mw.html object for the generated row...."
 
No edit summary
 
Line 4: Line 4:
local colorContrastModule = require('Module:Color contrast')
local colorContrastModule = require('Module:Color contrast')
local htmlColor = mw.loadData('Module:Color contrast/colors')
local htmlColor = mw.loadData('Module:Color contrast/colors')
local delinkModule = require('Module:Delink')
local langModule = require("Module:Lang")
local langModule = require("Module:Lang")
local mathModule = require('Module:Math')
local mathModule = require('Module:Math')
Line 33: Line 32:
["tba_values"] = "[[Category:Episode lists with TBA values]]",
["tba_values"] = "[[Category:Episode lists with TBA values]]",
["nonmatching_numbered_parameters"] = "[[Category:Episode lists with a non-matching set of numbered parameters]]",
["nonmatching_numbered_parameters"] = "[[Category:Episode lists with a non-matching set of numbered parameters]]",
["raw_unformatted_storyteleplay"] = "[[Category:Episode lists with unformatted story or teleplay credits]]"
["raw_unformatted_storyteleplay"] = "[[Category:Episode lists with unformatted story or teleplay credits]]",
}
}


Line 128: Line 127:
shortSummaryText = shortSummaryText .. '\n<span></span>'
shortSummaryText = shortSummaryText .. '\n<span></span>'
end
end
local shortSummaryDiv = mw.html.create('div')
:addClass('shortSummaryText')
:css('max-width', '90vw')
:css('position', 'sticky')
:css('left', '0.2em')
:newline()
:wikitext(shortSummaryText)


local shortSummaryCell = mw.html.create('td')
local shortSummaryCell = mw.html.create('td')
Line 134: Line 141:
:attr('colspan', nonNilParams)
:attr('colspan', nonNilParams)
:newline()
:newline()
:wikitext(shortSummaryText)
:node(shortSummaryDiv)


return mw.html.create('tr')
return mw.html.create('tr')
Line 140: Line 147:
:node(shortSummaryCell)
:node(shortSummaryCell)
end
end


-- Local function which is used to add tracking categories for Top Color issues.
-- Local function which is used to add tracking categories for Top Color issues.
Line 173: Line 181:
addTrackingCategory(trackingCategoryList["default_line_colors"])
addTrackingCategory(trackingCategoryList["default_line_colors"])
end
end
end
-- Local function which is used to remove wiki-links from repated information in rowspans.
-- Used for Doctor Who serials, where the director and writer are the same for each part of serial.
local function removeWikilinks(args, v)
return delinkModule._delink{args[v]}
end
end


Line 186: Line 188:
local function setTBDStatus(args, awaitingText, expiredText, weeks)
local function setTBDStatus(args, awaitingText, expiredText, weeks)
if args.OriginalAirDate == nil or args.OriginalAirDate == '' then
if args.OriginalAirDate == nil or args.OriginalAirDate == '' then
return tableEmptyCellModule._main({alt_text = awaitingText, title_text = awaitingText})
return tableEmptyCellModule._main({alt_text = awaitingText})
end
end
 
-- If it hasn't aired, change to "N/A".
if  string.match(args.OriginalAirDate, '^Unaired') then
return tableEmptyCellModule._main({alt_text = "N/A"})
end
 
local month, day, year = args.OriginalAirDate:gsub("&nbsp;", " "):match("(%a+) (%d+), (%d+)")
local month, day, year = args.OriginalAirDate:gsub("&nbsp;", " "):match("(%a+) (%d+), (%d+)")


Line 221: Line 228:


if (seconds >= 60 * 60 * 24 * 7 * weeks) then
if (seconds >= 60 * 60 * 24 * 7 * weeks) then
return tableEmptyCellModule._main({alt_text = expiredText, title_text = expiredText})
return tableEmptyCellModule._main({alt_text = expiredText})
else
else
return tableEmptyCellModule._main({alt_text = awaitingText, title_text = awaitingText})
return tableEmptyCellModule._main({alt_text = awaitingText})
end
end
end
end
Line 243: Line 250:
-- Air dates that don't use {{Start date}}
-- Air dates that don't use {{Start date}}
local function checkUsageOfDateTemplates(args, v, onInitialPage, title)
local function checkUsageOfDateTemplates(args, v, onInitialPage, title)
if (v == 'OriginalAirDate'
if v == 'OriginalAirDate'
and args[v] ~= ''
and args[v] ~= ''
and string.match(args[v], '%d%d%d%d') ~= nil
and string.match(args[v], '%d%d%d%d') -- Ensure it contains a four-digit number (likely a year)
and string.match(args[v], '2C2C2C') == nil
and string.match(args[v], '2C2C2C') == nil -- Avoids this specific pattern
and string.find(args[v], 'dtstart') == nil
and not string.match(args[v], '^Unaired') -- Exclude anything starting with "Unaired"
and string.find(args[v], 'itvstart') == nil -- Avoids a {{Start date}} unique class
and onInitialPage
and onInitialPage
and title.namespace == 0)
and title.namespace == 0  
then
then
addTrackingCategory(trackingCategoryList["air_dates"])
addTrackingCategory(trackingCategoryList["air_dates"])
Line 290: Line 298:
use the non-numbered parameter names (Title, Aux).
use the non-numbered parameter names (Title, Aux).


The function returns the args as non-numbered prameter names.
The function returns the args as non-numbered parameter names.
]]--
]]--
local function extractDataFromNumberedSerialArgs(args, i, numberOfParameterGroups, title)
local function extractDataFromNumberedSerialArgs(args, i, numberOfParameterGroups, title)
Line 322: Line 330:
Line 1: <Title><RTitle> (with no space between)
Line 1: <Title><RTitle> (with no space between)
Line 2: <AltTitle><RAltTitle> (with no space between) OR
Line 2: <AltTitle><RAltTitle> (with no space between) OR
Line 2: Transcription: <TranslitTitle> (<Language>: <NativeTitle>)<RAltTitle> (with space between first two parameters)
Line 2: Transliteration: <TranslitTitle> (<Language>: <NativeTitle>)<RAltTitle> (with space between first two parameters)


If <Title> or <RTitle> are empty,
If <Title> or <RTitle> are empty,
Line 369: Line 377:
elseif (hasValue(args.TranslitTitle)) then
elseif (hasValue(args.TranslitTitle)) then
if (hasValue(args.NativeTitleLangCode)) then
if (hasValue(args.NativeTitleLangCode)) then
titleString = titleString .. 'Transcription: "' .. langModule._transl({args.NativeTitleLangCode, args.TranslitTitle, italic = 'no'})  .. '"'
titleString = titleString .. 'Transliteration: "' .. langModule._xlit({args.NativeTitleLangCode, args.TranslitTitle, italic = 'no'})  .. '"'
else
else
titleString = titleString .. 'Transcription: "' .. args.TranslitTitle .. '"'
titleString = titleString .. 'Transliteration: "' .. args.TranslitTitle .. '"'
end
end
end
end
Line 388: Line 396:
if (hasValue(args.NativeTitleLangCode)) then
if (hasValue(args.NativeTitleLangCode)) then
local languageCode = "Lang-" .. args.NativeTitleLangCode
local languageCode = "Lang-" .. args.NativeTitleLangCode
titleString = titleString .. " (" .. langModule._lang_xx_inherit({code = args.NativeTitleLangCode, args.NativeTitle}) .. ")"
titleString = titleString .. " (" .. langModule._langx({code = args.NativeTitleLangCode, text=args.NativeTitle}) .. ")"
else
else
titleString = titleString .. " (" .. args.NativeTitle .. ")"
titleString = titleString .. " (" .. args.NativeTitle .. ")"
Line 415: Line 423:
Local function which is used to extract data
Local function which is used to extract data
from the numbered title parameters (Title1, RTitle2, etc.), and then convert them to
from the numbered title parameters (Title1, RTitle2, etc.), and then convert them to
use the non-numbered prameter names (Title, RTitle).
use the non-numbered parameter names (Title, RTitle).


The function returns two results:
The function returns two results:
Line 517: Line 525:
createTitleCell(args, numberOfParameterGroups, currentRow, isSerial)
createTitleCell(args, numberOfParameterGroups, currentRow, isSerial)
end
end
elseif excludeList[v] and args[excludeList[v]] then
-- Ignore this parameter set as multiple conflicting parameters were used
elseif (args[v] and (v ~= 'EpisodeNumber' and v ~= 'EpisodeNumber2')) then
elseif (args[v] and (v ~= 'EpisodeNumber' and v ~= 'EpisodeNumber2')) then
-- Set empty cells to TBA/TBD
-- Set empty cells to TBA/TBD
Line 547: Line 557:
checkUsageOfDateTemplates(args, v, onInitialPage, title)
checkUsageOfDateTemplates(args, v, onInitialPage, title)
end
end
 
if (args[v] == "TBA") then
-- Usages of TBA via [[Template:TableTBA]] can be found with the "tv-tba" class.
if args[v] and (args[v] == "TBA" or string.find(args[v], "tv%-tba")) then
cellValueTBA = true
cellValueTBA = true
end
end
Line 672: Line 683:
createCells(args, true, i, onInitialPage, title, numberOfParameterGroups)
createCells(args, true, i, onInitialPage, title, numberOfParameterGroups)
if (i ~= numberOfParameterGroups) then
if (i ~= numberOfParameterGroups) then
local textColor = '#333'
if topColor == 'inherit' then
textColor = 'inherit'
end
row = row:done()  -- Use done() to close the 'tr' tag in rowspaned rows.
row = row:done()  -- Use done() to close the 'tr' tag in rowspaned rows.
:tag('tr')
:tag('tr')
:addClass('vevent')
:addClass('module-episode-list-row')
:css('text-align', 'center')
:css('background', topColor)
:css('background', topColor)
:css('color', textColor)
end
end
end
end
Line 708: Line 728:
return '#' .. args.TopColor
return '#' .. args.TopColor
end
end
elseif (rowColorEnabled and onInitialPage and mathModule._mod(episodeNumber, 2) == 0) then
return '#E9E9E9'
elseif (onInitialPage and args.ShortSummary) then
return '#F2F2F2'
else
else
return 'inherit'
return 'inherit'
Line 751: Line 767:
-- with one of them not requiring an article name, so for backward compatability, the whole sequence is kept.
-- with one of them not requiring an article name, so for backward compatability, the whole sequence is kept.
local onInitialPage
local onInitialPage
local onInitialPageCheck = (mw.uri.anchorEncode(pageTitle) == mw.uri.anchorEncode(initiallistTitle))


-- Only sublist had anything about hiding, so only it needs to even check
-- Only sublist had anything about hiding, so only it needs to even check
if (sublist) then
if (sublist) then
onInitialPage = mw.uri.anchorEncode(pageTitle) == mw.uri.anchorEncode(initiallistTitle)
onInitialPage = onInitialPageCheck
-- avoid processing ghost references
-- avoid processing ghost references
if (not onInitialPage) then
if (not onInitialPage) then
Line 763: Line 780:
onInitialPage = true
onInitialPage = true
else
else
onInitialPage = mw.uri.anchorEncode(pageTitle) == mw.uri.anchorEncode(initiallistTitle)
onInitialPage = onInitialPageCheck
end
end
end
end
Line 789: Line 806:


local root = mw.html.create() -- Create the root mw.html object to return
local root = mw.html.create() -- Create the root mw.html object to return
local textColor = '#333'
if topColor == 'inherit' then
textColor = 'inherit'
end
row = root:tag('tr') -- Create the table row and store it globally
row = root:tag('tr') -- Create the table row and store it globally
:addClass('vevent')
:addClass('vevent')
:addClass('module-episode-list-row')
:css('text-align', 'center')
:css('text-align', 'center')
:css('background', topColor)
:css('background', topColor)
:css('color', textColor)


local numberOfParameterGroups, multiTitleListEnabled = getnumberOfParameterGroups(args)
local numberOfParameterGroups, multiTitleListEnabled = getnumberOfParameterGroups(args)