]> git.lizzy.rs Git - html-collection.git/blob - guessing.html
Add LICENSE
[html-collection.git] / guessing.html
1 <html><head>
2         <meta charset="utf-8">
3         <style type="text/css"> 
4                 body { background-color:lightyellow; }
5                 div  { width:15em; height: 6em; padding:1em;margin:1em;background-color:lightgreen; text-align:center;}
6                 div.blauer {background-color:lightblue;}
7         </style>
8         <script>
9         
10         var a = [];
11         var t = [];
12         var b=[1,2,3,4,5];
13         setTimeout(setzen,100);
14         function setzen(){
15         document.getElementById('punkte').value=0;
16         a=[3,2,5,1,4];
17         document.getElementById('b1').innerHTML=a[0];
18         document.getElementById('b2').innerHTML=a[1];
19         document.getElementById('b3').innerHTML=a[2];
20         document.getElementById('b4').innerHTML=a[3];
21         document.getElementById('b5').innerHTML=a[4];
22                 }
23         function controll(){
24         document.getElementById('b1').innerHTML=a[0];
25         document.getElementById('b2').innerHTML=a[1];
26         document.getElementById('b3').innerHTML=a[2];
27         document.getElementById('b4').innerHTML=a[3];
28         document.getElementById('b5').innerHTML=a[4];
29         
30
31         if(a.join() == b.join()){
32                         window.alert("DONE! Bad Points: "+document.getElementById('punkte').value);
33                         location.reload();
34                         }
35                 }
36                 function change(number){
37                 for(i=0;i < number;i++){
38                         t.push(a.shift());
39                         }
40                 for(i=0;i < number;i++){
41                         a.unshift(t.shift());
42                         }
43                 var c = parseInt(document.getElementById('punkte').value);
44                 document.getElementById('punkte').value = c + 1;
45                 controll();     
46                         }
47 </script>
48 </head>
49 <body>
50         <h1>Guessing Game</h1>
51         <p>Switch the nubers till they are in the correct order!</p>
52         <div style="background-color:pink">
53                 <button id="b1" onclick="change(1)"></button>
54                 <button id="b2" onclick="change(2)"></button>
55                 <button id="b3"onclick="change(3)"></button>
56                 <button id="b4"onclick="change(4)"></button>
57                 <button id="b5"onclick="change(5)"></button>
58         </div>
59         <div>
60                 <h3>BAD POINTS</h3>
61         <input type="number"readonly id="punkte" value="0" />
62         </div>
63 </body>
64
65 </html>
66