Members
(constant) router
Creating a router object. The constructor's function is the "home" function
- Source:
Methods
addFav(data, favRecipeArray)
Add the recipe to the favRecipeArray.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | a JSON data object contains information of a recipe. |
favRecipeArray |
Array | an array of favorited recipes. |
- Source:
Returns:
Void
addMy(data, nextMyRecipeID, myRecipeArray)
Add the recipe to the myRecipeArray.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | a JSON data object contains information of a recipe. |
nextMyRecipeID |
Number | a number representing the id of the next recipe to be created. |
myRecipeArray |
Array | an array of created recipes. |
- Source:
Returns:
Void
bindEscKey()
Credit: Lab 7 skeleton, Tai's implementation of skeleton
If the escape key is pressed, use your router to navigate() to the 'home'
page. This will let us go back to the home page from the detailed page.
- Source:
Returns:
Void
bindPopstate()
Credit: Lab 7 skeleton, Tai's implementation of skeleton.
Binds the 'popstate' event on the window (which fires when the back &
forward buttons are pressed) so the navigation will continue to work
as expected.
- Source:
Returns:
Void
calculateServing(baseAmount, multiplier)
This function calculates the nutrition facts of some number servings based on the provided
base amount of 1 serving and the desired number of servings.
Parameters:
| Name | Type | Description |
|---|---|---|
baseAmount |
* | a number representing the base amount of 1 serving |
multiplier |
* | a desired number of serving to multiply the baseAmount with |
- Source:
Returns:
Number
checkFav(recipeTitle, favRecipeArray)
Determine whether the recipe is in favRecipeArray.
Parameters:
| Name | Type | Description |
|---|---|---|
recipeTitle |
String | title string of a recipe. |
favRecipeArray |
Array | an array of favorited recipes. |
- Source:
Returns:
Boolean
createFavRecipeCards()
Initial Favorites Recipes section with three recipes from favRecipeArray
If no favorite recipes, then remove the Favorites Recipes section
- Source:
Returns:
a Promise of fetched data
createFavRecipePage()
Initial favorite Recipes page with all recipes from favRecipeArray
- Source:
Returns:
a Promise
createFeaRecipeCards()
Initial Featured Recipes section with three random recipes from feaRecipeArray
- Source:
Returns:
a Promise of fetched data
createFeaRecipePage()
Initial Featured Recipes page with all recipes from feaRecipeArray
- Source:
Returns:
a Promise
createMyRecipeCards()
Initial My Recipes section with three recipes from myRecipeArray
- Source:
Returns:
a Promise of fetched data
createMyRecipePage()
Initial My Recipes page with all recipes from myRecipeArray
- Source:
Returns:
a Promise
createSearch()
Implement search feature.
- Source:
Returns:
Void
createSearchFav(inputVal)
Create favorite recipe after search.
Parameters:
| Name | Type | Description |
|---|---|---|
inputVal |
String | the input string for search query. |
- Source:
Returns:
Void
createSearchFea(inputVal)
Create featured recipe after search.
Parameters:
| Name | Type | Description |
|---|---|---|
inputVal |
String | the input string for search query. |
- Source:
Returns:
Void
createSearchMy(inputVal)
Create my recipe after search.
Parameters:
| Name | Type | Description |
|---|---|---|
inputVal |
String | the input string for search query. |
- Source:
Returns:
Void
(async) fetchFeaRecipeArray()
Fetch data from spoonacular API (this function makes a call to another function
in the back-end Netlify service that is used to call our API. This way, the API key
is hidden from the client-side)
- Source:
Returns:
a Promise of fetched data
getDairy(data)
Get the dairyFree of recipe
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | a JSON data object contains information of DairyFree boolean. |
- Source:
Returns:
Boolean
getFeaturedSteps(data)
Get the steps of recipe (Array).
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | a JSON data object contains information of instructions array. |
- Source:
Returns:
Array
getGluten(data)
Get the glutenFree of recipe
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | a JSON data object contains information of GlutenFree boolean. |
- Source:
Returns:
Boolean
getImgUrl(data)
Get the image of recipe.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | a JSON data object contains information of image. |
- Source:
Returns:
String
getIngre(data)
Get the ingredients of recipe.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | a JSON data object contains information of ingredients string. |
- Source:
Returns:
String
getIngreArray(data)
Get the ingredients of recipe (Array).
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | a JSON data object contains information of ingredients array. |
- Source:
Returns:
Array
getIngreFea(data)
Get the ingredients of recipe.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | a JSON data object contains information of ingredients string. |
- Source:
Returns:
String
getSteps(data)
Get the steps of recipe.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | a JSON data object contains information of instructions string. |
- Source:
Returns:
String
getStepsArray(data)
Get the steps of recipe (Array).
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | a JSON data object contains information of instructions array. |
- Source:
Returns:
Array
getTime(data)
Get the cooking time of recipe.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | a JSON data object contains information of cook time. |
- Source:
Returns:
String
getTitle(data)
Get the title of recipe.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | a JSON data object contains information of title. |
- Source:
Returns:
String
getVegan(data)
Get the vegan of recipe
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | a JSON data object contains information of Vegan boolean. |
- Source:
Returns:
Boolean
getVegeta(data)
Get the vegetarian of recipe.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | a JSON data object contains information of Vegetarian boolean. |
- Source:
Returns:
Boolean
(async) init()
Initialize and load page.
- Source:
Returns:
Void
leaveFavorite()
Leave favorite page.
- Source:
Returns:
Void
leaveFeatured()
Leave featured page.
- Source:
Returns:
Void
leaveLanding()
Leave landing page.
- Source:
Returns:
Void
leaveMain()
Leave main page (like to add page).
- Source:
Returns:
Void
leaveMyRecipe()
Leave my recipe page.
- Source:
Returns:
Void
leaveSearchPage()
Leave search page.
- Source:
Returns:
Void
loadFavorite()
Load favorite page.
- Source:
Returns:
Void
loadFeatured()
Load featured page.
- Source:
Returns:
Void
loadLanding()
Load landing page.
- Source:
Returns:
Void
loadMain()
Load main page (like to add page).
- Source:
Returns:
Void
loadMyRecipe()
Load my recipe page.
- Source:
Returns:
Void
loadSearchPage()
Load search page.
- Source:
Returns:
Void
rmFav(recipeTitle, favRecipeArray)
Remove the recipe from the favRecipeArray
Parameters:
| Name | Type | Description |
|---|---|---|
recipeTitle |
String | title string of a recipe. |
favRecipeArray |
Array | an array of favorited recipes. |
- Source:
Returns:
Void
rmMy(data, myRecipeArray)
Remove the recipe to the myRecipeArray
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | a JSON data object contains information of a recipe. |
myRecipeArray |
Array | an array of created recipes. |
- Source:
Returns:
Void
setButtonListen()
Set event listener for all title button.
- Source:
Returns:
Void
updateMy(data, myRecipeArray)
Updata the recipe to the myRecipeArray
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | a JSON data object contains information of a recipe. |
myRecipeArray |
Array | an array of created recipes. |
- Source:
Returns:
Void