58 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <!DOCTYPE html>
 | |
| <html>
 | |
|   <head>
 | |
|     <script>
 | |
|       var audio = new Audio('notification.mp3');
 | |
|       var repetitions = 0;
 | |
| 
 | |
|       var run = function() {
 | |
|           var resetPoint = parseInt(document.getElementById("resetpoint").value);
 | |
| 
 | |
|           var previous = document.getElementById("clock").innerHTML;
 | |
|           var next = 1 + parseInt(previous);
 | |
|           if(next > resetPoint) {
 | |
|               audio.play();
 | |
|               next = 1;
 | |
|               repetitions += 1;
 | |
|           }
 | |
|           document.getElementById("clock").innerHTML = next;
 | |
|           document.getElementById("reps").innerHTML = repetitions;
 | |
| 
 | |
|           var maxreps = parseInt(document.getElementById("ripetizioni").value);
 | |
|           if(repetitions >= maxreps){
 | |
|               repetitions = 0;
 | |
|               stopSound();
 | |
|           }
 | |
| 
 | |
|       };
 | |
|       
 | |
|       var x = null;
 | |
| 
 | |
|       var stopSound = function (){
 | |
|           if (x != null) clearInterval(x);
 | |
|           repetitions = 0;
 | |
|           x = null;
 | |
|       };
 | |
| 
 | |
|       var startSound = function (){
 | |
|           document.getElementById("clock").innerHTML = 1;
 | |
|           document.getElementById("reps").innerHTML = 0;
 | |
|           if(x == null) x = setInterval(run, 1000);
 | |
|       }
 | |
|     </script>
 | |
|   </head>
 | |
|   <body>
 | |
|     <p id="rep">REP: <span id="reps">0</span> | TIME: <span id="clock">1</span></p>
 | |
| 
 | |
|     <label for="resetpoint">tempo (fino ad un minuto):</label>
 | |
|     <input type="number" id="resetpoint" name="resetpoint" min="1" max="60">
 | |
| 
 | |
|     <label for="ripetizioni">ripetizioni (fino a quaranta):</label>
 | |
|     <input type="number" id="ripetizioni" name="ripetizioni" min="1" max="40">
 | |
|     <br>
 | |
| 
 | |
|     <input id = "startsound" type = "button" value = "FAMMI PARTIRE" onclick = "startSound();" />
 | |
|     <input id = "stopsound" type = "button" value = "FERMAMI" onclick = "stopSound();" />
 | |
|   </body>
 | |
| </html>
 |