Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function chessDraw(n){
- document.write("<table>");
- var chars = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
- for(i = 0; i<n+1; i++){
- document.write("<tr>");
- for(j = 0; j<n+1;j++){
- if(i==n && j==n){}
- else if(j==n){
- if(n<27){
- document.write("<td class='isNumOrChar'>"+chars[i]+"</td>");
- }
- else{
- document.write("<td class='isNumOrChar'>");
- for(k=Math.ceil(Math.log(n)/Math.log(26));k>0;k--){
- document.write(chars[Math.ceil(i*j/Math.pow(26,k))]);
- }
- document.write("</td>");
- }
- }
- else if(i==n){
- document.write("<td class='isNumOrChar'>"+(j+1)+"</td>");
- }
- else if(i%2==0 && j%2==1){
- document.write("<td class='isBlack'></td>");
- }
- else if(i%2==1 && j%2==0){
- document.write("<td class='isBlack'></td>");
- }
- else{
- document.write("<td class='isWhite'></td>");
- }
- }
- document.write("</tr>");
- }
- document.write("</table>");
- }
Advertisement
Add Comment
Please, Sign In to add comment