<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ATelevision_critical_response</id>
	<title>Module:Television critical response - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ATelevision_critical_response"/>
	<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:Television_critical_response&amp;action=history"/>
	<updated>2026-06-15T04:50:34Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.3</generator>
	<entry>
		<id>https://mywikibiz.com/index.php?title=Module:Television_critical_response&amp;diff=479711&amp;oldid=prev</id>
		<title>Zoran: Pywikibot 6.4.0</title>
		<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:Television_critical_response&amp;diff=479711&amp;oldid=prev"/>
		<updated>2021-07-16T07:34:24Z</updated>

		<summary type="html">&lt;p&gt;Pywikibot 6.4.0&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- This module implements {{Television critical response}}.&lt;br /&gt;
&lt;br /&gt;
require('Module:No globals')&lt;br /&gt;
local yesno = require('Module:Yesno')&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- CriticalResponse class&lt;br /&gt;
-- The main class.&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local CriticalResponse = {}&lt;br /&gt;
&lt;br /&gt;
function CriticalResponse.cellspan(SeasonEntries, SeasonEntries_ordered, key, cell, multipart)&lt;br /&gt;
	local spanlength = 1&lt;br /&gt;
	&lt;br /&gt;
	for i = cell+1, #SeasonEntries_ordered do&lt;br /&gt;
		local entry = SeasonEntries[SeasonEntries_ordered[i]]&lt;br /&gt;
		-- Split season, then regular season&lt;br /&gt;
		if entry.startA then&lt;br /&gt;
			if not entry[key..'A'] then spanlength = spanlength + 1&lt;br /&gt;
			else break end&lt;br /&gt;
			if not entry[key..'B'] then spanlength = spanlength + 1&lt;br /&gt;
			else break end&lt;br /&gt;
		else&lt;br /&gt;
			if not entry[key] and (not entry.special and multipart) then&lt;br /&gt;
				spanlength = spanlength + 1&lt;br /&gt;
			else break end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return spanlength&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Sorting function&lt;br /&gt;
function CriticalResponse.series_sort(op1, op2)&lt;br /&gt;
	local n1,s1 = string.match(op1,&amp;quot;(%d+)(%a*)&amp;quot;)&lt;br /&gt;
	local n2,s2 = string.match(op2,&amp;quot;(%d+)(%a*)&amp;quot;)&lt;br /&gt;
	local n1N,n2N = tonumber(n1),tonumber(n2)&lt;br /&gt;
&lt;br /&gt;
	if n1N == n2N then&lt;br /&gt;
		return s1 &amp;lt; s2&lt;br /&gt;
	else&lt;br /&gt;
		return n1N &amp;lt; n2N&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Function to add either text or {{N/a}} to cell&lt;br /&gt;
function CriticalResponse.season_cell(text, frame)&lt;br /&gt;
	local cell&lt;br /&gt;
	&lt;br /&gt;
	if string.find(text or '', 'table-na', 0, true) ~= nil then&lt;br /&gt;
		local findpipe = string.find(text, ' | ', 0, true)&lt;br /&gt;
		if findpipe ~= nil then&lt;br /&gt;
			cell = CriticalResponse.series_attributes( frame:expandTemplate{title='N/A',args={string.sub(text,findpipe+3)}} )&lt;br /&gt;
		else&lt;br /&gt;
			cell = CriticalResponse.series_attributes( frame:expandTemplate{title='N/A'} )&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		cell = mw.html.create('td'):wikitext(text)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return cell&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Allow usages of {{N/A}} cells&lt;br /&gt;
function CriticalResponse.series_attributes(infoParam)&lt;br /&gt;
	local entries = {}&lt;br /&gt;
	local infoCell = mw.html.create('td')&lt;br /&gt;
	local attrMatch = '([%a-]*)=&amp;quot;([^&amp;quot;]*)&amp;quot;'&lt;br /&gt;
	&lt;br /&gt;
	while true do&lt;br /&gt;
		local a,b = string.match(infoParam,attrMatch)&lt;br /&gt;
		if a == nil or b == nil then break end&lt;br /&gt;
		infoCell:attr(a,b)&lt;br /&gt;
		infoParam = string.gsub(infoParam,attrMatch,'',1)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	infoParam = string.gsub(infoParam,'%s*|%s*','',1)&lt;br /&gt;
	infoCell:wikitext(infoParam)&lt;br /&gt;
	&lt;br /&gt;
	return infoCell&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function CriticalResponse.new(frame, args)&lt;br /&gt;
	args = args or {}&lt;br /&gt;
	&lt;br /&gt;
	local initialArticle = args['1'] or ''&lt;br /&gt;
	local categories = ''&lt;br /&gt;
	local title = mw.title.getCurrentTitle()&lt;br /&gt;
	local hide_rotten_tomatoes = yesno(args.hide_rotten_tomatoes)&lt;br /&gt;
	local hide_metacritic = yesno(args.hide_metacritic)&lt;br /&gt;
	local show_cinemascore = yesno(args.show_cinemascore)&lt;br /&gt;
	local hide_season = yesno(args.hide_season)&lt;br /&gt;
	local series_name = tostring(title):gsub(&amp;quot;%s%((.-)%)&amp;quot;,&amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	-- Create critical response table&lt;br /&gt;
	local root = mw.html.create((args.multiseries or not args.series) and 'table' or '')&lt;br /&gt;
	local cellPadding = '0 8px'&lt;br /&gt;
	local basePadding = '0.2em 0.4em'&lt;br /&gt;
	&lt;br /&gt;
	root&lt;br /&gt;
		:addClass('wikitable')&lt;br /&gt;
		:addClass('plainrowheaders')&lt;br /&gt;
		:css('text-align', 'center')&lt;br /&gt;
		&lt;br /&gt;
	-- Remove float if multiple series&lt;br /&gt;
	if not args.multiseries then&lt;br /&gt;
		root:css('float', 'right')&lt;br /&gt;
		root:css('margin', '10px')&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Sortable&lt;br /&gt;
	if args.sortable or args.multiseries then&lt;br /&gt;
		root:addClass('sortable');&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Width&lt;br /&gt;
	if args.width then&lt;br /&gt;
		root:css('width', args.width)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Caption&lt;br /&gt;
	if not args.series then&lt;br /&gt;
		if args.title and args.multiseries then&lt;br /&gt;
			root:tag('caption'):wikitext(frame:expandTemplate{title='Screen reader-only',args={'Critical response of ' .. args.title}})&lt;br /&gt;
		elseif args.title then&lt;br /&gt;
			root:tag('caption'):wikitext(frame:expandTemplate{title='Screen reader-only',args={'Critical response of &amp;lt;i&amp;gt;' .. args.title .. '&amp;lt;/i&amp;gt;'}})&lt;br /&gt;
		else&lt;br /&gt;
			root:tag('caption'):wikitext(frame:expandTemplate{title='Screen reader-only',args={'Critical response of &amp;lt;i&amp;gt;' .. series_name .. '&amp;lt;/i&amp;gt;'}})&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Extract seasons info and place into a 3D array&lt;br /&gt;
	local SeasonEntries = {}&lt;br /&gt;
	for k,v in pairs(args) do&lt;br /&gt;
		local str, num, str2 = string.match(k, '([^%d]*)(%d*)(%a*)')&lt;br /&gt;
		if num ~= '' then&lt;br /&gt;
			-- Special&lt;br /&gt;
			local special = false&lt;br /&gt;
			if string.sub(str2,1,1) == 'S' then&lt;br /&gt;
				special = true&lt;br /&gt;
				num = num .. str2&lt;br /&gt;
				str2 = ''&lt;br /&gt;
			end&lt;br /&gt;
			-- Add to entries, create if necessary&lt;br /&gt;
			if not SeasonEntries[num] then&lt;br /&gt;
				SeasonEntries[num] = {}&lt;br /&gt;
			end&lt;br /&gt;
			SeasonEntries[num][str .. str2] = v&lt;br /&gt;
			if special then&lt;br /&gt;
				SeasonEntries[num]['special'] = 'y'&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Order table by season number&lt;br /&gt;
	local SeasonEntries_ordered = {}&lt;br /&gt;
	for k in pairs(SeasonEntries) do&lt;br /&gt;
		table.insert(SeasonEntries_ordered, k)&lt;br /&gt;
	end&lt;br /&gt;
	table.sort(SeasonEntries_ordered,CriticalResponse.series_sort)&lt;br /&gt;
	&lt;br /&gt;
	local firstRow = args.multiseries and {} or SeasonEntries[SeasonEntries_ordered[1]]&lt;br /&gt;
&lt;br /&gt;
	-- Headers&lt;br /&gt;
	do&lt;br /&gt;
		if args.multiseries or not args.series then&lt;br /&gt;
			local headerRow = root:tag('tr')&lt;br /&gt;
			headerRow&lt;br /&gt;
				:css('text-align', 'center')&lt;br /&gt;
			&lt;br /&gt;
			-- Multiple series header&lt;br /&gt;
			if args.multiseries then&lt;br /&gt;
				headerRow:tag('th')&lt;br /&gt;
					:attr('scope', 'col')&lt;br /&gt;
					:css('padding', cellPadding)&lt;br /&gt;
					:wikitext('Title')&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			-- Season header&lt;br /&gt;
			if not hide_season then&lt;br /&gt;
				headerRow:tag('th')&lt;br /&gt;
					:attr('scope', 'col')&lt;br /&gt;
					:css('min-width', '50px')&lt;br /&gt;
					:css('padding', cellPadding)&lt;br /&gt;
					:addClass('unsortable')&lt;br /&gt;
					:wikitext(args.seriesT or args.seasonT or 'Season')&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			-- Rotten Tomatoes header&lt;br /&gt;
			if not hide_rotten_tomatoes then&lt;br /&gt;
				headerRow:tag('th')&lt;br /&gt;
					:attr('scope', 'col')&lt;br /&gt;
					:wikitext('[[Rotten Tomatoes]]')&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			-- Metacritic header&lt;br /&gt;
			if not hide_metacritic then&lt;br /&gt;
				headerRow:tag('th')&lt;br /&gt;
					:attr('scope', 'col')&lt;br /&gt;
					:wikitext('[[Metacritic]]')&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			-- CinemaScore header&lt;br /&gt;
			if show_cinemascore then&lt;br /&gt;
				headerRow:tag('th')&lt;br /&gt;
					:attr('scope', 'col')&lt;br /&gt;
					:wikitext('[[CinemaScore]]')&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Season rows&lt;br /&gt;
	do&lt;br /&gt;
		if args.multiseries then&lt;br /&gt;
			-- Multi series individual entries&lt;br /&gt;
			if args.multiseries ~= &amp;quot;y&amp;quot; then&lt;br /&gt;
				root:node(args.multiseries)&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			-- One row entries, only categorized in the mainspace&lt;br /&gt;
			if #SeasonEntries == 1 then&lt;br /&gt;
				categories = categories .. '[[Category:Articles using Template:Television critical response with only one row]]'&lt;br /&gt;
			end&lt;br /&gt;
		&lt;br /&gt;
			-- Determine number of rows in the whole table&lt;br /&gt;
			local SeasonEntriesRows = 0&lt;br /&gt;
			for X = 1, #SeasonEntries_ordered do&lt;br /&gt;
				local season, entry = SeasonEntries_ordered[X], SeasonEntries[SeasonEntries_ordered[X]]&lt;br /&gt;
				SeasonEntriesRows = SeasonEntriesRows + 1&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			for X = 1, #SeasonEntries_ordered do&lt;br /&gt;
				local season, entry = SeasonEntries_ordered[X], SeasonEntries[SeasonEntries_ordered[X]]&lt;br /&gt;
				&lt;br /&gt;
				-- Season rows for each season&lt;br /&gt;
				for k0 = string.byte('A')-1, string.byte('Z') do&lt;br /&gt;
					local k = string.char(k0)&lt;br /&gt;
					if k0 == string.byte('A')-1 then k = '' end&lt;br /&gt;
					&lt;br /&gt;
					-- New season row&lt;br /&gt;
					local seasonRow = (entry['rotten_tomatoes' .. k] or entry['metacritic' .. k] or entry['cinemascore' .. k]) and root:tag('tr') or mw.html.create('tr')&lt;br /&gt;
					&lt;br /&gt;
					-- Series name for group overviews&lt;br /&gt;
					if X == 1 and (k == '' or k == 'A') and args.series then&lt;br /&gt;
						seasonRow:tag('th')&lt;br /&gt;
							:attr('scope', 'row')&lt;br /&gt;
							:attr('rowspan', SeasonEntriesRows)&lt;br /&gt;
							:wikitext(args.series)&lt;br /&gt;
					end&lt;br /&gt;
					&lt;br /&gt;
					-- Season number link, included only in the first row&lt;br /&gt;
					if not hide_season then&lt;br /&gt;
						if k == '' or k == 'A' then&lt;br /&gt;
							seasonRow:tag(args.series and 'td' or 'th')&lt;br /&gt;
								:attr('scope', 'row')&lt;br /&gt;
								:attr('colspan', entry.special or 1)&lt;br /&gt;
								:css('text-align', 'center')&lt;br /&gt;
								:wikitext((entry.link and '[[' .. entry.link .. '|' .. (entry.linkT or season) .. ']]' or (entry.linkT or season)) .. (entry.linkR or ''))&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
				&lt;br /&gt;
					-- Rotten Tomatoes&lt;br /&gt;
					if not hide_rotten_tomatoes and entry['rotten_tomatoes' .. k] ~= 'metacritic' then&lt;br /&gt;
						if entry['rotten_tomatoes' .. k] then&lt;br /&gt;
							local thisCell = CriticalResponse.season_cell(entry['rotten_tomatoes' .. k], frame)&lt;br /&gt;
								:css('padding',basePadding)&lt;br /&gt;
							seasonRow:node(thisCell)&lt;br /&gt;
						else&lt;br /&gt;
							local infoCell = CriticalResponse.series_attributes( frame:expandTemplate{title='N/A'} )&lt;br /&gt;
							infoCell:css('padding',basePadding)&lt;br /&gt;
							seasonRow:node(infoCell)&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
					&lt;br /&gt;
					-- Metacritic&lt;br /&gt;
					if not hide_metacritic and entry['metacritic' .. k] ~= 'rotten_tomatoes' then&lt;br /&gt;
						if entry['metacritic' .. k] then&lt;br /&gt;
							local thisCell = CriticalResponse.season_cell(entry['metacritic' .. k], frame)&lt;br /&gt;
								:css('padding',cellPadding)&lt;br /&gt;
							seasonRow:node(thisCell)&lt;br /&gt;
						else&lt;br /&gt;
							local infoCell = CriticalResponse.series_attributes( frame:expandTemplate{title='N/A'} )&lt;br /&gt;
							infoCell:css('padding',cellPadding)&lt;br /&gt;
							seasonRow:node(infoCell)&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
					&lt;br /&gt;
					-- CinemaScore&lt;br /&gt;
					if show_cinemascore and entry['cinemascore' .. k] ~= 'rotten_tomatoes' then&lt;br /&gt;
						if entry['cinemascore' .. k] then&lt;br /&gt;
							local thisCell = CriticalResponse.season_cell(entry['cinemascore' .. k], frame)&lt;br /&gt;
								:css('padding',cellPadding)&lt;br /&gt;
							seasonRow:node(thisCell)&lt;br /&gt;
						else&lt;br /&gt;
							local infoCell = CriticalResponse.series_attributes( frame:expandTemplate{title='N/A'} )&lt;br /&gt;
							infoCell:css('padding',cellPadding)&lt;br /&gt;
							seasonRow:node(infoCell)&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
				&lt;br /&gt;
				end -- End k0 string.byte&lt;br /&gt;
			end -- End 'for' SeasonEntries_ordered&lt;br /&gt;
		end -- End 'if' multiseries&lt;br /&gt;
	end -- End 'do' season rows&lt;br /&gt;
&lt;br /&gt;
	return (args.dontclose and mw.ustring.gsub(tostring(root), &amp;quot;&amp;lt;/table&amp;gt;&amp;quot;, &amp;quot;&amp;quot;) or tostring(root)) .. categories&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Exports&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local args = require('Module:Arguments').getArgs(frame, {&lt;br /&gt;
		wrappers = 'Template:Television critical response'&lt;br /&gt;
	})&lt;br /&gt;
	return CriticalResponse.new(frame, args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Zoran</name></author>
	</entry>
</feed>