| 26 | // Get Qutotes From API |
| 27 | |
| 28 | function newQuote() { |
| 29 | loading(); |
| 30 | const quote = apiQuotes[Math.floor(Math.random() * apiQuotes.length)]; |
| 31 | // console.log(quote); |
| 32 | |
| 33 | |
| 34 | // check if Author field is blank and replace it with 'Unknown' |
| 35 | if (!quote.author){ |
| 36 | authorText.textContent = 'Unknown'; |
| 37 | } else { |
| 38 | authorText.textContent = quote.author; |
| 39 | } |
| 40 | // Check Quote length to determine styling |
| 41 | if (quote.text.length > 50) { |
| 42 | quoteText.classList.add('long-quote'); |
| 43 | } else { |
| 44 | quoteText.classList.remove('long-quote'); |
| 45 | } |
| 46 | quoteText.textContent = quote.text; |
| 47 | complete(); |
| 48 | } |
| 49 | |
| 50 | async function getQuotes(){ |
| 51 | loading(); |