Deze module is nog in ontwikkeling (versie 0.0) en wordt getest.
De Module:Layout is bedoeld om snel, consistent en uitgebreid een pagina op te maken.
Er is een op de module afgestemde handleiding over deze onderwijswiki beschikbaar.
localchess={};functionchess.main(call)localresponse="";response=chess.wrapper(call);returnresponse;endfunctionchess.wrapper(call)localwrapper_chessboard=mw.html.create('div');wrapper_chessboard:css({float='left',width='342px'}):css('text-align','center');ifcall.definitionthenlocalboldText=mw.html.create('b'):wikitext(call.definition)wrapper_chessboard:wikitext(tostring(boldText));end;wrapper_chessboard:node(chess.board(call));localclearDiv=mw.html.create('div'):css('clear','left');wrapper_chessboard:node(clearDiv);wrapper_chessboard:allDone();returnwrapper_chessboard;endfunctionchess.board(call)localchessboard=mw.html.create('div'):css('border','1px solid #b0b0b0'):css('background-color','#f9f9f9'):css('color','black'):css('padding-top','6px');chessboard:node(chess.grid(call));ifcall.descriptionthenlocalhtml=mw.html.create('div'):addClass('thumbcaption'):css('margin-left','4px'):css('margin-right','4px'):wikitext(call.description);chessboard:node(html);endreturnchessboard;endfunctionchess.files(letters)localletters_row=mw.html.create('tr')letters_row:css('vertical-align','middle')letters_row:tag('td'):wikitext('[[File:Solid white.svg|18px|link=|alt=]]'):done()forfile,letterinipairs(letters)doletters_row:tag('td'):css('background-color','white'):css('color','black'):wikitext(letter):done()endletters_row:tag('td'):wikitext('[[File:Solid white.svg|18px|link=|alt=]]'):done()returnletters_row;endfunctionchess.grid(call)localchessboard_grid=mw.html.create('table'):attr('cellpadding','0'):attr('cellspacing','0'):css('border','1px solid #b0b0b0'):css('margin','auto');-- All unnamed parameters contain information about the chessboard grid.localletters=call.content.CHESS.LETTERS_WHITE;ifcall.orientation=="black"thenletters=call.content.CHESS.LETTERS_BLACK;endchessboard_grid:node(chess.files(letters));ifcall.orientation=="white"thenfori=8,1,-1dochessboard_grid:node(chess.rank(i,call.content.matrix[i],letters,call));endelsefori=1,8,1dochessboard_grid:node(chess.rank(i,call.content.matrix[i],letters,call));endend-- Name the files by letters on the last rowchessboard_grid:node(chess.files(letters));returnchessboard_grid;endfunctionchess.rank(number,ranksquares,letters,call)iftype(number)~="number"ornumber<1ornumber>8thennumber=1;endiftype(letters)~="table"or#letters~=8thenletters=call.content.CHESS.LETTERS_WHITE;endifnot(ranksquaresandranksquares.aandranksquares.bandranksquares.candranksquares.dandranksquares.eandranksquares.fandranksquares.gandranksquares.h)thenranksquares=call.content.CHESS.RANK;endlocalranknumber=mw.html.create('td');ranknumber:css('background-color','white');ranknumber:css('color','black');ranknumber:css('text-align','center');ranknumber:wikitext(number);localrank=mw.html.create('tr');rank:css('vertical-align','middle');rank:node(ranknumber);-- Tthe type function is used to check if the variable is a table.-- The #var expression is used to check the length of the table, which should be 8. -- The next function is used to check if there are any named parameters in the table, and should return nil if there are none.forfile,letterinipairs(letters)dorank:node(chess.square(letter..tostring(number),ranksquares[letter],call));endrank:node(ranknumber);returnrank;endfunctionchess.square(name,piece,call)localfile=string.sub(name,1,1);iffile==nilorfile:byte()<97orfile:byte()>104thenname="a1";endlocalrank=tonumber(string.sub(name,2,2));ifrank==nilorrank<1orrank>8thenname="a1";end-- Get the name of the piece if existslocalpiece_description=call.message.CHESS.WITHOUT_A_PIECE;ifpiece~=""andcall.message.CHESS.ABBREVIATION[piece]~=nilthenpiece_description=call.message.CHESS.WITH_A_PIECE..call.message.CHESS.ABBREVIATION[piece];end-- Create the table cell elementlocalchessboard_square=mw.html.create('td'):css('background-color',chess.square_color(name,call.color[2].shades[10],call.color[2].tints[7])):css('color','black'):css('text-align','center'):wikitext('[[File:Chess '..piece..'t45.svg|26px|alt='..call.message.CHESS.SQUARE..name..piece_description..']]');returnchessboard_square;endfunctionchess.square_color(name,black,white)-- : string-- Get the file and rank numbers from the square_namelocalfile=string.sub(name,1,1);iffile==nilthenreturnwhite;endlocalrank=tonumber(string.sub(name,2,2));ifrank==nilorrank<1orrank>8thenreturnwhite;end-- Check if the square is on a white or black squareif((file=='a'orfile=='c'orfile=='e'orfile=='g')and(rank%2==1))or((file=='b'orfile=='d'orfile=='f'orfile=='h')and(rank%2==0))thenreturnblack;elsereturnwhite;endendreturnchess;