Advertisement
MrSliff

Reaktionstester

Oct 6th, 2016
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5.73 KB | None | 0 0
  1. <html>
  2.    
  3.    <head>
  4.    
  5.    
  6.        <link href='https://fonts.googleapis.com/css?family=Roboto:400italic' rel='stylesheet' type='text/css'>
  7.        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  8.        
  9.  
  10.        <style type="text/css">
  11.            
  12.            #btn_start {
  13.                
  14.                margin:auto;
  15.                height 20px;
  16.                width: 50px;
  17.                
  18.            }
  19.  
  20.            #kopfzeile {
  21.                
  22.              
  23.                height:200px;
  24.                float:left;
  25.                margin-right: 500px;
  26.                
  27.            }
  28.            
  29.            #spielfeld {
  30.                
  31.                float:left;
  32.                height:800px;
  33.                width:800px;              
  34.                background-color: azure;
  35.                border-style: solid;
  36.                border-color: dimgrey;
  37.                
  38.            }
  39.            
  40.            #kreis {
  41.                
  42.                width: 100px;
  43.                height:100px;
  44.                border-radius: 50px;
  45.                background-color: blanchedalmond;
  46.                display: none;
  47.                position: absolute;
  48.                top: 0px;
  49.                left: 0px;
  50.  
  51.  
  52.  
  53.                
  54.            }
  55.            
  56.            #quadrat {
  57.                
  58.                width: 100px;
  59.                height:100px;
  60.                background-color: darkviolet;
  61.                display: none;
  62.                position: absolute;
  63.                top: 0px;
  64.                left: 0px;
  65.                
  66.            }
  67.            
  68.            #dreieck {
  69.                
  70.                width: 0px;
  71.                height: 0px;
  72.                -webkit-transform:rotate(360deg);
  73.                border-style: solid;
  74.                border-width: 0 50px 100px 50px;
  75.                border-color: transparent transparent #35b19b transparent;
  76.                display: none;
  77.                position: absolute;
  78.                top: 0px;
  79.                left: 0px;
  80.            }
  81.            
  82.        </style>
  83.            
  84.    
  85.    </head>
  86.    
  87.    <body style="background-color:#90C3D4;">
  88.          
  89.          <div id="kopfzeile">
  90.  
  91.              <h1>Test your Reactions!</h1>
  92.  
  93.              <p>Click on the boxes and circles as quickly as you can!</p>
  94.  
  95.              <p><b id="zeit">Your time: </b></p>
  96.              
  97.              <p><button id="btn_start">Start</button></p>
  98.  
  99.              
  100.  
  101.          </div>
  102.          
  103.          <div id="spielfeld">
  104.              
  105.  
  106.              
  107.              <div id="kreis"></div>
  108.              
  109.              <div id="quadrat"></div>
  110.              
  111.              <div id="dreieck"></div>
  112.              
  113.              
  114.              
  115.          </div>
  116.  
  117.          <script type="text/javascript">
  118.              
  119.              var formen = new Array("kreis","quadrat","dreieck");
  120.              var min = 0, max = 2;
  121.              
  122.              function position(form) {
  123.                  
  124.                  var y = Math.floor(Math.random() * 800);
  125.                  
  126.                  var x = Math.floor(Math.random() * 800);
  127.                  
  128.                  document.getElementById(form).style.top = y;
  129.                  document.getElementById(form).style.left = x;
  130.                  
  131.                  document.getElementById(form).style.display = "block";
  132.                  
  133.                  
  134.                  
  135.              }
  136.              
  137.              function randomFormen (){
  138.                  
  139.                  var num = Math.floor(Math.random() * 3);
  140.                  return num;
  141.              }
  142.              
  143.              
  144.              function reaction() {
  145.                  
  146.                  var zeit = new Date().getTime();
  147.                  var i = 0;
  148.                  
  149.                  
  150.                  
  151.                  
  152.                  while(i < 10) {
  153.                    
  154.                    var zufall = randomFormen();
  155.                    
  156.                    
  157.                    var anzeigen = position(formen[zufall]);
  158.                    
  159.                     /////////////////////////////////////////////////////////////                
  160.                     //
  161.                     //             HIER STEHENGEBLIEBEN
  162.                     //            
  163.                     /////////////////////////////////////////////////////////////
  164.                    
  165.                    
  166.                      
  167.                     document.getElementById(formen[zufall]).onclick = function() {                    
  168.                         document.getElementById(formen[zufall]).style.display = "none";
  169.                         i++;
  170.                      
  171.                        
  172.                     }
  173.                    
  174.  
  175.                        
  176.                    
  177.                 }
  178.                
  179.                 zeit = (zeit - new Date().getTime()) / 1000;
  180.                
  181.                 return(zeit);
  182.             }
  183.            
  184.             document.getElementById("btn_start").onclick = function() {
  185.                
  186.                 document.getElementById("zeit").innerHTML = "GO!";
  187.                
  188.                 document.getElementById("kreis").style.display = "none";                    
  189.                 document.getElementById("quadrat").style.display = "none";                    
  190.                 document.getElementById("dreieck").style.display = "none";
  191.                
  192.                
  193.                
  194.                 var spielzeit = reaction();
  195.                
  196.                 document.getElementById("zeit").innerHTML = document.getElementById("zeit").innerHTML + spielzeit;
  197.                
  198.             }
  199.            
  200.            
  201.        
  202.         </script>
  203.  
  204.    </body>
  205.    
  206. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement