跳转到内容

模組:Release timeline

维基百科,自由的百科全书

这是本页的一个历史版本,由風中的刀劍留言 | 贡献2015年7月16日 (四) 14:10编辑。这可能和当前版本存在着巨大的差异。

local function left( year )
	local td = mw.html.create( 'td' )
	
	td
		:wikitext( year .. '-' )
		
	return tostring( td )
end

local function center( color )
	local td  = mw.html.create( 'td' )
	
	td
		:css( 'width', '10px' )
		:css( 'border', '1px solid black' )
		:css( 'background-color', color )
		:wikitext( ' ' )
		
	return tostring( td )
end

local function right( content )
	local td  = mw.html.create( 'td' )
	
	td
		:wikitext( content )
		
	return tostring( td )
end

local function row( year, color, content )
	local tr = mw.html.create( 'tr' )
	
	tr
		:wikitext( left( year ) .. center( color ) .. right( content ) )
		
	return tostring( tr )
end

local getArgs = require('Module:Arguments').getArgs
local p = {}
 
function p.main(frame)
	local args = getArgs(frame, {
	valueFunc = function (key, value)
		if value == '' then
			value = nil
		end
		return value
	end
	})

	if not args.first then
		for i = 1982, os.date("%Y") do
			if args[i] or args[i .. 'a'] then
				args.first = i
				break
			end
		end
	end

	if not args.last then
		for i = os.date("%Y") + 3, args.first, -1 do
			if args[i] or args[i .. 'a'] then
				if i >= os.date("%Y") + 1 or i <= os.date("%Y") - 10 then
					args.last = i
					break
				elseif i >= os.date("%Y") - 10 then
					args.last = os.date("%Y")
					break
				end
			end	
		end	
	end
	
	return p._main(args)
end
 
function p._main(args)
	-- Main module code goes here.
	local tab = mw.html.create( 'table' )
	local temp = '<caption cellspacing="3" style="margin: 0 0 0.5ex 1em; font-size: 110%;"><b>' .. ( args.title and args.title or '发行时间轴' ) .. '</b></caption>'

	for i = args.first, args.last do
		if args[i] or args[i .. 'a'] then
			local _temp = '-' .. ( args[i] and args[i] or args[i .. 'a'] )
			for j = 98, 106 do
				if  args[i .. string.char(j)] then
					_temp = _temp .. '<br />-' .. args[i .. string.char(j)]
				end
			end
			temp = temp .. row( i, ( args[i .. '_color'] and args[i .. '_color'] or '#22BB22' ), _temp )
		else
			temp = temp .. row( i, ( args[i .. '_color'] and args[i .. '_color'] or '#08DA51' ), '&nbsp;' )
		end
	end		
	
	tab
		:css( 'float', args.align and args.align or 'right' )
		:css( 'margin', '0 0 0.5ex 1em' )
		:css( 'font-size', '88%' )
		:css( 'line-height', '90%' )
		:css( 'clear',  args.align and args.align or 'right' )
		:css( 'max-width', '264px' )
		:attr( 'cellspacing', '0' )
		:attr( 'cellpadding', '2' )
		:attr( 'summary', args.summary )
		:wikitext( temp )
	
	return tostring( tab )
end
 
return p