change
This commit is contained in:
parent
3dd31e4b35
commit
3229184d89
@ -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: [] }
|
||||
];
|
@ -12,7 +12,7 @@
|
||||
<h1>Workout</h1>
|
||||
<p>
|
||||
Today's workout muscle group:
|
||||
<select name="workout-muscle">
|
||||
<select id="workout-muscle">
|
||||
<option value="chest-triceps">Chest, Triceps</option>
|
||||
<option value="back-biceps">Back, Biceps</option>
|
||||
<option value="leg">Leg</option>
|
||||
@ -20,7 +20,7 @@
|
||||
</p>
|
||||
<p>
|
||||
Today's workout type:
|
||||
<select name="workout-type">
|
||||
<select id="workout-type">
|
||||
<option value="strength">Strength</option>
|
||||
<option value="strengthen-durance">Strength-Endurance</option>
|
||||
</select>
|
||||
|
75
main.js
75
main.js
@ -1,15 +1,42 @@
|
||||
exercises = [
|
||||
// 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]);
|
Loading…
Reference in New Issue
Block a user