Members
(constant) backButton :HTMLElement|null
A reference to back button HTMlElement on menu.html
Type:
- HTMLElement | null
- Source:
cardCount :number
Set the number of cards to appear to be 6
Type:
- number
- Source:
(constant) categories :HTMLCollection.<Element>
A reference to the div containing all the category Buttons on menu.html
Type:
- HTMLCollection.<Element>
- Source:
enterButton :HTMLElement|null
A reference to the button for entering the hut and triggering the animation
Type:
- HTMLElement | null
- Source:
fortuneText :string
A reference to the fortuneText when prediction occurs.
Type:
- string
- Source:
hutBackground :HTMLElement|null
A reference to the html element of the page which defines the background-image
Type:
- HTMLElement | null
- Source:
pageContents :HTMLElement|null
A reference to the body element of the page which includes the page contents
Type:
- HTMLElement | null
- Source:
(constant) predictButton :HTMLElement|null
A reference to a button to get the tarot card predictions
Type:
- HTMLElement | null
- Source:
(constant) resetButton :HTMLElement|null
A reference to reset button to get new fortune
Type:
- HTMLElement | null
- Source:
(constant) returnToMenuButton :HTMLElement|null
A reference to back button HTMlElement on card.html
Type:
- HTMLElement | null
- Source:
(constant) saveButton :HTMLElement|null
A reference to a button to save the fortune to localStorage
Type:
- HTMLElement | null
- Source:
(constant) saveReadingsButton :HTMLElement|null
A reference to a button to save the fortune to localStorage
Type:
- HTMLElement | null
- Source:
(constant) savedReadingsButton :HTMLElement|null
A reference to Saved Readings button HTMlElement on menu.html
Type:
- HTMLElement | null
- Source:
selectBuffer :Array.<string>
Array containing the id strings of all selected cards
Type:
- Array.<string>
- Source:
selectCount :number
A reference to the number of cards the user wants to select
Type:
- number
- Source:
(constant) tarotCards :HTMLCollection.<img>|null
A reference to all card images
Type:
- HTMLCollection.<img> | null
- Source:
(constant) titles :HTMLCollection.<String>
Array of category Buttons to create
Type:
- HTMLCollection.<String>
- Source:
typeOutputInterval
A reference to the output interal for typing the fortune to the screen
- Source:
Methods
addFortune(fortuneText, category, date)
This function adds a fortune to localStorage. Does not add the fortune if it
is a duplicate of another fortune already in localStorage.
Parameters:
Name | Type | Description |
---|---|---|
fortuneText |
string | the text of the fortune |
category |
string | the category of the fortune |
date |
Date | a JavaScript Date object |
- Source:
backToMenu()
This function sends the user back to the menu page
- Source:
centerSelectedCard()
Function to center the selected card.
Triggered when Predict button is clicked.
ASSUMPTION: Only one Card is Selected.
- Source:
checkDuplicate(fortune)
Takes in a fortune array containing the fortuneText, category, and date and
checks if there is another fortune in local storage that matches this fortune.
Returns the index of the fortune in the localStorage array otherwise returns
-1 if does not exist.
Parameters:
Name | Type | Description |
---|---|---|
fortune |
Array.<Object> |
- Source:
chooseCard()
Function enables the selection of cards on the fortune generation page. When
a card is selected, it is added to a buffer that keeps track of selected cards
as space and category allows. When buffer grows too big, remove first element
in buffer and add the new element. Selected card has permanent box shadow
- Source:
clearFortunes()
This function clears the localStorage of (only) fortunes and
calls the displayFortunes function to update the display to
be cleared of fortunes. This function is called by the
event listener added to tempClearButton. This is meant to be a
temporary fuction used help test, but it could be useful for
the actual page.
- Source:
createCategoryButtons()
A function used for an event listener which is responsible for creating the
category Buttons with each category when the page is loaded
- Source:
deleteFortune(fortuneIndex)
Function that enables the individual deletion of fortunes from the saved-reading pages.
We pass the index of the fortune that it has in the localstorage array
and splice the array to remove that one index. Check if it the index is greater
than -1.
Parameters:
Name | Type | Description |
---|---|---|
fortuneIndex |
number | the index of the fortune in the localstorage array |
- Source:
dewooshCards()
Function to dewoosh or animate to the left into a deck the unselected cards
Triggered when Predict button is clicked.
Assumption: Number of Cards that could be selected from are 6
- Source:
displayFortunes()
Uses getFortunes and displays the fortunes it
gets on the page with a div element for each fortune. Every
time this function is called, it clears everything in the
element refered to by history and re-adds each fortune to the
page. The date values of the fortunes are displayed according to
the locale of the browser. So if your browser uses Spanish
for the UI, the date would be in Spanish.
- Source:
enterHut()
This function is responsible for removing the contents of the page and
triggering the animation of zooming into the hut while also redirecting
to the menu page after zooming in enough.
- Source:
generateNonDuplicateRandomNumbers(min, max, count) → {Array.<number>}
Generates an array of non-duplicate random numbers within a given range.
Parameters:
Name | Type | Description |
---|---|---|
min |
number | The minimum value of the range (inclusive). |
max |
number | The maximum value of the range (inclusive). |
count |
number | The number of random non-duplicate numbers to generate. |
- Source:
Returns:
An array of non-duplicate random numbers.
- Type
- Array.<number>
(async) generatePrediction()
A function used for an event listener in order to generate the prediction
when the user has selected their cards
- Source:
getFortunes() → {Array.<Object>}
Retrieves fortunes from localStorage and returns an array
of fortunes. If nothing in local storage, it returns an empty array.
Parameters:
Type | Description |
---|---|
string | the text of the fortune |
string | the category of the fortune |
- Source:
Returns:
- an array of fortunes, each with fortune, category,
and date elements
- Type
- Array.<Object>
goToSavedReadings()
Function that changes the page to the save readings page (only after click
sound effect has finished)
- Source:
init()
Function containing all intial setup functions for generating cards
and event listeners for the buttons on the page
- Source:
init()
Function adding event listeners for the buttons on the page
and calling the function to display fortunes.
- Source:
returnToMenu()
Function that changes to page back to the main menu (only after click sound
effect has finished)
- Source:
saveFortune()
Function to save a fortune to localStorage for later display on the save
fortunes page. Executes when the save fortune button is pressed
- Source:
setCardLink()
A function used for an event listener which is responsible for performing the
necessary actions when a card is clicked on by the user such as saving card
category type and redirecting them
- Source:
setLandingLink()
A function used for an event listener which is responsible for performing the
necessary actions when the landing page is clicked on by the user
- Source:
setSavedReadingsLink()
A function used for an event listener which is responsible for performing the
necessary actions when the saved readings page is clicked
- Source:
toMenuPage()
This function sends the user to the menu page where they can select what type
of fortune they would like to receive and is called after a timeout to allow
for the animation to trigger.
- Source:
typePrediction(prediction)
Takes in the prediction generate and types out the
prediction results by updating the html content character
by character
Parameters:
Name | Type | Description |
---|---|---|
prediction |
string | Predition result to be typed out |
- Source:
wooshCards()
Function to woosh or animate to the cards from a deck on the left
to being layed out for the user to pick
Triggered when the page is loaded.
Assumption: Number of Cards that could be selected from are 6
- Source: