controller.js 1.1 KB

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