Module:Episode list
- Afrikaans
- العربية
- Basa Bali
- বাংলা
- भोजपुरी
- Bosanski
- Català
- Cymraeg
- Dansk
- Eesti
- Ελληνικά
- Español
- Esperanto
- فارسی
- Føroyskt
- Galego
- 한국어
- Hausa
- Հայերեն
- Bahasa Indonesia
- Jawa
- ಕನ್ನಡ
- Kurdî
- Latviešu
- Magyar
- മലയാളം
- मराठी
- مصرى
- Bahasa Melayu
- မြန်မာဘာသာ
- नेपाली
- 日本語
- Norsk bokmål
- Oʻzbekcha / ўзбекча
- ਪੰਜਾਬੀ
- Português
- Qaraqalpaqsha
- Русский
- Scots
- Shqip
- Simple English
- Slovenščina
- کوردی
- Српски / srpski
- Suomi
- Svenska
- Tagalog
- တႆး
- ไทย
- Türkçe
- Українська
- اردو
- Tiếng Việt
- 粵語
- 中文
Appearance
From Wikipedia, the free encyclopedia
Warning This Lua module is used on approximately 29,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them.
This module is rated as ready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned on help pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed through sandbox testing rather than repeated trial-and-error editing.
Page template-protected This module is currently protected from editing.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
This module depends on the following other modules:
Module:Episode list creates a table row, for use in a list of episodes tables, primarily for television. This module can be used in conjunction with Module:Episode table which creates a consistent and Manual of Style ready table, or with a manually created table. See Template:Episode list for further explanation and documentation.
Usage
Create a standard Episode list with:
{{#invoke:Episode list|list}}
Create a sublist which removes episode summaries on the transcluded page with:
{{#invoke:Episode list|sublist}}
Tracking categories
- Category:Episode list using the default LineColor (5,752)
- Category:Episode lists with a non-matching set of numbered parameters (109)
- Category:Episode lists with faulty line colors (5)
- Category:Episode lists with incorrectly formatted alternative air dates (1)
- Category:Episode lists with invalid top colors (1)
- Category:Episode lists with non-compliant line colors (13)
- Category:Episode lists with row deviations (36)
- Category:Episode lists with row dividers (0)
- Category:Episode lists with TBA values (474)
- Category:Episode lists with unformatted air dates (2)
- Category:Episode lists with unformatted story or teleplay credits (0)
The above documentation is transcluded from Module:Episode list/doc. (edit | history)
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Subpages of this module.
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Subpages of this module.
localp={} -- This module requires the use of the following modules: localcolorContrastModule=require('Module:Color contrast') localhtmlColor=mw.loadData('Module:Color contrast/colors') locallangModule=require("Module:Lang") localmathModule=require('Module:Math') localtableEmptyCellModule=require('Module:Table empty cell') localyesNoModule=require('Module:Yesno') -- mw.html object for the generated row. localrow -- Variable that will decide the colspan= of the Short Summary cell. localnonNilParams=0 -- Variable that will keep track if a TBA value was entered. localcellValueTBA=false -- Variable that handles the assigned tracking categories. localtrackingCategories="" -- List of tracking categories. localtrackingCategoryList={ ["air_dates"]="[[Category:Episode lists with unformatted air dates]]", ["alt_air_dates"]="[[Category:Episode lists with incorrectly formatted alternative air dates]]", ["faulty_line_colors"]="[[Category:Episode lists with faulty line colors]]", ["non_compliant_line_colors"]="[[Category:Episode lists with non-compliant line colors]]", ["default_line_colors"]="[[Category:Episode list using the default LineColor]]", ["row_deviations"]="[[Category:Episode lists with row deviations]]", ["invalid_top_colors"]="[[Category:Episode lists with invalid top colors]]", ["tba_values"]="[[Category:Episode lists with TBA values]]", ["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]]", } -- List of parameter names in this order. localcellNameList={ 'EpisodeNumber', 'EpisodeNumber2', 'Title', 'Aux1', 'DirectedBy', 'WrittenBy', 'Aux2', 'Aux3', 'OriginalAirDate', 'AltDate', 'Guests', 'MusicalGuests', 'ProdCode', 'Viewers', 'Aux4' } -- List of pairs which cannot be used together localexcludeList={ ['Guests']='Aux1', ['MusicalGuests']='Aux2' } -- List of cells that have parameter groups localparameterGroupCells={} localfirstParameterGroupCell localparameterGroupCellsAny=false -- List of title parameter names in this order. -- List used for multi title lists. localtitleList={ 'Title', 'RTitle', 'AltTitle', 'RAltTitle', 'NativeTitle', 'TranslitTitle', } -- Local function which is used to retrieve the episode number or production code number, -- without any additional text. localfunctionidTrim(val,search) localvalFind=string.find(val,search,1,true) if(valFind==nil)then returnval else returnstring.sub(val,0,valFind-1) end end -- Local function which is used to validate that a parameter has an actual value. localfunctionhasValue(param) if(param~=nilandparam~="")then returntrue else returnfalse end end -- Local function which is used to create a table data cell. localfunctioncreateTableData(text,rowSpan,textAlign) if(rowSpan~=nilandtonumber(rowSpan)>1)then row:tag('td') :attr('rowspan',rowSpan) :wikitext(text) else row:tag('td') :css('text-align',textAlign) :wikitext(text) end end -- Local function which is used to add a tracking category to the page. localfunctionaddTrackingCategory(category) trackingCategories=trackingCategories..category end -- Local function which is used to create a Short Summary row. localfunctioncreateShortSummaryRow(args,lineColor) -- fix for lists in the Short Summary localshortSummaryText=args.ShortSummary if(shortSummaryText:match('^[*:;#]')orshortSummaryText:match('^{|'))then shortSummaryText='<span></span>\n'..shortSummaryText end if(shortSummaryText:match('\n[*:;#]'))then shortSummaryText=shortSummaryText..'\n<span></span>' end localshortSummaryDiv=mw.html.create('div') :addClass('shortSummaryText') :css('max-width','90vw') :css('position','sticky') :css('left','0.2em') :newline() :wikitext(shortSummaryText) localshortSummaryCell=mw.html.create('td') :addClass('description') :css('border-bottom','solid 3px '..lineColor) :attr('colspan',nonNilParams) :newline() :node(shortSummaryDiv) returnmw.html.create('tr') :addClass('expand-child') :node(shortSummaryCell) end -- Local function which is used to add tracking categories for Top Color issues. localfunctionaddTopColorTrackingCategories(args) if(hasValue(args.TopColor))then addTrackingCategory(trackingCategoryList["row_deviations"]) -- Track top colors that have a color contrast rating below AAA with -- respect to text color, link color, or visited link color. See -- [[WP:COLOR]] for more about color contrast requirements. localtextContrastRatio=colorContrastModule._ratio{args.TopColor,'black',['error']=0} locallinkContrastRatio=colorContrastModule._ratio{args.TopColor,'#0B0080',['error']=0} localvisitedLinkContrastRatio=colorContrastModule._ratio{args.TopColor,'#0645AD',['error']=0} if(textContrastRatio<7orlinkContrastRatio<7orvisitedLinkContrastRatio<7)then addTrackingCategory(trackingCategoryList["invalid_top_colors"]) end end end -- Local function which is used to add tracking categories for Line Color issues. localfunctionaddLineColorTrackingCategories(args) if(hasValue(args.LineColor))then localblackContrastRatio=colorContrastModule._ratio{args.LineColor,'black',['error']=0} localwhiteContrastRatio=colorContrastModule._ratio{'white',args.LineColor,['error']=0} if(colorContrastModule._lum(args.LineColor)=='')then addTrackingCategory(trackingCategoryList["faulty_line_colors"]) elseif(blackContrastRatio<7andwhiteContrastRatio<7)then addTrackingCategory(trackingCategoryList["non_compliant_line_colors"]) end else addTrackingCategory(trackingCategoryList["default_line_colors"]) end end -- Local function which is used to set the text of an empty cell -- with either "TBD" or "N/A". -- Set to N/A if viewers haven't been available for four weeks, else set it as TBD. localfunctionsetTBDStatus(args,awaitingText,expiredText,weeks) ifargs.OriginalAirDate==nilorargs.OriginalAirDate==''then returntableEmptyCellModule._main({alt_text=awaitingText}) end -- If it hasn't aired, change to "N/A". ifstring.match(args.OriginalAirDate,'^Unaired')then returntableEmptyCellModule._main({alt_text="N/A"}) end localmonth,day,year=args.OriginalAirDate:gsub(" "," "):match("(%a+) (%d+), (%d+)") if(month==nil)then day,month,year=args.OriginalAirDate:gsub(" "," "):match("(%d+) (%a+) (%d+)") end if(day==nil)then returntableEmptyCellModule._main({alt_text="TBD"}) else -- List of months. localmonthList={ ['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12 } ifnotmonthList[month]then error('Invalid month '..month) end localseconds=os.time()-os.time({year=year,month=monthList[month],day=day,hour=0,min=0,sec=0}) if(seconds>=60*60*24*7*weeks)then returntableEmptyCellModule._main({alt_text=expiredText}) else returntableEmptyCellModule._main({alt_text=awaitingText}) end end end -- Local function which is used to create an empty cell. localfunctioncreateEmptyCell(args,v,unsetParameterGroup) if(unsetParameterGroup)then args[v]=tableEmptyCellModule._main({alt_text="N/A"}) elseif(v=='Viewers'andhasValue(args.OriginalAirDate))then args[v]=setTBDStatus(args,"TBD","N/A",4) elseif(v=='DirectedBy'orv=='WrittenBy')then args[v]=setTBDStatus(args,"TBA","Unknown",4) else args[v]=tableEmptyCellModule._main({}) end end -- Air dates that don't use {{Start date}} localfunctioncheckUsageOfDateTemplates(args,v,onInitialPage,title) ifv=='OriginalAirDate' andargs[v]~='' andstring.match(args[v],'%d%d%d%d')-- Ensure it contains a four-digit number (likely a year) andstring.match(args[v],'2C2C2C')==nil-- Avoids this specific pattern andnotstring.match(args[v],'^Unaired')-- Exclude anything starting with "Unaired" andstring.find(args[v],'itvstart')==nil-- Avoids a {{Start date}} unique class andonInitialPage andtitle.namespace==0 then addTrackingCategory(trackingCategoryList["air_dates"]) end -- Alternate air dates that do use {{Start date}} if(v=='AltDate'andargs[v]~=''andstring.find(args[v],'dtstart')~=nilandonInitialPageandtitle.namespace==0)then addTrackingCategory(trackingCategoryList["alt_air_dates"]) end end -- Local function which is used to create a Production Code cell. localfunctioncreateProductionCodeCell(args,v,numberOfParameterGroups) localthisRowspan if(notparameterGroupCells[v]andparameterGroupCellsAny)then thisRowspan=numberOfParameterGroups else thisRowspan=1 end if(hasValue(args.ProdCode)andstring.find(args.ProdCode,'TBA')==nil)then row:tag('td') :attr('id','pc'..idTrim(idTrim(args.ProdCode,' ----'),'<')) :attr('rowspan',thisRowspan) :css('text-align','center') :wikitext(args.ProdCode) elseif(args.ProdCode==''orstring.find(args.ProdCodeor'','TBA')~=nil)then createEmptyCell(args,v,false) createTableData(args.ProdCode,thisRowspan,"center") else -- ProductionCode parameter not used; Do nothing. end nonNilParams=nonNilParams+1 end --[[ Local function which is used to extract data from the numbered serial parameters (Title1, Aux1, etc.), and then convert them to use the non-numbered parameter names (Title, Aux). The function returns the args as non-numbered parameter names. ]]-- localfunctionextractDataFromNumberedSerialArgs(args,i,numberOfParameterGroups,title) for_,vinipairs(cellNameList)do localparameter=v localnumberedParameter=v.."_"..i localexcludeParameter=excludeList[parameter]or'NULL'..parameter localexcludeNumberParameter=(excludeList[numberedParameter]or'NULL'..parameter).."_"..i if(nothasValue(args[numberedParameter])andnothasValue(args[excludeNumberParameter]) andhasValue(parameterGroupCells[parameter])andnothasValue(args[excludeParameter]))then if(v~='ProdCode')then createEmptyCell(args,parameter,true) else args[parameter]='' end if(title.namespace==0)then addTrackingCategory(trackingCategoryList["nonmatching_numbered_parameters"]) end elseif(hasValue(args[numberedParameter])andnothasValue(args[excludeNumberParameter]))then args[parameter]=args[numberedParameter] end end returnargs end --[[ Local function which is used to create the Title cell text. The title text will be handled in the following way: Line 1: <Title><RTitle> (with no space between) Line 2: <AltTitle><RAltTitle> (with no space between) OR Line 2: Transliteration: <TranslitTitle> (<Language>: <NativeTitle>)<RAltTitle> (with space between first two parameters) If <Title> or <RTitle> are empty, then the values of line 2 will be placed on line 1 instead. --]] localfunctioncreateTitleText(args) localtitleString='' localisCellPresent=false localuseSecondLine=false locallineBreakUsed=false -- Surround the Title with quotes; No quotes if empty. if(args.Title~=nil)then if(args.Title=="")then isCellPresent=true else titleString='"'..args.Title..'"' useSecondLine=true isCellPresent=true end end if(args.RTitle~=nil)then if(args.RTitle=="")then isCellPresent=true else titleString=titleString..args.RTitle useSecondLine=true isCellPresent=true end end -- Surround the AltTitle/TranslitTitle with quotes; No quotes if empty. if(args.AltTitleorargs.TranslitTitle)then isCellPresent=true if(useSecondLine)then titleString=titleString.."<br />" lineBreakUsed=true end if(hasValue(args.AltTitle))then titleString=titleString..'"'..args.AltTitle..'"' elseif(hasValue(args.TranslitTitle))then if(hasValue(args.NativeTitleLangCode))then titleString=titleString..'Transliteration: "'..langModule._xlit({args.NativeTitleLangCode,args.TranslitTitle,italic='no'})..'"' else titleString=titleString..'Transliteration: "'..args.TranslitTitle..'"' end end end if(args.NativeTitle~=nil)then if(args.NativeTitle=="")then isCellPresent=true else isCellPresent=true if(useSecondLineandlineBreakUsed==false)then titleString=titleString.."<br />" end if(hasValue(args.NativeTitleLangCode))then locallanguageCode="Lang-"..args.NativeTitleLangCode titleString=titleString.." ("..langModule._langx({code=args.NativeTitleLangCode,text=args.NativeTitle})..")" else titleString=titleString.." ("..args.NativeTitle..")" end end end if(args.RAltTitle~=nil)then if(args.RAltTitle=="")then isCellPresent=true else isCellPresent=true if(useSecondLineandlineBreakUsed==false)then titleString=titleString.."<br />" end titleString=titleString..args.RAltTitle end end returntitleString,isCellPresent end --[[ Local function which is used to extract data from the numbered title parameters (Title1, RTitle2, etc.), and then convert them to use the non-numbered parameter names (Title, RTitle). The function returns two results: -- The args parameter table. -- A boolean indicating if the title group has data. ]]-- localfunctionextractDataFromNumberedTitleArgs(args,i) localnextGroupValid=false for_,vinipairs(titleList)do localparameter=v localnumberedParameter=v.."_"..i args[parameter]=args[numberedParameter] if(nextGroupValid==falseandhasValue(args[numberedParameter]))then nextGroupValid=true end end returnargs,nextGroupValid end -- Local function which is used to create a Title cell. localfunctioncreateTitleCell(args,numberOfParameterGroups,currentRow,isSerial) localtitleText localisCellPresent if(isSerialandargs.TitleandcurrentRow>1)then returnnil end if(args.Title_2)then localargs,nextGroupValid=extractDataFromNumberedTitleArgs(args,currentRow) end titleText,isCellPresent=createTitleText(args) if(isCellPresent==false)then returnnil end localtextAlign="left" -- If Title is blank, then set Raw Title to TBA if(hasValue(titleText)==false)then titleText=tableEmptyCellModule._main({}) textAlign="left" end -- If title is the first cell, create it with a !scope="row" if(nonNilParams==0)then if(isSerial)then row:tag('th') :addClass('summary') :attr('scope','row') :attr('rowspan',numberOfParameterGroups) :css('text-align',textAlign) :wikitext(titleText) else row:tag('th') :addClass('summary') :attr('scope','row') :css('text-align',textAlign) :wikitext(titleText) end else if(isSerial)then row:tag('td') :addClass('summary') :attr('rowspan',numberOfParameterGroups) :css('text-align',textAlign) :wikitext(titleText) else row:tag('td') :addClass('summary') :css('text-align',textAlign) :wikitext(titleText) end end nonNilParams=nonNilParams+1 end --[[ Local function which is used to create column cells. EpisodeNumber, EpisodeNumber2 are created in different functions as they require some various if checks. See: -- createEpisodeNumberCell() -- createEpisodeNumberCellSecondary() ]]-- localfunctioncreateCells(args,isSerial,currentRow,onInitialPage,title,numberOfParameterGroups) fork,vinipairs(cellNameList)do if(v=='ProdCode')then if(currentRow==1or(currentRow>1andparameterGroupCells[v]))then createProductionCodeCell(args,v,numberOfParameterGroups) end elseif(v=='Title')then if(currentRow==1or(currentRow>1andparameterGroupCells[v]))then localisSerial=notargs.Title_2andtrueorfalse createTitleCell(args,numberOfParameterGroups,currentRow,isSerial) end elseifexcludeList[v]andargs[excludeList[v]]then -- Ignore this parameter set as multiple conflicting parameters were used elseif(args[v]and(v~='EpisodeNumber'andv~='EpisodeNumber2'))then -- Set empty cells to TBA/TBD if(args[v]=='')then createEmptyCell(args,v,false) elseif(v=='WrittenBy'andtitle.namespace==0)then if((string.find(args[v],"''Story")~=nilorstring.find(args[v],"''Teleplay")~=nil)andstring.find(args[v],"8202")==nil)then --   is the hairspace added through {{StoryTeleplay}} addTrackingCategory(trackingCategoryList["raw_unformatted_storyteleplay"]) end end -- If serial titles need to be centered and not left, then this should be removed. localtextAlign="center" -- if (v == 'Aux1' and isSerial) then -- textAlign = "left" -- end localthisRowspan if(notparameterGroupCells[v]andparameterGroupCellsAny)then thisRowspan=numberOfParameterGroups else thisRowspan=1 end if(currentRow==1or(currentRow>1andparameterGroupCells[v]))then createTableData(args[v],thisRowspan,textAlign) end nonNilParams=nonNilParams+1 checkUsageOfDateTemplates(args,v,onInitialPage,title) end -- Usages of TBA via [[Template:TableTBA]] can be found with the "tv-tba" class. ifargs[v]and(args[v]=="TBA"orstring.find(args[v],"tv%-tba"))then cellValueTBA=true end end end -- Local function which is used to create a table row header for either the -- EpisodeNumber or EpisodeNumber2 column cells. localfunctioncreateTableRowEpisodeNumberHeader(episodeNumber,numberOfParameterGroups,episodeText,separateEpisodeNumbers) localepID=string.match(episodeNumber,"^%w+") row:tag('th') :attr('scope','row') :attr('rowspan',notseparateEpisodeNumbersandnumberOfParameterGroupsor1) :attr('id',epIDand'ep'..epIDor'') :css('text-align','center') :wikitext(episodeText) end --[[ Local function which is used to extract the text from the EpisodeNumber or EpisodeNumber2 parameters and format them into a correct MoS compliant version. Styles supported: -- A number range of two numbers, indicating the start and end of the range, seperated by an en-dash (–) with no spaces in between. Example: "1 - 2" -> "1–2"; "1-2-3" -> "1–3". -- An alphanumeric or letter range, similar to the above. Example: "A - B" -> "A–B"; "A-B-C" -> "A–C". Example: "A1 - B1" -> "A1–B1"; "A1-B1-C1" -> "A1–C1". -- A number range of two numbers, indicating the start and end of the range, seperated by a visual <hr /> (divider line). -- An alphanumeric or letter range, similar to the above. ]]-- localfunctiongetEpisodeText(episodeNumber) if(episodeNumber=='')then returntableEmptyCellModule._main({}) else localepisodeNumber1 localepisodeNumber2 -- Used for double episodes that need a visual "–"" or "<hr />"" added. localdivider episodeNumber=episodeNumber:gsub('%s*<br%s*/?%s*>%s*','<hr />') if(episodeNumber:match('^(%w+)%s*<hr */%s*>%s*(%w+)$'))then episodeNumber1,episodeNumber2=episodeNumber:match('^(%w+)%s*<hr */%s*>%s*(%w+)$') divider="<hr />" elseif(episodeNumber:match('^(%w+)%s*<hr */%s*>.-<hr */%s*>%s*(%w+)$'))then-- 3 or more elements episodeNumber1,episodeNumber2=episodeNumber:match('^(%w+)%s*<hr */%s*>.-<hr */%s*>%s*(%w+)$') divider="<hr />" elseif(mw.ustring.match(episodeNumber,'^(%w+)%s*[%s%-–/&]%s*(%w+)$'))then episodeNumber1,episodeNumber2=mw.ustring.match(episodeNumber,'^(%w+)%s*[%s%-–/&]%s*(%w+)$') divider="–" else episodeNumber1,episodeNumber2=mw.ustring.match(episodeNumber,'^(%w+)%s*[%s%-–/&].-[%s%-–/&]%s*(%w+)$')-- 3 or more elements divider="–" end if(notepisodeNumber1)then returnepisodeNumber elseif(notepisodeNumber2)then returnstring.match(episodeNumber,'%w+') else returnepisodeNumber1..divider..episodeNumber2 end end end -- Local function which is used to create EpisodeNumber2 and EpisodeNumber3 cells. localfunction_createEpisodeNumberCellSecondary(episodeValue,numberOfParameterGroups,separateEpisodeNumbers) if(episodeValue)then localepisodeText=getEpisodeText(episodeValue) if(nonNilParams==0)then createTableRowEpisodeNumberHeader(episodeValue,numberOfParameterGroups,episodeText,separateEpisodeNumbers) else createTableData(episodeText,notseparateEpisodeNumbersandnumberOfParameterGroupsor1,"center") end nonNilParams=nonNilParams+1 end end -- Local function which is used to create seconday episode number cells. localfunctioncreateEpisodeNumberCellSecondary(args,numberOfParameterGroups,separateEpisodeNumbers) _createEpisodeNumberCellSecondary(args.EpisodeNumber2,numberOfParameterGroups,separateEpisodeNumbers) _createEpisodeNumberCellSecondary(args.EpisodeNumber3,numberOfParameterGroups,separateEpisodeNumbers) end -- Local function which is used to create an EpisodeNumber cell. localfunctioncreateEpisodeNumberCell(args,numberOfParameterGroups,separateEpisodeNumbers) if(args.EpisodeNumber)then localepisodeText=getEpisodeText(args.EpisodeNumber) createTableRowEpisodeNumberHeader(args.EpisodeNumber,numberOfParameterGroups,episodeText,separateEpisodeNumbers) nonNilParams=nonNilParams+1 end end -- Local function which is used to create a single row of cells. -- This is the standard function called. localfunctioncreateSingleRowCells(args,numberOfParameterGroups,multiTitleListEnabled,onInitialPage,title) createEpisodeNumberCell(args,1,false) createEpisodeNumberCellSecondary(args,1,false) createCells(args,false,1,onInitialPage,title,numberOfParameterGroups) end -- Local function which is used to create a multiple row of cells. -- This function is called when part of the row is rowspaned. localfunctioncreateMultiRowCells(args,numberOfParameterGroups,onInitialPage,title,topColor) localEpisodeNumberSplit=(args.EpisodeNumber_1andtrueorfalse) fori=1,numberOfParameterGroupsdo args=extractDataFromNumberedSerialArgs(args,i,numberOfParameterGroups,title) if(EpisodeNumberSplitor(notEpisodeNumberSplitandi==1))then createEpisodeNumberCell(args,numberOfParameterGroups,EpisodeNumberSplit) createEpisodeNumberCellSecondary(args,numberOfParameterGroups,EpisodeNumberSplit) end createCells(args,true,i,onInitialPage,title,numberOfParameterGroups) if(i~=numberOfParameterGroups)then localtextColor='#333' iftopColor=='inherit'then textColor='inherit' end row=row:done()-- Use done() to close the 'tr' tag in rowspaned rows. :tag('tr') :addClass('vevent') :addClass('module-episode-list-row') :css('text-align','center') :css('background',topColor) :css('color',textColor) end end end -- Local function which is used to retrieve the NumParts value. localfunctiongetnumberOfParameterGroups(args) fork,vinipairs(cellNameList)do localnumberedParameter=v.."_"..1 if(args[numberedParameter])then parameterGroupCells[v]=true parameterGroupCellsAny=true ifnotfirstParameterGroupCellthen firstParameterGroupCell=k end end end if(hasValue(args.NumParts))then returnargs.NumParts,true else return1,false end end -- Local function which is used to retrieve the Top Color value. localfunctiongetTopColor(args,rowColorEnabled,onInitialPage) localepisodeNumber=mathModule._cleanNumber(args.EpisodeNumber)or1 if(args.TopColor)then if(string.find(args.TopColor,"#"))then returnargs.TopColor else return'#'..args.TopColor end else return'inherit' end end -- Local function which is used to retrieve the Row Color value. localfunctionisRowColorEnabled(args) localrowColorEnabled=yesNoModule(args.RowColor,false) if(args.RowColorandstring.lower(args.RowColor)=='on')then rowColorEnabled=true end returnrowColorEnabled end -- Local function which is used to retrieve the Line Color value. localfunctiongetLineColor(args) -- Default color to light blue locallineColor=args.LineColoror'CCCCFF' -- Add # to color if necessary, and set to default color if invalid if(htmlColor[lineColor]==nil)then lineColor='#'..(mw.ustring.match(lineColor,'^[%s#]*([a-fA-F0-9]*)[%s]*$')or'') if(lineColor=='#')then lineColor='#CCCCFF' end end returnlineColor end -- Local function which is used to check if the table is located on the page -- currently viewed, or on a transcluded page instead. -- If it is on a transcluded page, the episode summary should not be shown. localfunctionisOnInitialPage(args,sublist,pageTitle,initiallistTitle) -- This should be the only check needed, however, it was previously implemented with two templates -- with one of them not requiring an article name, so for backward compatability, the whole sequence is kept. localonInitialPage localonInitialPageCheck=(mw.uri.anchorEncode(pageTitle)==mw.uri.anchorEncode(initiallistTitle)) -- Only sublist had anything about hiding, so only it needs to even check if(sublist)then onInitialPage=onInitialPageCheck -- avoid processing ghost references if(notonInitialPage)then args.ShortSummary=nil end else if(initiallistTitle=="")then onInitialPage=true else onInitialPage=onInitialPageCheck end end returnonInitialPage end -- Local function which does the actual main process. localfunction_main(args,sublist) localtitle=mw.title.getCurrentTitle() localpageTitle=title.text localinitiallistTitle=args['1']or'' -- Is this list on the same page as the page directly calling the template? localonInitialPage=isOnInitialPage(args,sublist,pageTitle,initiallistTitle) -- Need just this parameter removed if blank, no others if(hasValue(args.ShortSummary)==false)then args.ShortSummary=nil end locallineColor=getLineColor(args) localrowColorEnabled=isRowColorEnabled(args) localtopColor=getTopColor(args,rowColorEnabled,onInitialPage) localroot=mw.html.create()-- Create the root mw.html object to return localtextColor='#333' iftopColor=='inherit'then textColor='inherit' end row=root:tag('tr')-- Create the table row and store it globally :addClass('vevent') :addClass('module-episode-list-row') :css('text-align','center') :css('background',topColor) :css('color',textColor) localnumberOfParameterGroups,multiTitleListEnabled=getnumberOfParameterGroups(args) if(multiTitleListEnabled)then createMultiRowCells(args,numberOfParameterGroups,onInitialPage,title,topColor) else createSingleRowCells(args,numberOfParameterGroups,multiTitleListEnabled,onInitialPage,title) end -- add these categories only in the mainspace and only if they are on the page where the template is used if(onInitialPageandtitle.namespace==0)then addLineColorTrackingCategories(args) addTopColorTrackingCategories(args) end if(cellValueTBA==trueandtitle.namespace==0)then addTrackingCategory(trackingCategoryList["tba_values"]) end -- Do not show the summary if this is being transcluded on the initial list page -- Do include it on all other lists if(onInitialPageandargs.ShortSummary)then localbottomWrapper=createShortSummaryRow(args,lineColor) returntostring(root)..tostring(bottomWrapper)..trackingCategories else returntostring(root)..trackingCategories end end -- Local function which handles both module entry points. localfunctionmain(frame,sublist) localgetArgs=require('Module:Arguments').getArgs localargs -- Most parameters should still display when blank, so don't remove blanks if(sublist)then args=getArgs(frame,{removeBlanks=false,wrappers='Template:Episode list/sublist'}) else args=getArgs(frame,{removeBlanks=false,wrappers='Template:Episode list'}) end -- args['1'] = mw.getCurrentFrame():getParent():getTitle() return_main(args,sublist,frame) end --[[ Public function which is used to create an Episode row for an Episode Table used for lists of episodes where each table is on a different page, usually placed on individual season articles. For tables which are all on the same page see p.list(). Parameters: -- |1= — required; The title of the article where the Episode Table is located at. -- |EpisodeNumber= — suggested; The overall episode number in the series. -- |EpisodeNumber2= — suggested; The episode number in the season. -- |Title= — suggested; The English title of the episode. -- |RTitle= — optional; Unformatted parameter that can be used to add a reference after "Title", or can be used as a "raw title" to replace "Title" completely. -- |AltTitle= — optional; An alternative title, such as the title of a foreign show's episode in its native language, or a title that was originally changed. -- |TranslitTitle= — optional; The title of the episode transliteration (Romanization) to Latin characters. -- |RAltTitle= — optional; Unformatted parameter that can be used to add a reference after "AltTitle", or can be used as a "raw title" to replace "AltTitle" completely. -- |NativeTitle= — optional; The title of the episode in the native language. -- |NativeTitleLangCode — optional; The language code of the native title language. -- |Aux1= — optional; General purpose parameter. The meaning is specified by the column header. This parameter is also used for Serial episode titles, such as those used in Doctor Who. -- |DirectedBy= — optional; Name of the episode's director. May contain links. -- |WrittenBy= — optional; Primary writer(s) of the episode. May include links. -- |Aux2= — optional; General purpose parameter. The meaning is specified by the column header. -- |Aux3= — optional; General purpose parameter. The meaning is specified by the column header. -- |OriginalAirDate= — optional; This is the date the episode first aired on TV, or is scheduled to air. -- |AltDate= — optional; The next notable air date, such as the first air date of an anime in English. -- |Guests= — optional; List of Guests for talk shows. Cannot be used simultaneously with Aux1. -- |MusicalGuests= — optional; List of MusicalGuests for talk shows. Cannot be used simultaneously with Aux2. -- |ProdCode= — optional; The production code in the series. When defined, this parameter also creates a link anchor, prefixed by "pc"; for example, List of episodes#pc01. -- |Viewers= — optional; Number of viewers who watched the episode. Should include a reference. -- |Aux4= — optional; General purpose parameter. The meaning is specified by the column header. -- |ShortSummary= — optional; A short 100–200 word plot summary of the episode. -- |LineColor= — optional; Colors the separator line between episode entries. If not defined the color defaults to "#CCCCFF" and the article is placed in Category:Episode list using the default LineColor. Use of "#", or anything but a valid hex code will result in an invalid syntax. -- |TopColor= — discouraged; Colors the main row of information (that is, not the ShortSummary row). Articles using this parameter are placed in Category:Episode lists with row deviations. -- |RowColor= — optional; Switch parameter that must only be defined when the EpisodeNumber= entry is not a regular number (e.g. "12–13" for two episodes described in one table entry). If the first episode number is even, define pass "on". If the first episode number is odd, pass "off". --]] functionp.sublist(frame) returnmain(frame,true) end --[[ Public function which is used to create an Episode row for an Episode Table used for lists of episodes where all tables are on the same page. For tables which are on different pages see p.sublist(). For complete parameter documentation, see the documentation at p.sublist(). --]] functionp.list(frame) returnmain(frame,false) end returnp