-- This module implements and .
local HTMLcolor = mw.loadData('Module:Color contrast/colors')
---------------------------------------------------------------------------------- EpisodeTable class-- The main class.--------------------------------------------------------------------------------
local contrast_ratio = require('Module:Color contrast')._ratiolocal EpisodeTable =
function EpisodeTable.cell(background, width, text, reference) local cell = mw.html.create('th') -- Cell cell:attr('scope','col') :css('background-color',background or '#CCCCFF') :css('width',width ~= and width .. '%' or nil) :wikitext(text) -- Reference if reference and reference ~= then cell:wikitext(" " .. EpisodeTable.reference(reference, background)) end return cellend
function EpisodeTable.reference(reference, background) local link1_cr = contrast_ratio local link2_cr = contrast_ratio local refspan = mw.html.create('span') :wikitext(reference) if link1_cr < 7 or link2_cr < 7 then refspan :css('background-color','white') :css('padding','1px') :css('display','inline-block') :css('line-height','50%') end return tostring(refspan)end
function EpisodeTable.abbr(text,title) local abbr = mw.html.create('abbr') :attr('title',title) :wikitext(text) return tostring(abbr)end
function EpisodeTable.part(frame,args) local row = mw.html.create('tr') local black_cr = contrast_ratio local white_cr = contrast_ratio local displaytext = (not args.nopart and 'Part ' or ) .. (args.p or ) row:tag('td') :attr('colspan',13) :css('text-align','center') :css('background-color', args.c) :css('color', black_cr > white_cr and 'black' or 'white') :wikitext("" .. frame:expandTemplate .. "" .. (args.r and " " .. EpisodeTable.reference(args.r, args.c) or )) return tostring(row)end
function EpisodeTable.new(args) args = args or local categories = local background = (args.background and args.background ~= and args.background ~= '#') and args.background or nil -- Add # to background if necessary if background ~= nil and HTMLcolor[background]
root :addClass('wikitable') :addClass('plainrowheaders') :addClass('wikiepisodetable') :addClass(tostring(sort_cond)) :css('width', args.total_width and string.gsub(args.total_width,'%%',) .. '%' or '100%') -- Caption if args.caption then root:tag('caption'):wikitext(args.caption) end -- Colour contrast; add to category only if it's in the mainspace local title = mw.title.getCurrentTitle local black_cr = contrast_ratio local white_cr = contrast_ratio if title.namespace
'series' and used_season
'season' then used_season = true end if (k <= 3 and thisCell
---------------------------------------------------------------------------------- Exports--------------------------------------------------------------------------------
local p =
function p.main(frame) local args = require('Module:Arguments').getArgs(frame,) return EpisodeTable.new(args)end
function p.part(frame) local args = require('Module:Arguments').getArgs(frame,) return EpisodeTable.part(frame,args)end
function p.ref(frame) local args = require('Module:Arguments').getArgs(frame,) return EpisodeTable.reference(args.r,args.b)end
return p