controller.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. let controller = {
  2. data: {}, //For storing all data from user to pass to backend
  3. //Component divs
  4. basicInfoStrand: document.querySelector("#basicInfoStrand"),
  5. addIngredientsStrand: document.querySelector("#addIngredientsStrand"),
  6. createIngredientsStrand: document.querySelector("#createIngredientsStrand"),
  7. nameRecipesStrand: document.querySelector("#nameRecipesStrand"),
  8. createRecipesStrand: document.querySelector("#createRecipesStrand"),
  9. onStart: function(){
  10. if(error){
  11. banner.createError(error);
  12. }
  13. basicInfoObj.display();
  14. },
  15. //General purpose data validator
  16. checkValid: function(valueToCheck, inputField){
  17. if(!validator.ingredient[valueToCheck](inputField.value, createBanner = false)){
  18. inputField.classList += " input-error"
  19. }else{
  20. inputField.classList.remove("input-error");
  21. }
  22. },
  23. clearScreen: function(){
  24. this.basicInfoStrand.style.display = "none";
  25. this.addIngredientsStrand.style.display = "none";
  26. this.createIngredientsStrand.style.display = "none";
  27. this.nameRecipesStrand.style.display = "none";
  28. this.createRecipesStrand.style.display = "none";
  29. }
  30. }
  31. controller.onStart();