I started testing with this HTML:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body onload="principal();">
<audio id="audio">
<source src="arquivo1.mp3" type="audio/mp3" />
</audio>
<form name="form">
<input type="text" name="cronometro" id="cron" value="00:00:00" />
<br />
<button type="button" onclick="setInterval('tempo()',983);return false;">Cronômetro</button>
<br />
<button onclick="clearTimeout(teste)">Zerar</button>
<br />
<div class="marginTop col-md-12 text-center center-block">
<div class="col-md-4 col-md-offset-4">
<div class="input-group">
<span class="input-group-addon">Min</span>
<input id="minutos" type="number" min="0" max="59" class="form-control" placeholder="Minutos">
</div>
<div class="input-group">
<span class="input-group-addon">Seg</span>
<input id="segundos" type="number" min="0" max="59" class="form-control" placeholder="Segundos">
<input id="pause" type="hidden" value="0" class="form-control"> <br />
</div>
</div>
</div>
<button type="submit" id="marcarTempo">marcar</button>
<br />
<button type="reset" id="parar" onclick="pause()">Parar</button>
<br />
</form>
<script type="text/javascript" src="script.js"></script>
</body>
</html>'
And this CSS:
*{
margin:0;
padding:0;
}
body{
background:#CCC;
color:#FFF;
font-family:Arial, Helvetica, sans-serif;
text-align:center;
}
#topo{
background:#069;
height:100px;
line-height:100px;
border-bottom:2px solid #006;
}
h2 a{
color:#069;
text-decoration:none;
}
h2 a:hover{
color:#006;
}
input{
background:#000;
width:600px;
height:200px;
line-height:200px;
font-size:150px;
border:none;
color:#ffffff;
border-radius: 25px;
border: 2px solid #a1a1a1;
}
input#minutos.form-control{
font-size:14px;
width: 100px;
height: 50px;
padding-left: 40px;
}
input#segundos.form-control{
font-size:14px;
width: 100px;
height: 50px;
padding-left: 40px;
}
div.input-group{
width: 50px;
border-bottom-width: 1px;
}
div.col-md-4.col-md-offset-4{
padding-right: 650px;
}
div.marginTop.col-md-12.text-center.center-block{
padding-left: 650px;
}
JavaScript:
var segundo = 0+"0";
var minuto = 0+"0";
var hora = 0+"0";
var audio = document.getElementById('audio');
function play(){
audio.play();
}
function tempo(){
if (segundo < 59){
segundo++
if(segundo < 10){segundo = "0"+segundo}
}else
if(segundo == 59 && minuto < 59){
segundo = 0+"0";
minuto++;
if(minuto < 10){minuto = "0"+minuto}
}
if(minuto == 59 && segundo == 59 && hora < 23){
segundo = 0+"0";
minuto = 0+"0";
hora++;
if(hora < 10){hora = "0"+hora}
}else
if(minuto == 59 && segundo == 59 && hora == 23){
segundo = 0+"0";
minuto = 0+"0";
hora = 0+"0";
}
form.cronometro.value = hora +":"+ minuto +":"+ segundo
if(segundo == 5){
play();
}
function pause() {
audio.pause();
}
}
Thanks in advance!