Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.13 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <!--
  3. To change this license header, choose License Headers in Project Properties.
  4. To change this template file, choose Tools | Templates
  5. and open the template in the editor.
  6. -->
  7. <html>
  8. <head>
  9. <title>Переставь фигуры</title>
  10. <meta charset="UTF-8">
  11. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  12. </head>
  13. <body>
  14. <table border=6 align="center" id="TABLE" cellpadding=4 cellspacing=0 >
  15. <caption>Переставь фигуры</caption>
  16. <tr> <td>3</td>
  17. <td><input type="button" id="button1" value="&#9821" style="width: 50px; height: 50px; font-size: 32px" onClick="onClick(0,0,button1.value)"></td>
  18. <td><input type="button" id="button2" value="&#9821" style="width: 50px; height: 50px; font-size: 32px" onclick="onClick(0,1,button2.value)"></td>
  19. <td><input type="button" id="button3" value="&#9821" style="width: 50px; height: 50px; font-size: 32px" onclick="onClick(0,2,button3.value)"></td> </tr>
  20. <tr> <td>2</td>
  21. <td><input type="button" id="button4" value="" style="width: 50px; height: 50px; font-size: 32px" onClick="onClick(1,0,button4.value)"></td>
  22. <td><input type="button" id="button5" value="" style="width: 50px; height: 50px; font-size: 32px" onclick="onClick(1,1,button5.value)"></td>
  23. <td><input type="button" id="button6" value="" style="width: 50px; height: 50px; font-size: 32px" onclick="onClick(1,2,button6.value)"></td> </tr>
  24. <tr> <td>1</td>
  25. <td><input type="button" id="button7" value="&#9816" style="width: 50px; height: 50px; font-size: 32px" onClick="onClick(2,0,button7.value)"></td>
  26. <td><input type="button" id="button8" value="&#9816" style="width: 50px; height: 50px; font-size: 32px" onclick="onClick(2,1,button8.value)"></td>
  27. <td><input type="button" id="button9" value="&#9816" style="width: 50px; height: 50px; font-size: 32px" onclick="onClick(2,2,button9.value)"></td> </tr>
  28. <tr> <td></td> <td>a</td> <td>b</td> <td>c</td> </tr>
  29. </table>
  30.  
  31. <script>
  32. function but(number){
  33. return document.getElementById(number);
  34. }
  35.  
  36. var ip=1, jp=0,vp="";
  37. var c=String.fromCharCode(9821);
  38. var nm = [['button1','button2','buton3'],['button4','button5','button6'],['button7','buton8','button9']];
  39. function onClick(i,j,v){
  40. if(vp===String.fromCharCode(9816)&& v===""){
  41. if((Math.abs(j-jp)==1 && Math.abs(i-ip)==2) || (Math.abs(j-jp)==2 && Math.abs(i-ip)==1)){
  42. but(nm[i][j]).value=vp;
  43. but(nm[ip][jp]).value="";
  44. }
  45. }
  46. if(vp===String.fromCharCode(9821) && v===""){
  47. if((Math.abs(j-jp)==1 && Math.abs(i-ip)==1)|(Math.abs(j-jp)==2&&Math.abs(i-ip)==2)){
  48. but(nm[i][j]).value=vp;
  49. but(nm[ip][jp]).value="";
  50. }
  51. }
  52. if(but("button4").value==="" && but("button5").value==="" &&
  53. but("button6").value==="" && but("button7").value===c &&
  54. but("button8").value===c && but("button9").value===c){
  55. alert("Молодец!");
  56. window.location.reload(true);
  57. }
  58.  
  59. ip=i;
  60. jp=j;
  61. if(i==0&&j==0) vp=but("button1").value;
  62. if(i==0&&j==1) vp=but("button2").value;
  63. if(i==0&&j==2) vp=but("button3").value;
  64. if(i==1&&j==0) vp=but("button4").value;
  65. if(i==1&&j==1) vp=but("button5").value;
  66. if(i==1&&j==2) vp=but("button6").value;
  67. if(i==2&&j==0) vp=but("button7").value;
  68. if(i==2&&j==1) vp=but("button8").value;
  69. if(i==2&&j==2) vp=but("button9").value;
  70. }
  71.  
  72. </script>
  73. </body>
  74. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement