Members
(constant) API_KEY_STORAGE :string
The key used for storing/retrieving the Google Maps API key from localStorage.
Type:
- string
map :google.maps.Map|null
Holds the initialized Google Maps map instance.
Type:
- google.maps.Map | null
Methods
addMarker(map, lat, lng, titleopt)
Adds a marker to the specified map at given latitude and longitude.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
map |
google.maps.Map | The map instance to add the marker to. | ||
lat |
number | Latitude coordinate for the marker. | ||
lng |
number | Longitude coordinate for the marker. | ||
title |
string |
<optional> |
"" | Optional title text for the marker tooltip. |
addMemory(post, db) → {Promise}
This function adds a memory to the MemoryDB.
Parameters:
Name | Type | Description |
---|---|---|
post |
Object | |
db |
IDBDatabase |
- Source:
Returns:
Promise that resolves into a post being added--this would be the post id.
- Type
- Promise
cardTemplate(data) → {string}
Generates the complete HTML for a memory card calling on above helpers.
Parameters:
Name | Type | Description |
---|---|---|
data |
Object | The data for the memory card. |
- Source:
Returns:
The HTML string for the memory card.
- Type
- string
changeImg()
This function previews the uploaded image and makes sure only one file is selected.
- Source:
confirmSafety(post) → {boolean}
This function validates the memory being submitted
Parameters:
Name | Type | Description |
---|---|---|
post |
object | This is the memory being submitted |
- Source:
Returns:
True if the post is valid, False if the post is not valid
- Type
- boolean
createCardContent(data) → {string}
Generates the HTML for the content section of a card -- main content area below image
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object | The data for the memory card.
Properties
|
- Source:
Returns:
The HTML string for the content section.
- Type
- string
createCardMeta(data) → {string}
Generates the HTML for the metadata section of a card.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object | The data for the memory card.
Properties
|
- Source:
Returns:
The HTML string for the metadata section.
- Type
- string
createMemoryPhoto(data) → {string}
Generates the HTML for the memory photo section of a card.
Builds top part of card and displays it with image.
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object | The data for the memory card.
Properties
|
- Source:
Returns:
The HTML string for the memory photo section.
- Type
- string
deleteAllMemories(db)
This function deletes all the memoryes currently being stored.
Parameters:
Name | Type | Description |
---|---|---|
db |
IDBDatabase | The database being deleted. |
- Source:
deleteListener(cardElement, id, db)
This function adds a delete listener to the card element.
Parameters:
Name | Type | Description |
---|---|---|
cardElement |
* | to remove from DOM |
id |
* | to delete from IndexedDB |
db |
* | Database instance |
- Source:
deleteMemory(post_id, db) → {Promise}
This function deletes a specific memory that was stored
Parameters:
Name | Type | Description |
---|---|---|
post_id |
int | |
db |
IDBDatabase | Database instance |
- Source:
Returns:
Resolves into true/false for successful deletion
- Type
- Promise
displayAllMemories(db)
This function is written to display all the memories from date descending.
There are additional filters--mood and search bar (currently only mood)
Parameters:
Name | Type | Description |
---|---|---|
db |
IDBDatabase | Database instance |
- Source:
editListener(cardElement, id, db)
This function adds an edit listener on the card element.
Parameters:
Name | Type | Description |
---|---|---|
cardElement |
* | to edit from DOM |
id |
* | to edit from IndexedDB |
db |
* | Database instance |
- Source:
fileToDataUrl(file) → {Promise}
Parameters:
Name | Type | Description |
---|---|---|
file |
Blob |
- Source:
Returns:
Promise that resolves into the image data URL
- Type
- Promise
(async) fillForm(db) → {number|null}
This function loads an existing memory into the form for editing.
Parameters:
Name | Type | Description |
---|---|---|
db |
IDBDatabase | The database to retrieve the memory from. |
- Source:
Returns:
The postId if editing, or null if creating a new memory.
- Type
- number | null
getAllLocations(db) → {Promise}
This function handles grabbing all the longitudes and latitudes.
Parameters:
Name | Type | Description |
---|---|---|
db |
IDBDatabase | MemoryDB |
- Source:
Returns:
resolves into the list of the following: latitude, longitude, and title [(lat, long, title), ...]
- Type
- Promise
(async) init()
This function sets up the database, loads form data, and initializes location input.
- Source:
(async) init() → {Promise.<void>}
Initializes the page's interactive behavior.
Responsibilities:
- Manages showing/hiding a modal window.
- Loads button states from localStorage and enables toggling.
- Colors category tags based on their type.
- Initializes the map display.
Returns:
- Type
- Promise.<void>
initAutocomplete()
Initializes the Google Places Autocomplete widget on the input element with id "location".
Configures autocomplete to restrict results to US geocoded addresses and limits the
fields returned to optimize performance.
Function sets up search bar, currently set to US locations only.
initCreate()
Function run upon loading the page -- API key saved in localStorage
is sought after, then initAutocomplete() is run to hook up address search
box
initDB() → {Promise.<IDBDatabase>}
This function initializes the IndexedDB and creates object stores if needed.
- Source:
Returns:
A promise that resolves with the database instance.
- Type
- Promise.<IDBDatabase>
initMap()
Callback function for Google Maps API to initialize the map.
Sets up the map centered on San Diego with some controls disabled.
Also adds a marker at the center point.
(async) initMapDisplay() → {Promise.<void>}
Initializes the map display by opening the IndexedDB database and rendering saved locations.
Also loads the Google Maps API if an API key is stored.
Returns:
Resolves when the map is ready.
- Type
- Promise.<void>
insertAPIKey()
Handles user input of the API key and starts loading the map.
Validates input, stores the key, loads the map, and populates it with markers.
isEmptyDB(db) → {boolean}
This function checks the MemoryDB to see if it is empty or not.
Parameters:
Name | Type | Description |
---|---|---|
db |
IDBDatabase |
- Source:
Returns:
Returns `true` if db is empty, `false` if db is not empty.
- Type
- boolean
(async) loadGoogleMaps(apiKey, libraries)
Parameters:
Name | Type | Description |
---|---|---|
apiKey |
any | |
libraries |
any | Function loads Google Maps if it isn't already loaded. Potential refactoring needed |
loadGoogleMaps(apiKey, libopt, removeInputopt) → {Promise.<void>}
Dynamically loads the Google Maps JavaScript API.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
apiKey |
string | The user's Google Maps API key. | ||
lib |
string |
<optional> |
"" | Optional Google Maps libraries to include (e.g., "marker"). |
removeInput |
boolean |
<optional> |
true | Whether to remove the API key input elements after loading. |
Returns:
Resolves when the API is loaded successfully; rejects if it fails.
- Type
- Promise.<void>
onPlaceChanged()
Callback fired when the user selects a place from the autocomplete suggestions.
It retrieves place details and logs relevant information, or warns if no geometry is available.
retrieveMemory(post_id, db) → {Promise}
This function retrieves a specific memory that was stored.
Parameters:
Name | Type | Description |
---|---|---|
post_id |
int | Primary key |
db |
IDBDatabase | Database instance |
- Source:
Returns:
Resolves into the memory or failure message
- Type
- Promise
(async) submitForm(event)
This function handles form submission and saves or updates the memory in the database.
Parameters:
Name | Type | Description |
---|---|---|
event |
Event | The form submission event. |
- Source: