Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. <html>
  2. <head>
  3. <style type="text/css">
  4. input{
  5. width:100px;
  6. height:100px;
  7. background-color:black;
  8. color:white;
  9. font-size:70px;
  10.  
  11.  
  12. }
  13.  
  14. .nowy{
  15. width:308px;
  16. height:20px;
  17. background-color:red;
  18. color:yellow;
  19. font-size:10px;
  20.  
  21.  
  22. }
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30. </style>
  31. <title>Układanka</title>
  32. <script type="text/javascript">
  33. function wolny(x)
  34. {
  35. if (x.value=="")
  36.  
  37. return true;
  38. else
  39.  
  40. return false;
  41.  
  42.  
  43. }
  44. button8, button9
  45. function zamien2(x, y,z)
  46. {
  47. if(wolny(y))
  48. {
  49. y.value=x.value;
  50. x.value="";
  51. }
  52. else
  53. if(wolny(z))
  54. {
  55. z.value=x.value;
  56. x.value="";
  57. }
  58.  
  59. }
  60. function zamien3(x, y,z,w)
  61. {
  62. if(wolny(y))
  63. {
  64. y.value=x.value;
  65. x.value="";
  66. }
  67. else
  68. if(wolny(z))
  69. {
  70. z.value=x.value;
  71. x.value="";
  72. }
  73. else
  74. if(wolny(w))
  75. {
  76. w.value=x.value;
  77. x.value="";
  78. }
  79.  
  80. }
  81. function zamien4(x, y,z,w,v)
  82. {
  83. if(wolny(y))
  84. {
  85. y.value=x.value;
  86. x.value="";
  87. }
  88. else
  89. if(wolny(z))
  90. {
  91. z.value=x.value;
  92. x.value="";
  93. }
  94. else
  95. if(wolny(w))
  96. {
  97. w.value=x.value;
  98. x.value="";
  99. }
  100. else
  101. if(wolny(v))
  102. {
  103. v.value=x.value;
  104. x.value="";
  105. }
  106.  
  107.  
  108.  
  109.  
  110. }
  111.  
  112. function pomieszaj()
  113. {
  114. for(k=0;k<10000;k++)
  115. {
  116. let los=Math.round(Math.random()*10);
  117. switch (los)
  118. {
  119. case 1: zamien2(button1,button2,button4); break;
  120. case 2: zamien3(button2,button1,button3,button5); break;
  121. case 3: zamien2(button3,button2,button6); break;
  122. case 4: zamien3(button4,button1,button5,button7); break;
  123. case 5: zamien4(button5,button2,button4,button6,button8); break;
  124. case 6: zamien3(button6,button3,button5,button9); break;
  125. case 7: zamien2(button7,button4,button8); break;
  126. case 8: zamien3(button8,button5,button7,button9); break;
  127. case 9: zamien2(button9,button6,button8); break;
  128. }
  129. }
  130.  
  131.  
  132.  
  133.  
  134.  
  135. }
  136.  
  137.  
  138.  
  139. </script>
  140. </head>
  141. <body>
  142. <input type="button" value="1" id="button1" onclick="zamien2(button1,button2,button4)" >
  143. <input type="button" value="2" id="button2" onclick="zamien3(button2,button1,button3,button5)">
  144. <input type="button" value="3" id="button3" onclick="zamien2(button3,button2,button6)"><br>
  145. <input type="button" value="4" id="button4" onclick="zamien3(button4,button1,button5,button7)">
  146. <input type="button" value="5" id="button5" onclick="zamien4(button5,button2,button4,button6,button8)">
  147. <input type="button" value="6" id="button6" onclick="zamien3(button6,button3,button5,button9)"><br>
  148. <input type="button" value="7" id="button7" onclick="zamien2(button7,button4,button8)">
  149. <input type="button" value="8" id="button8" onclick="zamien3(button8,button5,button7,button9)">
  150. <input type="button" value="" id="button9" onclick="zamien2(button9,button6,button8)"> <br>
  151. <input type="button" value="Pomieszaj" class="nowy" onclick="pomieszaj()">
  152.  
  153.  
  154. </body>
  155. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement