FreeCodeCamp - Random Quote Generator

Developer
Size
3,218 Kb
Views
44,528

How do I make an freecodecamp - random quote generator?

What is a freecodecamp - random quote generator? How do you make a freecodecamp - random quote generator? This script and codes were developed by Jason Thomas on 14 September 2022, Wednesday.

FreeCodeCamp - Random Quote Generator Previews

FreeCodeCamp - Random Quote Generator - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>freeCodeCamp - Random Quote Generator</title> <link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="container rounded"> <h2>Random Quotes</h2> <div class = "col-xs-12 well message"> <div id="quote"> <div class="message"></div><div id="quote-text"></div><div id="author" class="text-right"></div>
</div> </div> <div class = "col-xs-12"> <button class = "btn btn-primary" id="getMessage">New Quote</button><a href="#" class = "btn_tweet btn btn-primary btn-success" id="tweet-button" >Tweet Quote!</a> </div> <hr class="my-4"> <footer>API provided by <a href="https://forismatic.com/">forismatic.com</a></footer>
</div>
<script type="text/javascript" async src="https://platform.twitter.com/widgets.js"></script> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

FreeCodeCamp - Random Quote Generator - Script Codes CSS Codes

body { background-image:url(https://dl.dropboxusercontent.com/s/sd94nplro9c2rww/asanoha-400px.png?dl=0); padding-top:100px;
}
@media (min-width: 500px) { .container{ max-width: 500px; }
}
.container{ background: rgba(247,247,247, .6); color: #4d4d4d; padding: 10px; border-style: dashed; border-width: 1px;
}
#author { color:#ba0123;
}
.btn_tweet { margin-left:15px; color:white;
}
.btn_tweet a:hover,
.btn_tweet a:active,
.btn_tweet a:link,
.btn_tweet a:visited { color:white;
}
footer { margin-top:10px;
}

FreeCodeCamp - Random Quote Generator - Script Codes JS Codes

/*
This code was written with the help of Julian Aramburu: https://codepen.io/julianaramburu/pen/GpJYoX
*/
$(document).ready(function() { $("#getMessage").on("click", function(quote, quoter) { var quoter = $('#author'); var quote = $('#quote-text'); /*The object below contains all the dropbox links for the random backgrounds*/ var myData = { 1: { imageUrl: "https://dl.dropboxusercontent.com/s/g8nb1id94cx90hg/weather.png?dl=0", }, 2: { imageUrl: "https://dl.dropboxusercontent.com/s/h4bqjmkun1z192r/seigaiha.png?dl=0", }, 3: { imageUrl: "https://dl.dropboxusercontent.com/s/gtyhw0dmckgkbiy/sayagata-400px.png?dl=0", }, 4: { imageUrl: "https://dl.dropboxusercontent.com/s/dk4rs9b4rrr4ras/sakura.png?dl=0", }, 5: { imageUrl: "https://dl.dropboxusercontent.com/s/yg43ce8e42fdkzm/pink%20dust.png?dl=0", }, 6: { imageUrl: "https://dl.dropboxusercontent.com/s/qsnmsem7s3p8198/new_year_background.png?dl=0", }, 7: { imageUrl: "https://dl.dropboxusercontent.com/s/cy6rf50zcnix4cl/ep_naturalwhite.png?dl=0", }, 8: { imageUrl: "https://dl.dropboxusercontent.com/s/kpb6b30hpxpbn63/ep_naturalblack.png?dl=0", }, 9: { imageUrl: "https://dl.dropboxusercontent.com/s/2r29tlwtlv5cmuf/cork-wallet.png?dl=0" }, 10: { imageUrl: "https://dl.dropboxusercontent.com/s/ex6purrqkm728ro/circles-and-roundabouts.png.png?dl=0" }
}; /*Get the API amd the data */ $.getJSON("https://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=?", function(data) {
quote.html(data.quoteText); if (data.quoteAuthor) { quoter.html("- " + data.quoteAuthor); /*If there is an author then add the author's name otherwise add anonymous*/ quoter.attr("href", data.quoteLink); } else { quoter.removeAttr("href"); quoter.html("- Anonymous"); } tweetThis = data.quoteText + " By - " + data.quoteAuthor; }); var randomNumber = Math.floor((Math.random() * 10) + 1); /* A random background is chosen when the button is hit*/ document.body.style.backgroundImage = "url('"+myData[randomNumber].imageUrl+"')"; /*tweet quote button is disabled when there are to many characters*/ $('#tweet-button').removeClass("disabled"); $('#tweet-button').html("Tweet Quote!"); }); });
/*The function for the tweet quote button*/
var tweetThis = "";
$('#tweet-button').click(function() { if (tweetThis.length > 140) { tweetThis = ""; $(this).addClass("disabled"); $(this).html("Sorry! 140 chars exceeded!"); } else { $(this).attr("href", "https://twitter.com/intent/tweet?text=" + tweetThis); }
})
FreeCodeCamp - Random Quote Generator - Script Codes
FreeCodeCamp - Random Quote Generator - Script Codes
Home Page Home
Developer Jason Thomas
Username samoht513
Uploaded September 14, 2022
Rating 3
Size 3,218 Kb
Views 44,528
Do you need developer help for FreeCodeCamp - Random Quote Generator?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Jason Thomas (samoht513) Script Codes
Create amazing marketing copy with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!