Skip to content

Commit

Permalink
Changed loading function name to LoadingSpinner.
Browse files Browse the repository at this point in the history
  • Loading branch information
naijamesz committed Oct 3, 2023
1 parent 163bb0e commit a5492d1
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ const newQuoteBtn = document.getElementById('new-quote')
const loader = document.getElementById('loader')

let apiQuotes = []
// Loading Spinner Shown
function loading() {
// Loading Spinner Show
function showLoadingSpinner() {
loader.hidden = false
quoteContainer.hidden = true
}

// Remove Loading Spinner
function complete() {
function removeLoadingSpinner() {
quoteContainer.hidden = false
loader.hidden = true
}

// Show New Quote
function newQuote() {
loading()
showLoadingSpinner()
// Pick a random quote from apiQuotes array
const quote = apiQuotes[Math.floor(Math.random() * apiQuotes.length)]
// check if author field is blank and replace it with 'Unknown'
Expand All @@ -37,12 +37,12 @@ function newQuote() {
}
// Set Quote, Hide Loader
quoteText.textContent = quote.text
complete() // call function complete
removeLoadingSpinner() // call function removeLoadingSpinner
}

// Get Quotes From API
async function getQuotes() {
loading()
showLoadingSpinner()
const apiUrl = 'https://jacintodesign.github.io/quotes-api/data/quotes.json'
try {
const response = await fetch(apiUrl)
Expand Down Expand Up @@ -75,20 +75,20 @@ getQuotes()
// let apiQuotes = []

// // Loading Spinner Shown
// function loading() {
// function showLoadingSpinner() {
// loader.hidden = false
// quoteContainer.hidden = true
// }

// // Remove Loading Spinner
// function complete() {
// function removeLoadingSpinner() {
// quoteContainer.hidden = false
// loader.hidden = true
// }

// // Show New Quote
// function newQuote() {
// loading()
// showLoadingSpinner()
// // Pick a random quote from apiQuotes array
// const quote = apiQuotes[Math.floor(Math.random() * apiQuotes.length)]
// // Check if Author field is blank and replace it with 'Unknown'
Expand All @@ -105,12 +105,12 @@ getQuotes()
// }
// // Set Quote, Hide Loader
// quoteText.textContent = quote.text
// complete()
// removeLoadingSpinner()
// }

// // Get Quotes From API
// async function getQuotes() {
// loading()
// showLoadingSpinner()
// const apiUrl = 'https://type.fit/api/quotes'
// try {
// const response = await fetch(apiUrl)
Expand Down

0 comments on commit a5492d1

Please sign in to comment.