controller.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // let data = {}; //For storing all data from user to pass to backend
  2. // //Divs to switch out to show different pages
  3. // let addIngredients = document.querySelector("#addIngredients");
  4. // let newIngredients = document.querySelector("#newIngredients");
  5. // let createRecipes = document.querySelector("#createRecipes");
  6. // //General purpose data validator
  7. // let checkValid = (valueToCheck, inputField)=>{
  8. // if(!validator.ingredient[valueToCheck](inputField.value, createBanner = false)){
  9. // inputField.classList += " input-error"
  10. // }else{
  11. // inputField.classList.remove("input-error");
  12. // }
  13. // }
  14. let controller = {
  15. data: {}, //For storing all data from user to pass to backend
  16. //Component divs
  17. addIngredientsComp: document.querySelector("#addIngredients"),
  18. newIngredientsComp: document.querySelector("#newIngredients"),
  19. createRecipesComp: document.querySelector("#createRecipes"),
  20. run: function(){
  21. },
  22. //General purpose data validator
  23. checkValid: function(valueToCheck, inputField){
  24. if(!validator.ingredient[valueToCheck](inputField.value, createBanner = false)){
  25. inputField.classList += " input-error"
  26. }else{
  27. inputField.classList.remove("input-error");
  28. }
  29. },
  30. clearScreen: function(){
  31. this.addIngredientsComp.style.display = "none";
  32. this.newIngredientsComp.style.display = "none";
  33. this.createRecipesComp.style.display = "none";
  34. }
  35. }
  36. //Run first function
  37. controller.run();