This commit is contained in:
parent
db4b93ba6f
commit
b46ae02bdf
44
main.js
44
main.js
@ -40,6 +40,7 @@ function setExercises() {
|
|||||||
exerciseList.innerHTML = ''
|
exerciseList.innerHTML = ''
|
||||||
for (let i = 0; i < exercises[t].length; i++) {
|
for (let i = 0; i < exercises[t].length; i++) {
|
||||||
var li = document.createElement("li");
|
var li = document.createElement("li");
|
||||||
|
var upDownDiv = document.createElement("div");
|
||||||
// Up Button
|
// Up Button
|
||||||
var upButton = document.createElement("button");
|
var upButton = document.createElement("button");
|
||||||
upButton.textContent = "▲"
|
upButton.textContent = "▲"
|
||||||
@ -49,7 +50,7 @@ function setExercises() {
|
|||||||
setExercises(exercises[t]);
|
setExercises(exercises[t]);
|
||||||
localStorage.setItem("exercises", JSON.stringify(exercises));
|
localStorage.setItem("exercises", JSON.stringify(exercises));
|
||||||
};
|
};
|
||||||
li.appendChild(upButton);
|
upDownDiv.appendChild(upButton);
|
||||||
// Down Button
|
// Down Button
|
||||||
var downButton = document.createElement("button");
|
var downButton = document.createElement("button");
|
||||||
downButton.textContent = "▼"
|
downButton.textContent = "▼"
|
||||||
@ -59,8 +60,10 @@ function setExercises() {
|
|||||||
setExercises(exercises[t]);
|
setExercises(exercises[t]);
|
||||||
localStorage.setItem("exercises", JSON.stringify(exercises));
|
localStorage.setItem("exercises", JSON.stringify(exercises));
|
||||||
};
|
};
|
||||||
li.appendChild(downButton);
|
upDownDiv.appendChild(downButton);
|
||||||
li.appendChild(document.createTextNode("Exercise "));
|
li.appendChild(upDownDiv);
|
||||||
|
var exerciseSelectorDiv = document.createElement("div");
|
||||||
|
exerciseSelectorDiv.appendChild(document.createTextNode("Exercise "));
|
||||||
// Select Exercise Type
|
// Select Exercise Type
|
||||||
var exType = document.createElement("select");
|
var exType = document.createElement("select");
|
||||||
exType.onchange = updateExercises;
|
exType.onchange = updateExercises;
|
||||||
@ -68,7 +71,7 @@ function setExercises() {
|
|||||||
exType.add(new Option(exercise.name, exercise.name));
|
exType.add(new Option(exercise.name, exercise.name));
|
||||||
});
|
});
|
||||||
exType.value = exercises[t][i].exerciseType
|
exType.value = exercises[t][i].exerciseType
|
||||||
li.appendChild(exType);
|
exerciseSelectorDiv.appendChild(exType);
|
||||||
// Select Repetition Type
|
// Select Repetition Type
|
||||||
var repType = document.createElement("select");
|
var repType = document.createElement("select");
|
||||||
repetitionTypes.forEach(repetitionType => {
|
repetitionTypes.forEach(repetitionType => {
|
||||||
@ -76,19 +79,24 @@ function setExercises() {
|
|||||||
});
|
});
|
||||||
repType.onchange = updateExercises;
|
repType.onchange = updateExercises;
|
||||||
repType.value = exercises[t][i].repetitionType
|
repType.value = exercises[t][i].repetitionType
|
||||||
li.appendChild(repType);
|
exerciseSelectorDiv.appendChild(repType);
|
||||||
li.appendChild(document.createTextNode("Reps done: "));
|
li.appendChild(exerciseSelectorDiv);
|
||||||
|
var repDiv = document.createElement("div");
|
||||||
|
repDiv.appendChild(document.createTextNode("Reps done: "));
|
||||||
var reps = document.createElement("input");
|
var reps = document.createElement("input");
|
||||||
reps.setAttribute("type", "number");
|
reps.setAttribute("type", "number");
|
||||||
reps.value = exercises[t][i].reps;
|
reps.value = exercises[t][i].reps;
|
||||||
reps.onchange = updateExercises;
|
reps.onchange = updateExercises;
|
||||||
li.appendChild(reps);
|
repDiv.appendChild(reps);
|
||||||
li.appendChild(document.createTextNode("Weight done: "));
|
li.appendChild(repDiv);
|
||||||
|
var weightDiv = document.createElement("div");
|
||||||
|
weightDiv.appendChild(document.createTextNode("Weight done: "));
|
||||||
var weight = document.createElement("input");
|
var weight = document.createElement("input");
|
||||||
weight.setAttribute("type", "number");
|
weight.setAttribute("type", "number");
|
||||||
weight.value = exercises[t][i].weight;
|
weight.value = exercises[t][i].weight;
|
||||||
weight.onchange = updateExercises;
|
weight.onchange = updateExercises;
|
||||||
li.appendChild(weight);
|
weightDiv.appendChild(weight);
|
||||||
|
li.appendChild(weightDiv);
|
||||||
// Delete Button
|
// Delete Button
|
||||||
var deleteButton = document.createElement("button");
|
var deleteButton = document.createElement("button");
|
||||||
deleteButton.textContent = "Delete"
|
deleteButton.textContent = "Delete"
|
||||||
@ -193,12 +201,14 @@ setExercises(exercises[t]);
|
|||||||
var body = document.querySelector("body");
|
var body = document.querySelector("body");
|
||||||
var pre = document.createElement("pre");
|
var pre = document.createElement("pre");
|
||||||
const jsn = JSON.parse(localStorage.getItem("exercises"));
|
const jsn = JSON.parse(localStorage.getItem("exercises"));
|
||||||
var s = "";
|
if (jsn != null) {
|
||||||
for (let [date, value] of Object.entries(jsn).sort().reverse()) {
|
var s = "";
|
||||||
s += date + "\n";
|
for (let [date, value] of Object.entries(jsn).sort().reverse()) {
|
||||||
for (let exercise of value) {
|
s += date + "\n";
|
||||||
s += " " + exercise.exerciseType + ": " + exercise.weight + "kg x " + exercise.reps + " of " + exercise.repetitionType + "\n";
|
for (let exercise of value) {
|
||||||
|
s += " " + exercise.exerciseType + ": " + exercise.weight + "kg x " + exercise.reps + " of " + exercise.repetitionType + "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
pre.textContent = s;
|
||||||
pre.textContent = s;
|
body.appendChild(pre);
|
||||||
body.appendChild(pre);
|
}
|
Loading…
Reference in New Issue
Block a user