Content deleted Content added
No edit summary |
Update |
||
Line 10:
function TVRG.hex2rgb(hex)
hex = hex:gsub('#', '')
if #hex == 3 then
return tonumber("0x"..hex:sub(1,2))/256, tonumber("0x"..hex:sub(3,4))/256, tonumber("0x"..hex:sub(5,6))/256▼
return tonumber("0x"..hex:sub(1,1))/256, tonumber("0x"..hex:sub(2,2))/256, tonumber("0x"..hex:sub(3,3))/256
▲ return tonumber("0x"..hex:sub(1,2))/256, tonumber("0x"..hex:sub(3,4))/256, tonumber("0x"..hex:sub(5,6))/256
end
end
Line 37 ⟶ 41:
local timelineCode = ''
local average = args.average and 1 or 0
local root = mw.html.create('div')
:attr('align', 'center')
Line 46 ⟶ 51:
timelineCode = timelineCode .. "Colors =\n"
timelineCode = timelineCode .. " id:a value:gray(0.7)\n"
local max_season = -1;
for k,v in pairs(args) do
local season_num = tonumber(string.sub(k,6))
if string.sub(k,1,5) == 'color' and season_num > max_season then
max_season = season_num
end
end
local season_num = 1
local r,g,b = TVRG.hex2rgb(args['color' .. season_num] or '#006600')
timelineCode = timelineCode .. " id:season" .. season_num .. " value:rgb("..r..","..g..","..b..") legend:" ..
string.gsub((args["legend" .. season_num] or "Season " .. season_num), ' ', '_') .. "\n"
Line 58 ⟶ 71:
for k,v in pairs(args) do
local num = tonumber(v)
if tonumber(k) ~= nil and num ~= nil and num > max_number then
max_number = num
end
Line 85 ⟶ 98:
end
this_episodes = 0
elseif average == 0 or (average == 1 and (args[k+1] == '-' or args[k+1] == nil) == false) then
▲ else
timelineCode = timelineCode .. " bar:" .. bar .. " from:start till:" .. (v ~= '' and v or 'start') .. "\n"
this_episodes = this_episodes + 1
Line 100 ⟶ 113:
:css('text-align', 'center')
if args.title ~= nil and args.title ~= '' then
rtable:tag('caption'):wikitext("''" .. args.title .. "'': Viewers per episode (millions)") else
rtable:tag('caption'):wikitext("Viewers per episode (millions)")
end
local row = rtable:tag('tr')
Line 109 ⟶ 126:
:attr('scope','col')
:wikitext('Ep. '..i)
end
if average == 1 then
row:tag('th')
:attr('scope','col')
:wikitext("''Average''")
end
Line 117 ⟶ 140:
if tonumber(k) ~= nil then
if v == '-' then
if season > 1 and this_episodes
row:node(TVRG.NACell(frame,"N/A"):attr('colspan',max_episodes-this_episodes))
end
Line 139 ⟶ 162:
end
if this_episodes
row:node(TVRG.NACell(frame,"N/A"):attr('colspan',max_episodes-this_episodes))
end
|