Methods
addChore(chore)
Given a chore, add it to local storage
Precondition: There exists a sorted array in local storage with the key "chores"
Postcondition: The new chore is added in the correct position to this array in local storage
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
chore |
Object
|
A JSON object describing the chore to be added |
(async) getChores()
Retrieves chores from persistent storage and places them in local storage
Precondition: All chores to be displayed in the chore list are existent in persistent storage and correctly sorted
Postcondition: All chores to be displayed in the chore list are existent in a sorted array in local storage with the "chores" key
- Source:
(async) init()
Initialize page with chores from storage and add all event listeners
Postcondition: All chores in the chore list are available in local storage and displayed on the screen
- Source:
init_add_btn()
Initalize all necessary event listeners for "add chore" button
- Source:
init_menu()
Initialize all necessary event listeners for menu button
- Source:
reformatDate(date)
Format a date string to make it lexicographically comparable
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
date |
string
|
a date in mm/dd/yyyy format |
Returns:
string newDate in yyyymmdd format
removeChore(chore)
Given a chore, remove it from local storage
Postcondition: The given chore no longer exists in the array in local storage
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
chore |
Object
|
A JSON object describing the chore to be removed |
(async) saveChores()
Save all chores from local storage in persistent storage
Precondition: There exists an array in local storage with the key "chores"
Postcondition: Persistent storage is updated to match the "chores" array in local storage
- Source:
updateDocument()
Update the chore list in the DOM to correctly include all elements in the "chores" array in local storage
Precondition: There exists a sorted array in local storage with the key "chores"
Postcondition: The chore list in the DOM contains all chores from local storage sorted by priority
- Source: