peppe workout
This commit is contained in:
parent
6860b79804
commit
06b111df21
BIN
extra/peppe_workout/notification.mp3
Normal file
BIN
extra/peppe_workout/notification.mp3
Normal file
Binary file not shown.
57
extra/peppe_workout/peppe_workout.html
Normal file
57
extra/peppe_workout/peppe_workout.html
Normal file
@ -0,0 +1,57 @@
|
||||
<!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>
|
Loading…
Reference in New Issue
Block a user