Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1.  
  2. var row;
  3. var col;
  4. var player;
  5. //var human = true;
  6. var lvl;
  7. var four = document.getElementById("four");
  8. var five = document.getElementById("five");
  9. var six = document.getElementById("six");
  10. var easy = document.getElementById("easy");
  11. var medium = document.getElementById("medium");
  12. var hard = document.getElementById("hard");
  13. var comp = document.getElementById("computer");
  14. var hum = document.getElementById("human");
  15. var run = document.getElementById("imgrungame");
  16.  
  17. var dot = document.getElementById("dot");
  18.  
  19. window.onload = function() {
  20.  
  21. four.onclick = function() {
  22. var tam = four.getAttribute("value");
  23. row = tam;
  24. col = tam;
  25.  
  26. }
  27. five.onclick = function() {
  28. var tam = five.getAttribute("value");
  29. row = tam;
  30. col = tam;
  31.  
  32. }
  33. six.onclick = function() {
  34. var tam = six.getAttribute("value");
  35. row = tam;
  36. col = tam;
  37. }
  38. easy.onclick = function() {
  39. var lvl = easy.getAttribute("value");
  40.  
  41. }
  42. medium.onclick = function() {
  43. var lvl = medium.getAttribute("value");
  44. }
  45. hard.onclick = function() {
  46. var lvl = hard.getAttribute("value");
  47. }
  48.  
  49. human.onclick = function() {
  50. var player = human.getAttribute("value");
  51. }
  52.  
  53. comp.onclick = function() {
  54. var player = comp.getAttribute("value");
  55. }
  56.  
  57. run.onclick = function() {
  58. drawBoard(row,col);
  59. }
  60.  
  61.  
  62. function drawBoard(row, col) {
  63. var div = document.createElement('div');
  64. var table = document.createElement('table');
  65. div.className = "board";
  66. div.appendChild(table);
  67. table.className = "table";
  68. for(var i=0; i<row; i++) {
  69. var tr = document.createElement('tr');
  70. for(var j=0; j<col; j++) {
  71. var td = document.createElement('td');
  72. td.id = "dot"+i+j;
  73. tr.appendChild(td);
  74. td.addEventListener("click", remove(i,j,"dot"+i+j), false);
  75. }
  76. table.appendChild(tr);
  77. }
  78. document.body.appendChild(div);
  79. }
  80.  
  81. }
  82.  
  83. function remove(x,y,id) {
  84. this.x = x;
  85. this.y = y;
  86. this.id = id;
  87. var removed = document.getElementById("id");
  88. removed.style.display = "none";
  89. console.log(removed);
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement