controller.js 1.2 KB

123456789101112131415161718192021222324252627282930313233
  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. basicInfoObj.display();
  11. },
  12. //General purpose data validator
  13. checkValid: function(valueToCheck, inputField){
  14. if(!validator.ingredient[valueToCheck](inputField.value, createBanner = false)){
  15. inputField.classList += " input-error"
  16. }else{
  17. inputField.classList.remove("input-error");
  18. }
  19. },
  20. clearScreen: function(){
  21. this.basicInfoStrand.style.display = "none";
  22. this.addIngredientsStrand.style.display = "none";
  23. this.createIngredientsStrand.style.display = "none";
  24. this.nameRecipesStrand.style.display = "none";
  25. this.createRecipesStrand.style.display = "none";
  26. }
  27. }
  28. controller.onStart();