I am stuck with this project. I am having only one code for the quote, And I want to do more than one quote.
This is my code.
<html lang="en"><head>
<meta charset="UTF-8">
<link rel="apple-touch-icon" type="image/png" href="https://cpwebassets.codepen.io/assets/favicon/apple-touch-icon-5ae1a0698dcc2402e9712f7d01ed509a57814f994c660df9f7a952f3060705ee.png">
<meta name="apple-mobile-web-app-title" content="CodePen">
<link rel="shortcut icon" type="image/x-icon" href="https://cpwebassets.codepen.io/assets/favicon/favicon-aec34940fbc1a6e787974dcd360f2c6b63348d4b1f4e06c77743096d55480f33.ico">
<link rel="mask-icon" type="image/x-icon" href="https://cpwebassets.codepen.io/assets/favicon/logo-pin-8f3771b1072e3c38bd662872f6b673a722f4b3ca2421637d5596661b4e2132cc.svg" color="#111">
<title>CodePen - FCC : Random Quote Machine</title>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<style>
@import url("https://fonts.googleapis.com/css?family=Raleway:400,500");
* {
margin: 0;
padding: 0;
list-style: none;
vertical-align: baseline;
}
div {
position: relative;
z-index: 2;
}
body {
background-color: #333;
color: #333;
font-family: "Raleway", sans-serif;
font-weight: 400;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.footer {
width: 450px;
text-align: center;
display: block;
margin: 15px auto 30px auto;
font-size: 0.8em;
color: #fff;
}
.footer a {
font-weight: 500;
text-decoration: none;
color: #fff;
}
#quote-box {
border-radius: 3px;
position: relative;
width: 450px;
padding: 40px 50px;
display: table;
background-color: #fff;
}
#quote-box .quote-text {
text-align: center;
width: 450px;
height: auto;
clear: both;
font-weight: 500;
font-size: 1.75em;
}
#quote-box .quote-text i {
font-size: 1em;
margin-right: 0.4em;
}
#quote-box .quote-author {
width: 450px;
height: auto;
clear: both;
padding-top: 20px;
font-size: 1em;
text-align: right;
}
#quote-box .buttons {
width: 450px;
margin: auto;
display: block;
}
#quote-box .buttons .button {
height: 38px;
border: none;
border-radius: 3px;
color: #fff;
background-color: #333;
outline: none;
font-size: 0.85em;
padding: 8px 18px 6px 18px;
margin-top: 30px;
opacity: 1;
cursor: pointer;
}
#quote-box .buttons .button:hover {
opacity: 0.9;
}
#quote-box .buttons .button#tweet-quote, #quote-box .buttons .button#tumblr-quote {
float: left;
padding: 0px;
padding-top: 8px;
text-align: center;
font-size: 1.2em;
margin-right: 5px;
height: 30px;
width: 40px;
}
#quote-box .buttons .button#new-quote {
float: right;
}
</style>
<script>
window.console = window.console || function(t) {};
</script>
<script>
if (document.location.search.match(/type=embed/gi)) {
window.parent.postMessage("resize", "*");
}
</script>
</head>
<body translate="no" style="background-color: rgb(52, 34, 36); color: rgb(52, 34, 36);">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<div id="wrapper">
<div id="quote-box">
<div class="quote-text" style="opacity: 1;">
<i class="fa fa-quote-left"> </i><span id="text">The most difficult thing is the decision to act, the rest is merely tenacity.</span>
</div>
<div class="quote-author" style="opacity: 1;">- <span id="author">Amelia Earhart</span></div>
<div class="buttons">
<a class="button" id="tweet-quote" title="Tweet this quote!" target="_top" href="https://twitter.com/intent/tweet?hashtags=quotes&related=freecodecamp&text=%22The%20most%20difficult%20thing%20is%20the%20decision%20to%20act%2C%20the%20rest%20is%20merely%20tenacity.%22%20Amelia%20Earhart" style="background-color: rgb(52, 34, 36);">
<i class="fa fa-twitter"></i>
</a>
<a class="button" id="tumblr-quote" title="Post this quote on tumblr!" target="_blank" href="https://www.tumblr.com/widgets/share/tool?posttype=quote&tags=quotes,freecodecamp&caption=Amelia%20Earhart&content=The%20most%20difficult%20thing%20is%20the%20decision%20to%20act%2C%20the%20rest%20is%20merely%20tenacity.&canonicalUrl=https%3A%2F%2Fwww.tumblr.com%2Fbuttons&shareSource=tumblr_share_button" style="background-color: rgb(52, 34, 36);">
<i class="fa fa-tumblr"></i>
</a>
<button class="button" id="new-quote" style="background-color: rgb(52, 34, 36);">New quote</button>
</div>
</div>
<div class="footer">by <a href="https://codepen.io/hezag/">hezag</a></div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.0/jquery-ui.min.js"></script>
<script src="https://cpwebassets.codepen.io/assets/common/stopExecutionOnTimeout-1b93190375e9ccc259df3a57c1abc0e64599724ae30d7ea4c6877eb615f89387.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.0/jquery-ui.min.js"></script>
<script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script><div id="fcc_test_suite_wrapper" style="position: relative !important; z-index: 99999 !important;"></div>
<script id="rendered-js">
/* eslint-disable max-len */
// eslint-disable-next-line no-unused-vars
const projectName = 'random-quote-machine';
let quotesData;
/*
Code by Gabriel Nunes
Modified by Todd Chaffee to use Camper gist for JSON Quote data.
*/
var colors = [
'#16a085',
'#27ae60',
'#2c3e50',
'#f39c12',
'#e74c3c',
'#9b59b6',
'#FB6964',
'#342224',
'#472E32',
'#BDBB99',
'#77B1A9',
'#73A857'];
var currentQuote = '',
currentAuthor = '';
function getQuotes() {
return $.ajax({
headers: {
Accept: 'application/json' },
url:
'https://gist.githubusercontent.com/camperbot/5a022b72e96c4c9585c32bf6a75f62d9/raw/e3c6895ce42069f0ee7e991229064f167fe8ccdc/quotes.json',
success: function (jsonQuotes) {
if (typeof jsonQuotes === 'string') {
quotesData = JSON.parse(jsonQuotes);
console.log('quotesData');
console.log(quotesData);
}
} });
}
function getRandomQuote() {
return quotesData.quotes[
Math.floor(Math.random() * quotesData.quotes.length)];
}
function getQuote() {
let randomQuote = getRandomQuote();
currentQuote = randomQuote.quote;
currentAuthor = randomQuote.author;
$('#tweet-quote').attr(
'href',
'https://twitter.com/intent/tweet?hashtags=quotes&related=freecodecamp&text=' +
encodeURIComponent('"' + currentQuote + '" ' + currentAuthor));
$('#tumblr-quote').attr(
'href',
'https://www.tumblr.com/widgets/share/tool?posttype=quote&tags=quotes,freecodecamp&caption=' +
encodeURIComponent(currentAuthor) +
'&content=' +
encodeURIComponent(currentQuote) +
'&canonicalUrl=https%3A%2F%2Fwww.tumblr.com%2Fbuttons&shareSource=tumblr_share_button');
$('.quote-text').animate({ opacity: 0 }, 500, function () {
$(this).animate({ opacity: 1 }, 500);
$('#text').text(randomQuote.quote);
});
$('.quote-author').animate({ opacity: 0 }, 500, function () {
$(this).animate({ opacity: 1 }, 500);
$('#author').html(randomQuote.author);
});
var color = Math.floor(Math.random() * colors.length);
$('html body').animate(
{
backgroundColor: colors[color],
color: colors[color] },
1000);
$('.button').animate(
{
backgroundColor: colors[color] },
1000);
}
$(document).ready(function () {
getQuotes().then(() => {
getQuote();
});
$('#new-quote').on('click', getQuote);
});
//# sourceURL=pen.js
</script>
</body></html>