Module:Chessboard and Module:Chessboard/sandbox: Difference between pages
Appearance
(Difference between pages)
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 |
local letters_tp = letters:match( 'both' ) or letters:match( 'top' ) |
||
local |
local letters_bt = letters:match( 'both' ) or letters:match( 'bottom' ) |
||
local |
local numbers_lt = numbers:match( 'both' ) or numbers:match( 'left' ) |
||
local |
local numbers_rt = numbers:match( 'both' ) or numbers:match( 'right' ) |
||
local width = ncols * size + 2 |
local width = ncols * size + 2 |
||
if ( |
if ( numbers_lt ) then width = width + 18 end |
||
if ( |
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 ( |
if ( letters_tp ) then |
||
b:tag('tr') |
b:tag('tr') |
||
:wikitext(letters_row( rev, |
:wikitext(letters_row( rev, numbers_lt, numbers_rt )) |
||
end |
end |
||
local tablerow = b:tag('tr') |
local tablerow = b:tag('tr') |
||
if ( |
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 ( |
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 ( |
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 ( |
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 ( |
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 ( |
if ( letters_bt ) then |
||
b:tag('tr') |
b:tag('tr') |
||
:wikitext(letters_row( rev, |
:wikitext(letters_row( rev, numbers_lt, numbers_rt )) |
||
end |
end |
||