|
@@ -3,39 +3,28 @@ window.recipeBookStrandObj = {
|
|
|
|
|
|
|
|
display: function(){
|
|
display: function(){
|
|
|
if(!this.isPopulated){
|
|
if(!this.isPopulated){
|
|
|
- let recipeList = document.querySelector("#recipeList");
|
|
|
|
|
|
|
+ this.populateRecipes();
|
|
|
|
|
|
|
|
- for(let recipe of merchant.recipes){
|
|
|
|
|
- let recipeDiv = document.createElement("div");
|
|
|
|
|
- recipeDiv.classList = "recipeItem";
|
|
|
|
|
- recipeDiv.onclick = ()=>{this.displayRecipe(recipe)};
|
|
|
|
|
- recipeList.appendChild(recipeDiv);
|
|
|
|
|
|
|
+ this.isPopulated = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
- let recipeName = document.createElement("p");
|
|
|
|
|
- recipeName.innerText = recipe.name;
|
|
|
|
|
- recipeDiv.appendChild(recipeName);
|
|
|
|
|
|
|
+ populateRecipes: function(){
|
|
|
|
|
+ let recipeList = document.querySelector("#recipeList");
|
|
|
|
|
|
|
|
- let recipePrice = document.createElement("p");
|
|
|
|
|
- recipePrice.innerText = `$${(recipe.price / 100).toFixed(2)}`;
|
|
|
|
|
- recipeDiv.appendChild(recipePrice);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ for(let recipe of merchant.recipes){
|
|
|
|
|
+ let recipeDiv = document.createElement("div");
|
|
|
|
|
+ recipeDiv.classList = "recipeItem";
|
|
|
|
|
+ recipeDiv.onclick = ()=>{this.displayRecipe(recipe)};
|
|
|
|
|
+ recipeList.appendChild(recipeDiv);
|
|
|
|
|
|
|
|
- let ingredientsSelect = document.querySelector("#recipeInputIngredients select");
|
|
|
|
|
- let categories = categorizeIngredients();
|
|
|
|
|
- for(let category of categories){
|
|
|
|
|
- let optgroup = document.createElement("optgroup");
|
|
|
|
|
- optgroup.label = category.name;
|
|
|
|
|
- ingredientsSelect.appendChild(optgroup);
|
|
|
|
|
-
|
|
|
|
|
- for(let ingredient of category.ingredients){
|
|
|
|
|
- let option = document.createElement("option");
|
|
|
|
|
- option.value = ingredient.id;
|
|
|
|
|
- option.innerText = ingredient.name;
|
|
|
|
|
- optgroup.appendChild(option);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ let recipeName = document.createElement("p");
|
|
|
|
|
+ recipeName.innerText = recipe.name;
|
|
|
|
|
+ recipeDiv.appendChild(recipeName);
|
|
|
|
|
|
|
|
- this.isPopulated = true;
|
|
|
|
|
|
|
+ let recipePrice = document.createElement("p");
|
|
|
|
|
+ recipePrice.innerText = `$${(recipe.price / 100).toFixed(2)}`;
|
|
|
|
|
+ recipeDiv.appendChild(recipePrice);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
|
|
@@ -68,6 +57,21 @@ window.recipeBookStrandObj = {
|
|
|
|
|
|
|
|
displayAddRecipe: function(){
|
|
displayAddRecipe: function(){
|
|
|
openSidebar(document.querySelector("#addRecipe"));
|
|
openSidebar(document.querySelector("#addRecipe"));
|
|
|
|
|
+
|
|
|
|
|
+ let ingredientsSelect = document.querySelector("#recipeInputIngredients select");
|
|
|
|
|
+ let categories = categorizeIngredients();
|
|
|
|
|
+ for(let category of categories){
|
|
|
|
|
+ let optgroup = document.createElement("optgroup");
|
|
|
|
|
+ optgroup.label = category.name;
|
|
|
|
|
+ ingredientsSelect.appendChild(optgroup);
|
|
|
|
|
+
|
|
|
|
|
+ for(let ingredient of category.ingredients){
|
|
|
|
|
+ let option = document.createElement("option");
|
|
|
|
|
+ option.value = ingredient.id;
|
|
|
|
|
+ option.innerText = ingredient.name;
|
|
|
|
|
+ optgroup.appendChild(option);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
changeRecipeCount: function(){
|
|
changeRecipeCount: function(){
|