controller.js 1.2 KB

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