Last active
August 29, 2015 14:02
-
-
Save samm81/5590e79ff7d4c712a9f6 to your computer and use it in GitHub Desktop.
timer for the tabata training style: http://i.kinja-img.com/gawker-media/image/upload/eg9b9nrsiwkpe3niudv7.jpg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body onload="go(1, true, 0)"> | |
<div style="text-align:center; padding-top:200px; font-size:40px; line-height:80px;"> | |
<div id="timer"></div> | |
<div id="exercise"></div> | |
</div> | |
</body> | |
<script> | |
var exercises = ["Preparing", "Running in Place", "Resting (Jumping Jacks Next)", "Jumping Jacks", "Resting (Jumping Squats Next)", "Jumping Squats", "Resting (Push Ups Next)", "Push Ups", "Resting (Bicycle Crunch Next)", "Bicycle Crunch", "Resting (Burpees Next)", "Burpees", "Resting (Mason Twist Next)", "Mason Twist", "Resting (Mountain Climbers Next)", "Mountain Climbers", "All Done!"]; | |
var timer = document.getElementById("timer"); | |
var exercise = document.getElementById("exercise"); | |
function go(time, resting, exerciseIndex) { | |
exercise.innerText = exercises[exerciseIndex]; | |
timer.innerText = time; | |
if(!resting) { | |
if(time < 20) { | |
setTimeout(function() { go(time + 1, resting, exerciseIndex) }, 1000); | |
} else { | |
setTimeout(function() { go(1, !resting, exerciseIndex + 1) }, 1000); | |
} | |
} else { | |
if(time < 10) { | |
setTimeout(function() { go(time + 1, resting, exerciseIndex) }, 1000); | |
} else { | |
setTimeout(function() { go(1, !resting, exerciseIndex + 1) }, 1000); | |
} | |
} | |
} | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment