controller.js 890 B

1234567891011121314151617181920212223242526
  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. //General purpose data validator
  8. checkValid: function(valueToCheck, inputField){
  9. if(!validator.ingredient[valueToCheck](inputField.value, createBanner = false)){
  10. inputField.classList += " input-error"
  11. }else{
  12. inputField.classList.remove("input-error");
  13. }
  14. },
  15. clearScreen: function(){
  16. this.addIngredientsComp.style.display = "none";
  17. this.newIngredientsComp.style.display = "none";
  18. this.createRecipesComp.style.display = "none";
  19. }
  20. }
  21. //Run first function
  22. ingredientSetup.existingIngredients();