Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <style type="text/css">
- input{
- width:100px;
- height:100px;
- background-color:black;
- color:white;
- font-size:70px;
- }
- .nowy{
- width:308px;
- height:20px;
- background-color:red;
- color:yellow;
- font-size:10px;
- }
- </style>
- <title>Układanka</title>
- <script type="text/javascript">
- function wolny(x)
- {
- if (x.value=="")
- return true;
- else
- return false;
- }
- button8, button9
- function zamien2(x, y,z)
- {
- if(wolny(y))
- {
- y.value=x.value;
- x.value="";
- }
- else
- if(wolny(z))
- {
- z.value=x.value;
- x.value="";
- }
- }
- function zamien3(x, y,z,w)
- {
- if(wolny(y))
- {
- y.value=x.value;
- x.value="";
- }
- else
- if(wolny(z))
- {
- z.value=x.value;
- x.value="";
- }
- else
- if(wolny(w))
- {
- w.value=x.value;
- x.value="";
- }
- }
- function zamien4(x, y,z,w,v)
- {
- if(wolny(y))
- {
- y.value=x.value;
- x.value="";
- }
- else
- if(wolny(z))
- {
- z.value=x.value;
- x.value="";
- }
- else
- if(wolny(w))
- {
- w.value=x.value;
- x.value="";
- }
- else
- if(wolny(v))
- {
- v.value=x.value;
- x.value="";
- }
- }
- function pomieszaj()
- {
- for(k=0;k<10000;k++)
- {
- let los=Math.round(Math.random()*10);
- switch (los)
- {
- case 1: zamien2(button1,button2,button4); break;
- case 2: zamien3(button2,button1,button3,button5); break;
- case 3: zamien2(button3,button2,button6); break;
- case 4: zamien3(button4,button1,button5,button7); break;
- case 5: zamien4(button5,button2,button4,button6,button8); break;
- case 6: zamien3(button6,button3,button5,button9); break;
- case 7: zamien2(button7,button4,button8); break;
- case 8: zamien3(button8,button5,button7,button9); break;
- case 9: zamien2(button9,button6,button8); break;
- }
- }
- }
- </script>
- </head>
- <body>
- <input type="button" value="1" id="button1" onclick="zamien2(button1,button2,button4)" >
- <input type="button" value="2" id="button2" onclick="zamien3(button2,button1,button3,button5)">
- <input type="button" value="3" id="button3" onclick="zamien2(button3,button2,button6)"><br>
- <input type="button" value="4" id="button4" onclick="zamien3(button4,button1,button5,button7)">
- <input type="button" value="5" id="button5" onclick="zamien4(button5,button2,button4,button6,button8)">
- <input type="button" value="6" id="button6" onclick="zamien3(button6,button3,button5,button9)"><br>
- <input type="button" value="7" id="button7" onclick="zamien2(button7,button4,button8)">
- <input type="button" value="8" id="button8" onclick="zamien3(button8,button5,button7,button9)">
- <input type="button" value="" id="button9" onclick="zamien2(button9,button6,button8)"> <br>
- <input type="button" value="Pomieszaj" class="nowy" onclick="pomieszaj()">
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement