Jump to content

Module:Sandbox/CAS222222221

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 風中的刀劍 (talk | contribs) at 15:34, 16 July 2015. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local getArgs = require('Module:Arguments').getArgs
local p = {}

local function color(args, year)
	return '#FF6666'
end

local function titleItem(content)
	local ret
	
	if content ~= nil then
		ret = mw.html.create( 'span' )
		ret
			:css( 'text-indent', '-1em')
			:wikitext( '-' .. context )
	end
	
	return ret
end

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

local function center(args, year)
	local ret
	ret = mw.html.create( 'td' )
	
	ret
		:wikitext( ' ' )
		:css( 'width', '10px' )
		:css( 'background-color', color(args, year) )
		
	return ret
end

local function right(args, year)
	local ret
	ret = mw.html.create( 'td' )

	ret
		:css( 'padding-left', '1em')
		:node( titleItem(args[year]) or titleItem(args[year .. 'a' ]) )

	for i = 98, 106 do
		ret:node( titleItem(args[year .. string.char(i)]) )
	end

	return ret
end

local function row(args, year)
	local ret
	ret = mw.html.create('tr')
	
	ret
		:node( left(args, year) )
		:node( center(args, year) )
		:node( right(args, year) )
		
	return ret
end

--------------------------------------------------------------------------------

function p.main(frame)
	local args = getArgs(frame)
	return p._main(args)
end

function p._main(args)
	-- Main module code goes here.
	local ret

	ret = mw.html.create( 'table' )
	
	for year = 1990, 2015 do
		ret:node( row(args, year) )
	end
	
	return ret
end

return p