Skip to content

Instantly share code, notes, and snippets.

@juniorbird
Last active June 24, 2017 22:54
Show Gist options
  • Save juniorbird/7fc787119a62198e6eb4438547d3e942 to your computer and use it in GitHub Desktop.
Save juniorbird/7fc787119a62198e6eb4438547d3e942 to your computer and use it in GitHub Desktop.
Taco customization with quote of the day
<iframe src="https://juniorbird.github.io/quotes-for-taco/" frameborder="0" width="100%"></iframe>
<script>
// Use the They Said So API https://theysaidso.com/api/
const quoteSource = 'https://quotes.rest/qod.json?category=inspire';
function setText(quote, author) {
let quoteDiv = document.getElementById('quote');
let authorDiv = document.getElementById('author');
quoteDiv.innerText = quote;
authorDiv.innerText = author;
return true;
}
fetch(quoteSource, { mode: 'cors' })
.then(res => res.json())
.then(data => setText(
data.contents.quotes[0].quote,
data.contents.quotes[0].author
));
</script>
<style type="text/css">
p#author {
text-align: right;
font-size: .6em;
font-style: normal;
opacity: .6;
}
div#fancyquotebox {
font-size: 2.3em;
padding: 0em 1em;
font-style: italic;
opacity: 0.75;
}
</style>
<div id = "fancyquotebox">
<p id = "quote">Quote Loading...</p>
<p id = "author">Author Loading...</p>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment