fixed linting errors

This commit is contained in:
j264415 2024-02-19 14:08:00 +00:00
parent 6b1086ddb9
commit 959aa709c3
2 changed files with 33 additions and 33 deletions

View file

@ -148,7 +148,7 @@ class Manager {
document.getElementById("edit-favourites").addEventListener("click", this.ops.editFavouritesClick.bind(this.ops)); document.getElementById("edit-favourites").addEventListener("click", this.ops.editFavouritesClick.bind(this.ops));
document.getElementById("save-favourites").addEventListener("click", this.ops.saveFavouritesClick.bind(this.ops)); document.getElementById("save-favourites").addEventListener("click", this.ops.saveFavouritesClick.bind(this.ops));
document.getElementById("categories").addEventListener("keydown", this.ops.onKeyPress.bind(this.ops)); document.getElementById("categories").addEventListener("keydown", this.ops.onKeyPress.bind(this.ops));
this.addDynamicListener(".op-list li.operation","keydown", this.ops.keyboardPopulateRecipe.bind(this.ops)); this.addDynamicListener(".op-list li.operation", "keydown", this.ops.keyboardPopulateRecipe.bind(this.ops));
document.getElementById("reset-favourites").addEventListener("click", this.ops.resetFavouritesClick.bind(this.ops)); document.getElementById("reset-favourites").addEventListener("click", this.ops.resetFavouritesClick.bind(this.ops));
this.addDynamicListener(".op-list", "oplistcreate", this.ops.opListCreate, this.ops); this.addDynamicListener(".op-list", "oplistcreate", this.ops.opListCreate, this.ops);
this.addDynamicListener("li.operation", "operationadd", this.recipe.opAdd, this.recipe); this.addDynamicListener("li.operation", "operationadd", this.recipe.opAdd, this.recipe);

View file

@ -283,50 +283,50 @@ class OperationsWaiter {
this.manager.recipe.initialiseOperationDragNDrop(); this.manager.recipe.initialiseOperationDragNDrop();
} }
/** /**
* Handler for on key press events. * Handler for on key press events.
* Get the children of categories and add event listener to them. * Get the children of categories and add event listener to them.
*/ */
onKeyPress() { onKeyPress() {
const cat = document.getElementById("categories"); const cat = document.getElementById("categories");
for (let i = 0; i < cat.children.length; i++){ for (let i = 0; i < cat.children.length; i++) {
cat.children[i].addEventListener("keydown", this.keyboardEventHandler, false); cat.children[i].addEventListener("keydown", this.keyboardEventHandler, false);
}; }
} }
/** /**
* Handler for keyboard enter/space events. * Handler for keyboard enter/space events.
* Uses "Enter" or "Space" to mimic the click function and open the operations panels . * Uses "Enter" or "Space" to mimic the click function and open the operations panels .
* @param {Event} ev * @param {Event} ev
*/ */
keyboardEventHandler(ev){ keyboardEventHandler(ev) {
if(ev.key === "Enter" || ev.key === "Space" || ev.key === " " ){ if (ev.key === "Enter" || ev.key === "Space" || ev.key === " ") {
ev.preventDefault(); ev.preventDefault();
for(let i = 0; i < ev.target.childNodes.length; i++){ for (let i = 0; i < ev.target.childNodes.length; i++) {
let targetChild = ev.target.childNodes[i].classList; const targetChild = ev.target.childNodes[i].classList;
if(targetChild !== undefined && targetChild.value.includes("panel-collapse collapse")){ if (targetChild !== undefined && targetChild.value.includes("panel-collapse collapse")) {
if(!targetChild.contains("show")){ if (!targetChild.contains("show")) {
targetChild.add("show"); targetChild.add("show");
}else if(targetChild.contains("show")){ } else if (targetChild.contains("show")) {
targetChild.remove("show"); targetChild.remove("show");
} }
}; }
} }
} }
}; }
/** /**
* Handler to populate recipe. * Handler to populate recipe.
* Get the children of op-list and add event listener to them. * Get the children of op-list and add event listener to them.
*/ */
operationPopulateRecipe(){ operationPopulateRecipe() {
let cat = document.querySelectorAll(".op-list li.operation"); const cat = document.querySelectorAll(".op-list li.operation");
for(let i = 0; i < cat.children.length; i++){ for (let i = 0; i < cat.children.length; i++) {
cat.children[i].addEventListener("keydown", this.keyboardPopulateRecipe, false); cat.children[i].addEventListener("keydown", this.keyboardPopulateRecipe, false);
}; }
} }
@ -335,13 +335,13 @@ class OperationsWaiter {
* Uses keyboard shortcut "CTRl + Enter" to mimic operationDblClick handler function * Uses keyboard shortcut "CTRl + Enter" to mimic operationDblClick handler function
* @param {Event} ev * @param {Event} ev
*/ */
keyboardPopulateRecipe(ev){ keyboardPopulateRecipe(ev) {
if(ev.ctrlKey && ev.key === "Enter"){ if (ev.ctrlKey && ev.key === "Enter") {
const li = ev.target const li = ev.target;
this.manager.recipe.addOperation(li.textContent); this.manager.recipe.addOperation(li.textContent);
} }
} }
/** /**
* Handler for reset favourites click events. * Handler for reset favourites click events.
* Resets favourites to their defaults. * Resets favourites to their defaults.