Content deleted Content added
No edit summary |
rename class "chess-board" to "chess-pieces", since the div contains only the pieces, and to avoid confusion with the new top-level "chessboard" class |
||
(26 intermediate revisions by 5 users not shown) | |||
Line 4:
local function innerboard(args, size, rev)
pattern = cfg.pattern or '%w%w'
local root = mw.html.create('div')
root:addClass('chess-
:css('position', 'relative')
:wikitext(cfg.image_board(size))
for trow = 1,nrows do
Line 14 ⟶ 15:
local col = rev and ( 1 + ncols - tcol ) or tcol
local piece = args[ncols * ( nrows - row ) + col + 2] or ''
if piece:match(
local img = cfg.image_square(piece:match(
root:tag('div')
:css('top', tostring(( trow - 1 ) * size) .. 'px')
:css('left', tostring(( tcol - 1 ) * size) .. 'px')
:wikitext(img)
end
Line 33 ⟶ 30:
function chessboard(args, size, rev, letters, numbers, header, footer, align, clear)
function letters_row( rev, num_lt, num_rt )
local letters =
local root = mw.html.create('')
if num_lt then
root:tag('td')
end
for k = 1,ncols do
root:tag('td')
:css('height', '18px')
:css('width', size .. 'px')
Line 51 ⟶ 43:
if num_rt then
root:tag('td')
end
return tostring(root)
Line 66 ⟶ 56:
local root = mw.html.create('div')
:addClass('chessboard')
: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 + ncols) .. 'px') :wikitext(header) end
local div = root:tag('div')
Line 78 ⟶ 74:
:attr('cellpadding', '0')
:attr('cellspacing', '0')
if ( letters_tp ) then
b:tag('tr')
:wikitext(letters_row( rev, numbers_lt, numbers_rt ))
end
local tablerow = b:tag('tr
if ( numbers_lt ) then
tablerow:tag('td')
:css('width', '18px')
:css('height', size .. 'px')
Line 102 ⟶ 89:
:attr('colspan', ncols)
:attr('rowspan', nrows)
:wikitext(innerboard(args, size, rev))
if ( numbers_rt ) then
tablerow:tag('td')
:css('width', '18px')
:css('height', size .. 'px')
Line 119 ⟶ 101:
local idx = rev and trow or ( 1 + nrows - trow )
tablerow = b:tag('tr')
if ( numbers_lt ) then
tablerow:tag('td')
:css('height', size .. 'px')
:wikitext(idx)
Line 130 ⟶ 108:
if ( numbers_rt ) then
tablerow:tag('td')
:css('height', size .. 'px')
:wikitext(idx)
Line 140 ⟶ 115:
if ( letters_bt ) then
b:tag('tr')
:wikitext(letters_row( rev, numbers_lt, numbers_rt ))
end
if
div:tag('div')
:addClass('thumbcaption')
Line 150 ⟶ 124:
end
return tostring(root) ..
mw.getCurrentFrame():extensionTag( 'templatestyles', '', { src = 'Module:Chessboard/styles.css' } )
end
Line 209 ⟶ 184:
local clear = args.clear or pargs.clear or ( align:match('tright') and 'right' ) or 'none'
local fen = args.fen or pargs.fen
local pgn = args.pgn or pargs.pgn
size = mw.ustring.match( size, '[%d]+' ) or '26' -- remove px from size
if (pgn) then
local pgnModule = require('Module:Pgn')
metadata, moves = pgnModule.main(pgn)
fen = moves[#moves]
end▼
if (fen) then
align = args.align or pargs.align or 'tright'
Line 223 ⟶ 204:
return chessboard(pargs, size, reverse, letters, numbers, header, footer, align, clear)
end
▲ end
end
|