Global

Members

(constant) MAIN_API_URL

How to use: After DATA is initialized automatically: inside init() function, under "await fetchRecipes();": call getRecipeCardInfo() to get recipe id,diets,image and title of all fetched recipes NOTE 1:I store fetched data in DATA. To access DATA, access inside init() function or there will be nothing. NOTE 2:DATA[0]['results'][0] returns first recipe; DATA[0]['results'][1] returns second one; aka DATA[0]['results'] = recipeData in lab 6 NOTE 3:main link https://spoonacular.com/food-api/docs#Search-Recipes-Complex
Source:

Methods

addMoreIngredients(ig)

This hepler function adds ingredients to the edit recipe.
Parameters:
Name Type Description
ig string ingredient
Source:

addMoreInstructions(ins)

This hepler function adds instructions to the edit recipe
Parameters:
Name Type Description
ins string instruction
Source:

addNewCookBook()

This function ask user to enter new cookbook's name, store it to local storage and call appendNewCookBook()
Source:

addRemoveCookBook(button)

This function removes a cookbook from cookbook List
Parameters:
Name Type Description
button HTMLElement the button that adds the cookbook
Source:

addRemoveRecipe(button)

This function removes recipe from a cookbook
Parameters:
Name Type Description
button HTMLElement the button that removes the recipe
Source:

appendNewCookBook(newCookBook)

This function adds new cookbook to the save-cookbook menu
Parameters:
Name Type Description
newCookBook string
Source:

bindAll()

Calls all binding functions above and is called in the init function
Source:

bindAppNameClick()

Returns to home when app name is clicked
Source:

bindCategoryCards(categoryCard, categoryName)

Binds the click event to the category card to initiate the search
Parameters:
Name Type Description
categoryCard Element the category card to bind to
categoryName String the name of the category searched
Source:

bindCookbookPage()

Goes to cookbook page when cookbook is clicked
Source:

bindCuisineFilters()

This function adds an event listener waiting for the user to click on the cuisine filters button and change the direction of the arrow icon which will then call toggleCuisineFilters() method to either reveal or hide the cuisine filters drop down menu
Source:

bindDietFilters()

This function adds an event listener waiting for the user to click on the diet filters button which will then call toggleDietFilters() method to either reveal or hide the diet filters drop down menu and change the direction of the arrow icon
Source:

bindHomePage()

Goes to home page when home is clicked
Source:

bindMealFilters()

This function adds an event listener waiting for the user to click on the meal type filters button which will then call toggleMealTypeFilters() method to either reveal or hide the meal type filters drop down menu and change the direction of the arrow icon
Source:

bindNewCookBook(li)

This functions bind a cookbook / add an event upon click, so that when users click on a cookbook, it saves the current recipe to the cookbook that user chose
Parameters:
Name Type Description
li HTMLObjectElement the cookbook to save to
Source:

bindPopState()

Binds a pop state to a routing page
Source:

bindSettingsPage()

Goes to setting page when settings is clicked
Source:

bindTimeFilters()

This function adds an event listener waiting for the user to click on the time filters button which will then call toggleTimeFilters() method to either reveal or hide the time filters drop down menu and change the direction of the arrow icon
Source:

checkBookMark(data)

This function check if the recurrent recipe has been whether saved or not. If the data has been saved, display bookmark and edit recipe, and load data from local storage.
Parameters:
Name Type Description
data Object
Source:

clearAllFilters()

This function removes all the filter cards and clears all checkboxes
Source:

clearCheckBoxes()

Clears check boxes on a recipe page and list
Source:

clearFilterCheckBoxes()

Clears check boxes in the filter drop down menus
Source:

createCategoryCards()

Creates 6 category cards from the categories and images arrays above using random values so every time the user refreshes, there will be a new set of categories
Source:

createFilters()

Function to create filter-card elements based off of the selected filters in the filters array.
Source:

emailRecipe()

Open the share recipe modal
Source:

(async) fetchRecipes(queries, callbackFn) → {Promise}

Fetch the recipes for the search page
Parameters:
Name Type Description
queries String string that contains all query parameters for API call
callbackFn function assigns the value from the fetch to the global variable
Source:
Returns:
a Promise for whether or not a recipe has been loaded successfully
Type
Promise

getIngredients(data) → {Array}

Extract the ingredients from data
Parameters:
Name Type Description
data Object JSON
Source:
Returns:
return a list of ingredients
Type
Array

getInstructions(data) → {Array}

Extract the instructions from data
Parameters:
Name Type Description
data Object JSON
Source:
Returns:
return a list of instructions
Type
Array

getRecipeCardInfo(data) → {Array}

Extract needed info of all recipes fetched as an array
Parameters:
Name Type Description
data Array an array of data for a recipe card
Source:
Returns:
an array of extracted data for a recipe card
Type
Array

getRecipeCardInfo(data) → {Object}

Extract needed info of all recipes fetched as an array
Parameters:
Name Type Description
data Object the data of the recipe card
Source:
Returns:
{{diets1,id1,image1,title1},{diets2,id2,image2,title2},...}
Type
Object

hideApplyBtn()

This function hides the apply filters button
Source:

hideCategoryCards()

Hide category cards
Source:

hideClearFiltersBtn()

This function should only be called when no filters are selected, showing, or is on another page like the settings home, or cookbook page. Thus the clear filters button should only show when a filter is selected but disappear all other times
Source:

hideCookbooks()

Hide cookbooks page
Source:

hideEditRecipe()

Hide edit recipe button
Source:

hideFilterBtns()

This function hides the filter buttons
Source:

hideFilters()

This function hides the filter drop down menus
Source:

hideHome()

Hide the home page
Source:

hideRecipeCards()

Hide recipe cards
Source:

hideRecipePage()

Hide recipe page
Source:

hideSearchBar()

Hide search bar
Source:

hideSelectedFilters()

This function hides the selected filters container
Source:

hideSettings()

Hide the settings
Source:

hideTapMode()

Hide tap mode button
Source:

(async) init()

When page is initialized, create a home page to show
Source:

load()

This function loads all ingredients and instructions to the Edit Recipe popup
Source:

printRecipe()

Print a recipe from the recipe page
Source:

removeIngredient()

this function removes the last ingredient in the ingredients list
Source:

removeInstruction()

This function removes the last intructions in the instructions list
Source:

removeRecipe(Id)

This function removes recipe from localstorage
Parameters:
Name Type Description
Id string of recipe
Source:

resetFilters()

This function removes all the filter cards in order to display new ones each time a user selects a new filter
Source:
The search function, calls API functoin to fetch all recipes Generates recipe cards by passing in values into RecipeData
Source:
Returns:
Whether search was successful
Type
Boolean

(async) searchByCategory() → {Promise}

Function to search when a category card is clicked
Source:
Returns:
a Promise whether recipes have been fetched correctly
Type
Promise

searchByFilter()

Function to filter the search the by the filters that the user selects
Source:

showApplyBtn()

This function shows the apply filters button
Source:

showBookMarkEditReipce()

This helper function display bookmark-filled and display editRecipe
Source:

showCategoryCards()

Show category cards
Source:

showClearFiltersBtn()

This function just reveals the clear filters button which should only appear after a filter is selected in any category
Source:

showCookBookMenu()

This functions displays all the cookbooks in local storage to the saved-cookbook menu when users click on bookmark. There is one cookbook by default - "favorites". If bookmark has been marked/filled. It removes the recipe from local Storage.
Source:

showCookbooks()

Show cookbooks page
Source:

showCuisineFilters()

This function shows the cuisine filter drop down menu when cuisine button is clicked
Source:

showDietFilters()

This function shows the diet filter drop down menu when diet button is clicked
Source:

showEditRecipe()

Show edit recipe button
Source:

showFilterBtns()

This function shows the filter buttons
Source:

showHome()

Show home page
Source:

showMealFilters()

This function shows the meal filter drop down menu when meal button is clicked
Source:

showRecipeCards()

Show the recipe cards
Source:

showRecipePage()

Show recipe page
Source:

showSearchBar()

Show the search bar
Source:

showSelectedFilters()

This function shows the selected filters container
Source:

showSettings()

Shows the Settings page
Source:

showTapMode()

Show tap mode button
Source:

showTimeFilters()

This function shows the time filter drop down menu when time button is clicked
Source:

submit()

When users hit "save" on edit recipe popup It save the data to recipe on local storage and reload the RecipePage with info
Source:

tapMode()

This function enables tap-mode
Source:

toggleCuisineFilters()

Function to toggle the cuisine filters each time the cuisine button is clicked
Source:

toggleDietFilters()

Function to toggle the diet filters each time the diet button is clicked
Source:

toggleEditRecipe()

This function displays the popup menu to edit recipe
Source:

toggleMealTypeFilters()

Function to toggle the meal filters each time the meal button is clicked
Source:

toggleMenu()

Toggles the Menu list
Source:

toggleSaveCookBook()

Displays saved-cookbook menu
Source:

toggleTapMode()

Toggles Tap Mode
Source:

toggleTimeFilters()

Function to toggle the time filters each time the time button is clicked
Source:

updateSettings()

Update global settings for user
Source: