Jump to content

Module:Sandbox/3df

From Wikipedia, the free encyclopedia
local p = {}

p.main = function(frame)
	local args = frame.args
	local pargs = frame:getParent().args
	
	-- Use a thumbnail div, like an image. This part is from Module:Chessboard
	local root = mw.html.create('div')
		:addClass('thumb')
		:addClass('noviewer')
		:addClass('tright')
	local div = root:tag('div')
		:addClass('thumbinner')
		:css('width', '246px')
	local b = div:tag('table')
		:attr('cellpadding', '0')
		:attr('cellspacing', '0')
		:css('background', 'white')
		:css('font-size', '88%')
		:css('border' , '1px #c8ccd1 solid')
		:css('padding', '0')
		:css('margin', 'auto')
		:css('width', '100%')
	
	local row = b:tag('tr')
	for i = 1, 9 do
		row:tag('td')
			:css('text-align', 'center')
			:wikitext(i)
	end
		
	for i = 1, 9 do
		local row = b:tag('tr')
			:css('vertical-align', 'middle')
		for j = 1, 9 do
			local cell = row:tag('td')
				:css('padding', '0')
				:css('vertical-align', 'top')
				:css('text-align', 'center')
				:css('width', '26px')
				:css('height', '26px')
				:css('background-color', 'tan')
				:css('box-sizing', 'border-box')
				:css('border', '1px solid black')
				:css('position', 'relative')
				
			if (i == 4 or i == 7) and (j == 4 or j == 7) then
				cell:tag('div')
					:css('width', '6px')
					:css('height', '6px')
					:css('position', 'absolute')
					:css('top', '-4px')
					:css('left', '-4.01px')
					:css('border-radius', '6px')
					:css('background-color', 'black')
			end
			
			if (i == 7) then
				local piece = cell:tag('div')
					:css('height', '24px')
					:css('width', '24px')
					:css('vertical-align', 'middle')
					:css('text-align', 'center')
					:css('position', 'absolute')
					:css('top', '2px')
					:css('left', '0')
					:css('user-select', 'text')
					:css('font-family', '"Hiragino Mincho ProN", serif')
					:wikitext('[[File:Shogi blank pentagon.svg|24x19px|link=|class=notpageimage]]')
				piece:tag('div')
					:css('position', 'absolute')
					:css('top', '2px')
					:css('width', '100%')
					:wikitext('歩')
			end
			
			if (i == 8 and j == 2) then
				local piece = cell:tag('div')
					:css('height', '24px')
					:css('width', '24px')
					:css('vertical-align', 'middle')
					:css('text-align', 'center')
					:css('position', 'absolute')
					:css('top', '0')
					:css('left', '0')
					:css('user-select', 'text')
					:css('font-family', '"Hiragino Mincho ProN", serif')
					:wikitext('[[File:Shogi blank pentagon.svg|24x22px|link=|class=notpageimage]]')
				piece:tag('div')
					:css('position', 'absolute')
					:css('top', '3px')
					:css('width', '100%')
					:css('font-size', '130%')
					:wikitext('角')
			end
				
		end
		row:tag('td')
			:css('vertical-align', 'inherit')
			:css('text-align', 'center')
			:wikitext(10-i)
	end

		
	div:tag('div'):wikitext(pargs.test)

	return tostring(root)
end
return p