Content deleted Content added
Plastikspork (talk | contribs) Nevermind, more complicated, need piece labels as well, so better with a data submodule for different games |
testing refactor |
||
Line 1:
local p = {}
local image_board, image_square
local function innerboard(args, size, rev)
local
root:addClass('chess-board')
:css('position', 'relative')
:wikitext(image_board(size))
for trow = 1,8 do
Line 56 ⟶ 14:
local col = rev and ( 9 - tcol ) or tcol
local piece = args[8 * ( 8 - row ) + col + 2] or ''
local img = image_square(piece:match('%w%w'), row, col, size )
root:tag('div')
:css('z-index', '3')
:css('top', tostring(( trow - 1 ) * size) .. 'px')
:css('left', tostring(( tcol - 1 ) * size) .. 'px')
:css('width',
:css('height',
:wikitext(img)
end
Line 69 ⟶ 28:
end
return tostring(
end
function chessboard(args, size, rev, letters, numbers, header, footer, align, clear)
function letters_row( rev, num_lt, num_rt )
local letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'}
local
if num_lt then
:css('vertical-align', 'inherit')
:css('padding', '0')
end
for k = 1,8 do
:css('padding', '0')
:css('vertical-align', 'inherit')
:css('text-align', 'center')
:css('height', '18px')
:css('width', size .. 'px')
:wikitext(rev and
end
if num_rt then
:css('vertical-align', 'inherit')
:css('padding', '0')
end
return tostring(
end
local letters_tp = letters:match(
local letters_bt = letters:match(
local numbers_lt = numbers:match(
local numbers_rt = numbers:match(
local width = 8 * size + 2
if ( numbers_lt ) then width = width + 18 end
Line 99 ⟶ 66:
local root = mw.html.create('div')
:addClass('thumb')
:addClass('noviewer')
:addClass(align)
if( header and header ~= '' ) then
root:tag('div'):addClass('center'):css('line-height', '130%'):css('margin', '0 auto'):css('max-width', (width + 8) .. 'px'):wikitext(header)
end
local
:addClass('thumbinner
:css('width', width .. 'px')
local
:attr('cellpadding', '0')
:attr('cellspacing', '0')
:css('background', 'white')
:css('font-size', '88%')
:css('border' , '1px #c8ccd1 solid')
:css('padding', '0')
:css('margin', 'auto')
if ( letters_tp ) then
:css('vertical-align', 'middle')
:wikitext(letters_row( rev, numbers_lt, numbers_rt ))
end
local tablerow =
if ( numbers_lt ) then
tablerow:tag('td')
:css('padding', '0')
:css('vertical-align', 'inherit')
:css('text-align', 'center')
:css('width', '18px')
:css('height',
:wikitext(rev and 1 or 8)
end
Line 129 ⟶ 102:
:attr('colspan', 8)
:attr('rowspan', 8)
:css('padding', '0')
:css('vertical-align', 'inherit')
:wikitext(innerboard(args, size, rev))
if ( numbers_rt ) then
tablerow:tag('td')
:css('padding', '0')
:css('vertical-align', 'inherit')
:css('text-align', 'center')
:css('width', '18px')
:css('height',
:wikitext(rev and 1 or 8)
end
Line 140 ⟶ 118:
for trow = 2, 8 do
local idx = rev and trow or ( 9 - trow )
tablerow =
:css('vertical-align', 'middle')
if ( numbers_lt ) then
tablerow:tag('td')
:css('
:css('vertical-align', 'inherit')
:css('text-align', 'center')
:css('height', size .. 'px')
:wikitext(idx)
end
if ( numbers_rt ) then
tablerow:tag('td')
:css('
:css('vertical-align', 'inherit')
:css('text-align', 'center')
:css('height', size .. 'px')
:wikitext(idx)
end
Line 154 ⟶ 139:
end
if ( letters_bt ) then
:
:wikitext(letters_row( rev, numbers_lt, numbers_rt ))
end
if (footer and footer ~= '') then
:addClass('thumbcaption')
:wikitext(footer)
Line 220 ⟶ 205:
local clear = args.clear or pargs.clear or ( align:match('tright') and 'right' ) or 'none'
local fen = args.fen or pargs.fen
local style = args.style or pargs.style or 'Chess'
image_board = require('Module:Chessboard/' .. style).image_board
image_square = require('Module:Chessboard/' .. style).image_square
size = mw.ustring.match( size, '[%d]+' ) or '26' -- remove px from size
if (fen) then
align = args.align or pargs.align or 'tright'
Line 230 ⟶ 216:
header = args.header or pargs.header or ''
footer = args.footer or pargs.footer or ''
return
end
if args[3] then
return
else
return
end
end
|