Commit e2d7b5dd authored by ibooking-sigurd's avatar ibooking-sigurd
Browse files

Last minor code smells for diet.js, diets.js and myathlethes.js.

parent efaedc9a
......@@ -318,12 +318,12 @@ async function retrieveDiet(id) {
if (dietData["owner"] == currentUser.url) {
editDietButton.classList.remove("hide");
editDietButton.addEventListener("click", handleEditDietButtonClick);
deleteDietButton.addEventListener("click", (async (delId) => await deleteDiet(delId)).bind(undefined, delId));
okDietButton.addEventListener("click", (async (okId) => await updateDiet(okId)).bind(undefined, okId));
postCommentButton.addEventListener("click", (async (postId) => await createComment(postId)).bind(undefined, postId));
deleteDietButton.addEventListener("click", (async (delId) => deleteDiet(delId)).bind(undefined, delId));
okDietButton.addEventListener("click", (async (okId) => updateDiet(okId)).bind(undefined, okId));
postCommentButton.addEventListener("click", (async (postId) => createComment(postId)).bind(undefined, postId));
divCommentRow.className = divCommentRow.className.replace(" hide", "");
} else {
postCommentButton.addEventListener("click", (async (postId) => await createComment(postId)).bind(undefined, postId));
postCommentButton.addEventListener("click", (async (postId) => createComment(postId)).bind(undefined, postId));
}
} else {
await createBlankMealtype();
......@@ -337,7 +337,7 @@ async function retrieveDiet(id) {
buttonAddMealtype.className = buttonAddMealtype.className.replace(" hide", "");
buttonRemoveMealtype.className = buttonRemoveMealtype.className.replace(" hide", "");
okDietButton.addEventListener("click", async () => await createDiet());
okDietButton.addEventListener("click", async () => createDiet());
cancelDietButton.addEventListener("click", handleCancelDuringDietCreate);
divCommentRow.className += " hide";
}
......
......@@ -63,8 +63,7 @@ window.addEventListener("DOMContentLoaded", async () => {
let diets = await fetchDiets(ordering);
let tabEls = document.querySelectorAll('a[data-bs-toggle="list"]');
for (let i = 0; i < tabEls.length; i++) {
let tabEl = tabEls[i];
for (let tabEl of tabEls) {
tabEl.addEventListener('show.bs.tab', function (event) {
let dietAnchors = document.querySelectorAll('.diet');
for (let j = 0; j < diets.length; j++) {
......
......@@ -53,8 +53,7 @@ function createFilledRow(templateFilledAthlete, inputValue, controls, disabled)
async function getDietInstances() {
let response = await sendRequest("GET", `${HOST}/api/diet-instances/`);
let diets = await response.json();
return diets;
return await response.json();
}
function createDiet(templateFile, name) {
......@@ -180,7 +179,7 @@ async function displayFiles() {
}
let uploadBtn = document.querySelector(`#btn-upload-${athlete.username}`);
uploadBtn.disabled = false;
uploadBtn.addEventListener("click", async (event) => await uploadFiles(event, athlete));
uploadBtn.addEventListener("click", async (event) => uploadFiles(event, athlete));
let fileInput = tabPanel.querySelector(".form-control");
fileInput.disabled = false;
......@@ -354,5 +353,5 @@ window.addEventListener("DOMContentLoaded", async () => {
await displayFiles();
let buttonSubmitRoster = document.querySelector("#button-submit-roster");
buttonSubmitRoster.addEventListener("click", async () => await submitRoster());
buttonSubmitRoster.addEventListener("click", async () => submitRoster());
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment