Combreal

sortImgGame.html

Apr 4th, 2021 (edited)
774
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 7.31 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3.     <head>
  4.         <style>
  5.             #div1, #div2
  6.             {
  7.                 float:left;
  8.                 width: 350px;
  9.                 height: 70px;
  10.                 padding: 10px;
  11.                 border: 1px solid #aaaaaa;
  12.             }
  13.            
  14.             #div1bis, #div2bis
  15.             {
  16.                 float:left;
  17.                 padding-left:5px;
  18.             }
  19.            
  20.             .flex
  21.             {
  22.                 padding-left: 150px;
  23.             }
  24.         </style>
  25.         <script>
  26.             function allowDrop(ev)
  27.             {
  28.                 ev.preventDefault();
  29.             }
  30.            
  31.             function drag(ev){
  32.                 ev.dataTransfer.setData("text", ev.target.id);
  33.             }
  34.            
  35.             function drop(ev)
  36.             {
  37.                 ev.preventDefault();
  38.                 var data = ev.dataTransfer.getData("text");
  39.                 ev.target.appendChild(document.getElementById(data));
  40.             }
  41.            
  42.             function reload()
  43.             {
  44.                 location.reload();
  45.             }
  46.            
  47.             function check()
  48.             {
  49.                 var goodResponses = 0;
  50.                 var offsets = document.getElementById('drag1').getBoundingClientRect();
  51.                 var top = offsets.top;
  52.                 var left = offsets.left;
  53.                 //alert(top + ' , ' + left)
  54.                 if ((top == 61) && (left == 19))
  55.                 {
  56.                     document.getElementById("div1").style.border = "thick solid #008000";
  57.                     goodResponses++;
  58.                 }
  59.                 else
  60.                 {
  61.                     document.getElementById("div1").style.border = "thick solid #FF0000";
  62.                 }
  63.                 offsets = document.getElementById('drag2').getBoundingClientRect();
  64.                 top = offsets.top;
  65.                 left = offsets.left;
  66.                 if ((top == 169) && (left == 19))
  67.                 {
  68.                     document.getElementById("div2").style.border = "thick solid #008000";
  69.                     goodResponses++;
  70.                 }
  71.                 else
  72.                 {
  73.                     document.getElementById("div2").style.border = "thick solid #FF0000";
  74.                 }
  75.                 if (goodResponses == 2)
  76.                 {
  77.                     document.getElementById("div3").innerHTML = "Congrats";
  78.                 }
  79.                 else
  80.                 {
  81.                     document.getElementById("div3").innerHTML = "Try again";
  82.                 }
  83.                 setTimeout(reload, 3000)
  84.             }
  85.         </script>
  86.     </head>
  87.     <body>
  88.         <p>Drag the images into the right rectangles :</p> 
  89.         <div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
  90.         <br><br>
  91.         <div id="div1bis">logo</div>
  92.         <br><br><br><br>
  93.         <div id="div2" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
  94.         <br><br>
  95.         <div id="div2bis">logo2</div>
  96.         <br><br><br><br>
  97.         <div class="flex">
  98.              <button type="button" onclick='check()'>Check</button>
  99.         </div>
  100.         <div id="div3"></div>
  101.         <br>
  102.         <img id="drag1" draggable="true" ondragstart="drag(event)" width="336" height="69" alt="" src="data:image/png;base64,R0lGODlhUAFFAGAAACH5BAEAAAAALAAAAABQAUUAhwAAAAAAMwAAZgAAmQAAzAAA/wArAAArMwArZgArmQArzAAr/wBVAABVMwBVZgBVmQBVzABV/wCAAACAMwCAZgCAmQCAzACA/wCqAACqMwCqZgCqmQCqzACq/wDVAADVMwDVZgDVmQDVzADV/wD/AAD/MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMrADMrMzMrZjMrmTMrzDMr/zNVADNVMzNVZjNVmTNVzDNV/zOAADOAMzOAZjOAmTOAzDOA/zOqADOqMzOqZjOqmTOqzDOq/zPVADPVMzPVZjPVmTPVzDPV/zP/ADP/MzP/ZjP/mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YrAGYrM2YrZmYrmWYrzGYr/2ZVAGZVM2ZVZmZVmWZVzGZV/2aAAGaAM2aAZmaAmWaAzGaA/2aqAGaqM2aqZmaqmWaqzGaq/2bVAGbVM2bVZmbVmWbVzGbV/2b/AGb/M2b/Zmb/mWb/zGb//5kAAJkAM5kAZpkAmZkAzJkA/5krAJkrM5krZpkrmZkrzJkr/5lVAJlVM5lVZplVmZlVzJlV/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llRgT0qStCjjZaF6XjzSYqoZUwu6mmmbW0qUJx4QhTmY5YOZCqpYL2KaqANPZBooVzC6hagEc160RG3GsSrrqUyupCvFlG6JK4yElvsqER2auShE/VJrUCvOrtVtnpeG6GK3marbVbZtrnnjpHmKqq6456VrbJuXpmcjsym2m5Yw0KE5WBWVrRqvH8ae29Y2ZZpJK0KdbtlswPfmyWunq0+ZPA+8pwobsNTidvmPv1KtPGb9SKMMbkCLzTxuQ/tK+fC9o68bcnqXZaPyJxeNuaZ0LrcVb4RTekizXEyjBDPOnt1MQDwPvbbQroJGHPORWulJ3POaUJ1c1djsjBhwyxtEAKgrBZqiCpebXVzWKOtddRRSdibaiATFLRl0BBDTCbEKNPbzVu//SHbULnt97IH4Tc4b/rU4pDgh48N+FIbHz6YLgp1JjnXXjMUueSUP96UALtdvnJCAeRgHm9d9xz65St6DtcBaeSt3GGJuW777bjnrvvuvOscEAA7" />
  103.         <img id="drag2" draggable="true" ondragstart="drag(event)" width="336" height="69" alt="" src="data:image/png;base64,R0lGODlhUAFFAGAAACH5BAEAAAAALAAAAABQAUUAhwAAAAAAMwAAZgAAmQAAzAAA/wArAAArMwArZgArmQArzAAr/wBVAABVMwBVZgBVmQBVzABV/wCAAACAMwCAZgCAmQCAzACA/wCqAACqMwCqZgCqmQCqzACq/wDVAADVMwDVZgDVmQDVzADV/wD/AAD/MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMrADMrMzMrZjMrmTMrzDMr/zNVADNVMzNVZjNVmTNVzDNV/zOAADOAMzOAZjOAmTOAzDOA/zOqADOqMzOqZjOqmTOqzDOq/zPVADPVMzPVZjPVmTPVzDPV/zP/ADP/MzP/ZjP/mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YrAGYrM2YrZmYrmWYrzGYr/2ZVAGZVM2ZVZmZVmWZVzGZV/2aAAGaAM2aAZmaAmWaAzGaA/2aqAGaqM2aqZmaqmWaqzGaq/2bVAGbVM2bVZmbVmWbVzGb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5QBrQeB/P0CMxi0GmNKdJzWpa85rYhGBAAAA7" />
  104.     </body>
  105. </html>
Add Comment
Please, Sign In to add comment