diff --git a/exerciseTypes.js b/exerciseTypes.js
index a8a0bfb..e436846 100644
--- a/exerciseTypes.js
+++ b/exerciseTypes.js
@@ -12,25 +12,23 @@ var exerciseTypes = [
{ name: "Bench Press", tags: [] },
{ name: "Bench Press Dumbbell", tags: [] },
{ name: "Butterfly", tags: [] },
- /*
- "Incline Bench Press",
- "Incline Bench Press Dumbbell",
- "Leg Press",
- "Squat",
- "Leg Curl",
- "Leg Extension",
- "Dips",
- "Under Grip Pull Up",
- "Over Grip Pull Up",
- "Cable Biceps Curl",
- "Supported Biceps Curl",
- "Cable Triceps",
- "Deadlift",
- "Standing Calf Raises",
- "Face Pull",
- "Machine Shoulder Press",
- "Dumbbell Shoulder Press",
- "Machine Bench Press",
- "21s"
- */
+ { name: "Incline Bench Press", tags: [] },
+ { name: "Incline Bench Press Dumbbell", tags: [] },
+ { name: "Leg Press", tags: [] },
+ { name: "Squat", tags: [] },
+ { name: "Leg Curl", tags: [] },
+ { name: "Leg Extension", tags: [] },
+ { name: "Dips", tags: [] },
+ { name: "Under Grip Pull Up", tags: [] },
+ { name: "Over Grip Pull Up", tags: [] },
+ { name: "Cable Biceps Curl", tags: [] },
+ { name: "Supported Biceps Curl", tags: [] },
+ { name: "Cable Triceps", tags: [] },
+ { name: "Deadlift", tags: [] },
+ { name: "Standing Calf Raises", tags: [] },
+ { name: "Face Pull", tags: [] },
+ { name: "Machine Shoulder Press", tags: [] },
+ { name: "Dumbbell Shoulder Press", tags: [] },
+ { name: "Machine Bench Press", tags: [] },
+ { name: "21s", tags: [] }
];
\ No newline at end of file
diff --git a/index.html b/index.html
index 3346073..db04790 100644
--- a/index.html
+++ b/index.html
@@ -12,7 +12,7 @@
Workout
Today's workout muscle group:
-
Today's workout type:
-
+
diff --git a/main.js b/main.js
index 059a7a1..79a0ec6 100644
--- a/main.js
+++ b/main.js
@@ -1,15 +1,42 @@
-exercises = [
- { exerciseType: exerciseTypes[0], repetitionType: "2-4", reps: "", weight: "2" },
- { exerciseType: exerciseTypes[0], repetitionType: "2-4", reps: "3", weight: "" }
-]
+// for debug purposes
+const t = today()
+var exercises = {
+ "2021-10-19": [
+ { exerciseType: exerciseTypes[0], repetitionType: "2-4", reps: "", weight: "2" },
+ { exerciseType: exerciseTypes[0], repetitionType: "2-4", reps: "3", weight: "" }
+ ]
+}
+
+function updateExercises() {
+ var exerciseList = document.querySelectorAll("#exercise-list > li");
+ exercises[t] = [];
+ for (const element of exerciseList) {
+ exercises[t].push({
+ exerciseType: element.childNodes[3].value,
+ repetitionType: element.childNodes[4].value,
+ reps: element.childNodes[6].value,
+ weight: element.childNodes[8].value
+ });
+ }
+}
+
var exerciseList = document.getElementById("exercise-list");
function setExercises(exercises) {
exerciseList.innerHTML = ''
exercises.forEach(element => {
var li = document.createElement("li");
+ var upButton = document.createElement("button");
+ upButton.textContent = "▲"
+ upButton.id = "up";
+ li.appendChild(upButton);
+ var downButton = document.createElement("button");
+ downButton.textContent = "▼"
+ downButton.id = "down";
+ li.appendChild(downButton);
li.appendChild(document.createTextNode("Exercise "));
var exType = document.createElement("select");
+ exType.onchange = updateExercises;
exerciseTypes.forEach(exercise => {
exType.add(new Option(exercise.name, exercise.name));
});
@@ -18,35 +45,65 @@ function setExercises(exercises) {
repetitionTypes.forEach(repetitionType => {
repType.add(new Option(repetitionType, repetitionType));
});
+ repType.onchange = updateExercises;
li.appendChild(repType);
li.appendChild(document.createTextNode("Reps done: "));
var reps = document.createElement("input");
reps.setAttribute("type", "number");
reps.value = element.reps;
+ reps.onchange = updateExercises;
li.appendChild(reps);
li.appendChild(document.createTextNode("Weight done: "));
var weight = document.createElement("input");
weight.setAttribute("type", "number");
weight.value = element.weight;
+ weight.onchange = updateExercises;
li.appendChild(weight);
+ var deleteButton = document.createElement("button");
+ deleteButton.textContent = "Delete"
+ deleteButton.id = "delete-button";
+ li.appendChild(deleteButton);
exerciseList.appendChild(li);
});
}
-function exercisesEdited() {
- document.querySelectorAll("#exercise-list > li > input").forEach(element => {
- if (element.value != "" && element.value != null) {
- console.log("b");
+function exercisesEdited(exercises) {
+ for (const element of exercises) {
+ if (element.reps != "" && element.reps != null) {
+ return true;
}
- });
+ if (element.weight != "" && element.weight != null) {
+ return true;
+ }
+ };
return false;
}
+function today() {
+ d = new Date;
+ return d.toISOString().split('T')[0];
+}
+
var addExerciseButton = document.getElementById("add-exercise");
addExerciseButton.onclick = () => {
exercises.push({ exerciseType: "", repetitionType: "", reps: "", weight: "" });
setExercises(exercises);
}
-setExercises(exercises);
-console.log(exercisesEdited());
+function f() {
+ if (!exercisesEdited(exercises[t])) {
+ console.log("fish");
+ exercises[t] = [
+ { exerciseType: exerciseTypes[0], repetitionType: "2-4", reps: "", weight: "2" },
+ { exerciseType: exerciseTypes[0], repetitionType: "2-4", reps: "3", weight: "" }
+ ];
+ setExercises(exercises[t]);
+ }
+}
+
+var muscleGroupSelector = document.getElementById("workout-muscle");
+muscleGroupSelector.onchange = f;
+var workoutTypeSelector = document.getElementById("workout-type");
+workoutTypeSelector.onchange = f;
+
+setExercises(exercises[t]);
\ No newline at end of file