Skip to content

Instantly share code, notes, and snippets.

@samm81
Last active August 29, 2015 14:02
Show Gist options
  • Save samm81/5590e79ff7d4c712a9f6 to your computer and use it in GitHub Desktop.
Save samm81/5590e79ff7d4c712a9f6 to your computer and use it in GitHub Desktop.
<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