Advertisement
Guest User

Untitled

a guest
Dec 16th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <script src="/script.js" defer></script>
  5. <link rel="stylesheet" href="/style.css">
  6. </head>
  7. <body>
  8. <p>
  9. TO TEST SNIPERA BETA.1Q6
  10. </p>
  11. <p>
  12.  
  13.  
  14.  
  15. TWÓJ CZAS REAKCJI TO:
  16. <span id="czasReakcji">0</span>s
  17. </p>
  18.  
  19.  
  20. <div id="box"></div>
  21.  
  22.  
  23. </body>
  24. </html>
  25.  
  26.  
  27.  
  28.  
  29.  
  30. var czasboxu = Date.now;
  31. var czaskliku;
  32. var czasreakcji;
  33.  
  34. document.getElementById("box").onclick = function() {
  35. document.getElementById("box").style.display = "none";
  36. czaskliku = Date.now();
  37. czasreakcji = (czaskliku-czasboxu)/1000
  38. document.getElementById("czasReakcji").innerHTML = czasreakcji;
  39. utwurzbox();
  40.  
  41. }
  42.  
  43. function utwurzbox(){
  44.  
  45. var czas = Math.random();
  46. czas = czas * 5000;
  47.  
  48. setTimeout(function(){
  49. document.getElementById("box").style.backgroundColor = losowykolor();
  50. document.getElementById("box").style.borderRadius = losowyradius();
  51. document.getElementById("box").style.display = "block";
  52. czasboxu = Date.now();
  53. }, czas)
  54. }
  55.  
  56. utwurzbox();
  57.  
  58. function losowykolor() {
  59. var latters = '0123456789ABCDEF';
  60. var color = '#';
  61. for(var i=0;i<6;i++){
  62. color += latters[Math.floor(Math.random()*16)];
  63. }
  64. return color;
  65. }
  66.  
  67. function losowyradius() {
  68. var radius= Math.random() * 100;
  69. radius = Math.floor(radius);
  70. radius = radius+"px";
  71. return radius;
  72. }
  73.  
  74. function setTimeOut(){
  75.  
  76. var wysokosc = Math.random() * 300 + "px";
  77. var szerokosc = Math.random() * 800 + "px";
  78.  
  79. document.getElementById("box").style.marginTop = wysokosc;
  80. document.getElementById("box").style.marginLeft = szerokosc;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement