diff --git a/index.html b/index.html index c66038d..4749309 100644 --- a/index.html +++ b/index.html @@ -11,24 +11,16 @@

Workout

-

- Today's workout muscle group: - -

-

- Today's workout type: - -

-

- Today's exercises: +

+

Load Predefined Workout

+ + + + + +
+

Today's Workout

-

diff --git a/main.js b/main.js index 94cb52f..b60637c 100644 --- a/main.js +++ b/main.js @@ -21,6 +21,10 @@ function updateExercises() { weight: element.childNodes[8].value }); } + if (exercisesEdited(exercises[t])) { + var workoutSelectionArea = document.getElementById("workout-selection-area"); + workoutSelectionArea.innerHTML = ''; + } localStorage.setItem("exercises", JSON.stringify(exercises)); } @@ -122,22 +126,17 @@ addExerciseButton.onclick = () => { setExercises(exercises); } -var muscleGroupSelector = document.getElementById("workout-muscle"); -muscleGroupSelector.onchange = loadPredefinedWorkouts; -var workoutTypeSelector = document.getElementById("workout-type"); -workoutTypeSelector.onchange = loadPredefinedWorkouts; - -function loadPredefinedWorkouts() { +function loadPredefinedWorkouts(workoutType) { if (!exercisesEdited(exercises[t])) { - switch ((muscleGroupSelector.value, workoutTypeSelector.value)) { - case ("leg", "strength"): + switch (workoutType) { + case ("load-leg-strength"): exercises[t] = [ { exerciseType: "Squat", repetitionType: "2-4", reps: "", weight: "" }, { exerciseType: "Leg Press", repetitionType: "2-4", reps: "", weight: "" }, { exerciseType: "Deadlift", repetitionType: "2-4", reps: "", weight: "" } ]; break; - case ("back-biceps", "strength-endurance"): + case ("load-back-hyp"): exercises[t] = [ { exerciseType: "One Arm Dumbbell Row", repetitionType: "3-5", reps: "", weight: "" }, { exerciseType: "Lat Pulldown Wide", repetitionType: "2-4", reps: "", weight: "" }, @@ -147,7 +146,17 @@ function loadPredefinedWorkouts() { { exerciseType: "Biceps Curl", repetitionType: "pyramid", reps: "", weight: "" } ]; break; - case ("leg", "strength-endurance"): + case ("load-body-strength"): + exercises[t] = [ + { exerciseType: "Bench Press", repetitionType: "2-4", reps: "", weight: "" }, + { exerciseType: "Cable Row w/ Over Grip", repetitionType: "2-4", reps: "", weight: "" }, + { exerciseType: "Dips", repetitionType: "3-5", reps: "", weight: "" }, + { exerciseType: "Under Grip Pull Up", repetitionType: "3-5", reps: "", weight: "" }, + { exerciseType: "Hammer Curls", repetitionType: "3-5", reps: "", weight: "" }, + { exerciseType: "Supported Biceps Curl", repetitionType: "3-5", reps: "", weight: "" } + ]; + break; + case ("load-leg-hyp"): exercises[t] = [ { exerciseType: "Leg Press", repetitionType: "5-8", reps: "", weight: "" }, { exerciseType: "Squat", repetitionType: "8-12", reps: "", weight: "" }, @@ -156,7 +165,7 @@ function loadPredefinedWorkouts() { { exerciseType: "Standing Calf Raises", repetitionType: "8-12", reps: "", weight: "" } ]; break; - case ("chest-triceps", "strength-endurance"): + case ("load-chest-hyp"): exercises[t] = [ { exerciseType: "Bench Press", repetitionType: "3-5", reps: "", weight: "" }, { exerciseType: "Incline Bench Press", repetitionType: "5-8", reps: "", weight: "" }, @@ -174,13 +183,18 @@ function loadPredefinedWorkouts() { } } +var predefinedWorkoutButtons = document.querySelectorAll("button.loadPredefinedWorkout"); +for (let button of predefinedWorkoutButtons) { + button.onclick = () => { loadPredefinedWorkouts(button.id); } +} + setExercises(exercises[t]); var body = document.querySelector("body"); var pre = document.createElement("pre"); const jsn = JSON.parse(localStorage.getItem("exercises")); var s = ""; -for (let [date, value] of Object.entries(jsn)) { +for (let [date, value] of Object.entries(jsn).sort().reverse()) { s += date + "\n"; for (let exercise of value) { s += " " + exercise.exerciseType + ": " + exercise.weight + "kg x " + exercise.reps + " of " + exercise.repetitionType + "\n";