Content deleted Content added
optimize to 1940 |
No further discussion, copied the better sandbox version here. |
||
Line 3:
local p = {}
local function
local itemList = {}
if args[year] or args[year .. 'a'] then
return true▼
end
for asciiletter =
if args[year .. string.char(asciiletter)] then
end
end
return table.maxn(itemList), itemList
end
local function color(args, year, itemNum)
if args[year .. '_color'] then
Line 22 ⟶ 24:
for yearrange = 1, 5 do
if args['range' .. yearrange] and args['range' .. yearrange .. '_color'] then
local _, _, beginyear, endyear = string.find( args['range' .. yearrange], '^(%d%d%d%d)
local year = tonumber(year) or 9999 -- For year == 'TBA'
Line 30 ⟶ 32:
if year >= beginyear and year <= endyear then
local _, _, color1, color2 = string.find( args['range' .. yearrange .. '_color'], '^(%S*)%s*(%S*)$' )
color2 = (string.find(color2
return
end
end
end
return
end
local function
builder = builder:tag( 'td' )▼
if content ~= nil then▼
if itemNum > 1 then
builder = builder:attr('rowspan', itemNum)
end
end
local function
builder:tag( 'td' )▼
▲ :css('padding', '5px')
▲ :wikitext( year )
end▼
▲ :css( 'border', '1px solid black' )
▲ :css( 'background-color', color(args, year) )
▲ :css( 'padding', '5px' )
▲ if isYearReleased(args, year) == nil then return end
▲ builder = builder:tag('td')
builder:
▲ titleItem(builder, args[year] or args[year .. 'a' ])
:css('border', 'none')
:wikitext(itemList[1])
▲ titleItem(builder, args[year .. string.char(asciiletter)])
end
-- if itemNum >= 2
:css('border', 'none')
:css('padding','5px 5px 2px 5px')
:wikitext(itemList[1])
for key = 2, itemNum - 1 do
:tag('td')
:css('border', 'none')
:css('padding','2px 5px 2px 5px')
:wikitext(itemList[key])
▲ end
builder = builder:tag('tr')
:tag('td')
:css('border', 'none')
:css('padding','2px 5px 5px 5px')
:wikitext(itemList[itemNum])
end
local function row(builder, args, year)
local itemNum, itemList = items(args, year)
builder = builder:tag('tr')
left(builder, args, year, itemNum)
end
Line 88 ⟶ 104:
-- Main module code goes here.
local ret
local firstyear, lastyear
local TBA =
ret = mw.html.create( 'table' )
:addClass('wikitable')
:css('border', 'none')
:css('float', args.align or 'right')
:css('clear', args.align or 'right')
Line 96 ⟶ 114:
:css('font-size', '80%')
:css('line-height', '90%')
:css('border-collapse', '
:css('border-spacing', '0 1px')
:css('background-color', 'transparent')
ret:tag('caption')
:css('padding', '5px')
:wikitext(args.title and
:wikitext(args.subtitle and string.format('<br />
if tonumber(args.first) then
Line 108 ⟶ 127:
else
for i = 1940, os.date('%Y') do
if
firstyear = i
break
Line 119 ⟶ 138:
else
for i = os.date('%Y') + 3, TBA and os.date('%Y') or firstyear, -1 do
if
lastyear = i
break
|