Jump to content

Module:Chessboard and Module:Chessboard/sandbox: Difference between pages

(Difference between pages)
Page 1
Page 2
Content deleted Content added
m use clearer variable names - took me a while to figure out what these mean
 
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
 
Line 47: Line 47:
end
end
local letters_top = letters:match( 'both' ) or letters:match( 'top' )
local letters_tp = letters:match( 'both' ) or letters:match( 'top' )
local letters_bottom = letters:match( 'both' ) or letters:match( 'bottom' )
local letters_bt = letters:match( 'both' ) or letters:match( 'bottom' )
local numbers_left = numbers:match( 'both' ) or numbers:match( 'left' )
local numbers_lt = numbers:match( 'both' ) or numbers:match( 'left' )
local numbers_right = numbers:match( 'both' ) or numbers:match( 'right' )
local numbers_rt = numbers:match( 'both' ) or numbers:match( 'right' )
local width = ncols * size + 2
local width = ncols * size + 2
if ( numbers_left ) then width = width + 18 end
if ( numbers_lt ) then width = width + 18 end
if ( numbers_right ) then width = width + 18 end
if ( numbers_rt ) then width = width + 18 end


local root = mw.html.create('div')
local root = mw.html.create('div')
Line 75: Line 75:
:attr('cellspacing', '0')
:attr('cellspacing', '0')


if ( letters_top ) then
if ( letters_tp ) then
b:tag('tr')
b:tag('tr')
:wikitext(letters_row( rev, numbers_left, numbers_right ))
:wikitext(letters_row( rev, numbers_lt, numbers_rt ))
end
end
local tablerow = b:tag('tr')
local tablerow = b:tag('tr')
if ( numbers_left ) then
if ( numbers_lt ) then
tablerow:tag('td')
tablerow:tag('td')
:css('width', '18px')
:css('width', '18px')
Line 91: Line 91:
:wikitext(innerboard(args, size, rev))
:wikitext(innerboard(args, size, rev))
if ( numbers_right ) then
if ( numbers_rt ) then
tablerow:tag('td')
tablerow:tag('td')
:css('width', '18px')
:css('width', '18px')
Line 97: Line 97:
:wikitext(rev and 1 or nrows)
:wikitext(rev and 1 or nrows)
end
end
if ( numbers_left or numbers_right ) then
if ( numbers_lt or numbers_rt ) then
for trow = 2, nrows do
for trow = 2, nrows do
local idx = rev and trow or ( 1 + nrows - trow )
local idx = rev and trow or ( 1 + nrows - trow )
tablerow = b:tag('tr')
tablerow = b:tag('tr')
if ( numbers_left ) then
if ( numbers_lt ) then
tablerow:tag('td')
tablerow:tag('td')
:css('height', size .. 'px')
:css('height', size .. 'px')
:wikitext(idx)
:wikitext(idx)
end
end
if ( numbers_right ) then
if ( numbers_rt ) then
tablerow:tag('td')
tablerow:tag('td')
:css('height', size .. 'px')
:css('height', size .. 'px')
Line 113: Line 113:
end
end
end
end
if ( letters_bottom ) then
if ( letters_bt ) then
b:tag('tr')
b:tag('tr')
:wikitext(letters_row( rev, numbers_left, numbers_right ))
:wikitext(letters_row( rev, numbers_lt, numbers_rt ))
end
end