Witam!
Od trzech dni staram się stworzyć aplikację internetową która ma być "czasomierzem" (w postaci "bomby"). Jednak coś w moim kodzie nie gra i nie potrafię stworzyć właściwego rozwiązania. Jeśli ktoś mógł by mi pomóc byłbym bardzo wdzięczny.
Oto mój kod:
(wszystko zamieściłem w jednym pliku: js,html,css)
<!DOCTYPE html>
<html>
<head>
<title>Bomb app.</title>
<meta charset="utf-8" />
<meta type="keywords" value="apps,bomb,app"/>
<link rel="shortcut icon" href="favicon.png">
</head>
<style>
#pole
{
font-family: Verdana;
width: 30px;
padding: 2px;
}
#pole1
{
font-family: Verdana;
width: 30px;
padding: 2px;
}
#pole2
{
font-family: Verdana;
width: 30px;
padding: 2px;
}
#przycisk1
{
display: block;
font-family: Fantasy;
width 800px;
height 400px;
backgorund: red;
color: black;
font-size: 20px;
cursor: pointer;
}
#przycisk2
{
display: block;
font-family: Fantasy;
width 800px;
height 400px;
backgorund: red;
color: black;
font-size: 20px;
cursor: pointer;
}
h1
{
margin-left: auto;
margin-right: auto;
padding: 20px;
font-family: Fantasy;
color: red;
background-color: black;
}
h2
{
font-family: Fantasy;
letter-spacing: 3px;
}
#audiopoint
{
align: left;
}
</style>
<script type="text/javascript">
var godz;
var min;
var sek;
var plant;
function SoundOn()
{
document.getElementById("audio").innerHTML = "<img src=\"audio.png\" id=\"audiopoint\" />";
document.getElementById("onoffdiv").innerHTML = "<input type=\"submit\" value=\"on/off\" id=\"onoff\" onclick=\"SoundOff()\" style=\"cursor: pointer;\" />"
}
function SoundOff()
{
document.getElementById("audio").innerHTML = "<img src=\"audiooff.png\" id=\"audiopoint\" />";
document.getElementById("onoffdiv").innerHTML = "<input type=\"submit\" value=\"on/off\" id=\"onoff\" onclick=\"SoundOn()\" style=\"cursor: pointer;\" />"
}
function DefuseBomb()
{
document.getElementById("timer").innerHTML = "00:00:00";
}
function Odliczanie()
{
document.getElementById("timer").innerHTML = godz+":"+min+":"+sek;
if(plant==true)
{
sek=sek-1;
if(sek==0)
{
min=min-1;
sek=sek+59;
if(min==0)
{
godz=godz-1;
min=min+59;
if(godz==0)
{
document.getElementById("timer").innerHTML = "00:"+min+":"+sek;
}
}
}
if((godz==0)&&(min==0)&&(sek==0))
{
Boom();
}
}
setTimeOut("Odliczanie()", 1000);
}
function Boom()
{
document.getElementById("container").innerHTML = "<source src=\"boom.mp4\" type=\"video/mp4\" codecs=\"avc1.42E01E, mp4a.40.2\">"
}
function PlantBomb()
{
godz = h;
min = m;
sek = s;
plant = planted;
var planted = false;
var h = document.getElementById("pole").value;
if(h<10) h = "0"+h;
if(h==0) h = "00"
var m = document.getElementById("pole1").value;
if(m<10) m = "0"+m;
if(m==0) m = "00"
var s = document.getElementById("pole2").value;
if(s<10) s = "0"+s;
if(s==0) s = "00"
if((h<0)||(m<0)||(s<0))document.getElementById("error").innerHTML = "It isn't good value! Try Again!";
if((h>=0)&&(m>=0)&&(s>=0)&&(h<=99)&&(m<=59)&&(s<=59))
{
document.getElementById("timer").innerHTML = h+":"+m+":"+s;
document.getElementById("error").innerHTML = "";
planted = true;
Odliczanie();
}
if((h>99)||(m>59)||(s>59))document.getElementById("error").innerHTML = "It isn't good value! Try Again!";
if((h==0)&&(m==0)&&(s==0))document.getElementById("error").innerHTML = "It isn't value! Try Again!";
}
</script>
<body bgcolor="gray">
<div id="container" align="center">
<h2 align="center">PLANT YOUR BOMB!<h2>
<br />
<br />
<br />
<input type="text" id="pole" />h
<input type="text" id="pole1" />m
<input type="text" id="pole2" />s
<br />
<br />
<input type="submit" value="Start!" id="przycisk1" onclick="PlantBomb()" />
<div>
<h1 align="center" id="timer">00:00:00</h1>
</div>
<div id="error">
</div>
<br />
<br />
<br />
<input type="submit" value="defuse the bomb" id="przycisk2" onclick="DefuseBomb()">
</div>
<div id="audio">
<img src="audio.png" id="audiopoint" />
</div>
<div id="onoffdiv">
<input type="submit" value="on/off" id="onoff" onclick="SoundOff()" style="cursor: pointer;" />
</div>
</body>
</html>
| Z góry dziękuję! |