controller.js 1001 B

12345678910111213141516171819202122232425262728
  1. let controller = {
  2. data: {}, //For storing all data from user to pass to backend
  3. //Component divs
  4. addIngredientsComp: document.querySelector("#addIngredients"),
  5. newIngredientsComp: document.querySelector("#newIngredients"),
  6. createRecipesComp: document.querySelector("#createRecipes"),
  7. newRecipesComp: document.querySelector("#newRecipes"),
  8. //General purpose data validator
  9. checkValid: function(valueToCheck, inputField){
  10. if(!validator.ingredient[valueToCheck](inputField.value, createBanner = false)){
  11. inputField.classList += " input-error"
  12. }else{
  13. inputField.classList.remove("input-error");
  14. }
  15. },
  16. clearScreen: function(){
  17. this.addIngredientsComp.style.display = "none";
  18. this.newIngredientsComp.style.display = "none";
  19. this.createRecipesComp.style.display = "none";
  20. this.newRecipesComp.style.display = "none";
  21. }
  22. }
  23. //Run first function
  24. ingredientSetup.existingIngredients();