Skip to content

Instantly share code, notes, and snippets.

@jasil1414
Last active October 18, 2016 09:25
Show Gist options
  • Save jasil1414/f9d7af7ef3c9a104876b530a2ae1b48d to your computer and use it in GitHub Desktop.
Save jasil1414/f9d7af7ef3c9a104876b530a2ae1b48d to your computer and use it in GitHub Desktop.
Random Quote Generator
<html>
<head>
<title> Quote Generator </title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300|Raleway" rel="stylesheet">
</head>
<body class= "container">
<div class= "wrapper">
<div class= "quote_heading"><h2>Random Quote Generator</h2></div>
<div class="quote_box">
<blockquote class="my_quotes"></blockquote>
<p id="quote_by"></p>
</div>
<div class="twitter_icon"><a target=_blank><i class="fa fa-twitter"></i> </a></div>
<div class="button_quote">
<button class="btn next_quote_button btn-primary ">Next Quote</button>
</div>
</div>
<div class="my_footer"><p>Made with <i class="fa fa-heart"></i> for Web by <span id="my_portfolio"><a href="https://jasil1414.github.io/jasil/">Jasil</a></span></p></div>
</body>
</html>
var quotes = [
{
quote: "Technology is anything that wasn’t around when you were born.",
author: "Alan Kay (Computer Scientist)"
}, {
quote: "Any sufficiently advanced technology is equivalent to magic.",
author: "Arthur C. Clarke (Author)"
}, {
quote: "All of the biggest technological inventions created by man – the airplane, the automobile, the computer – says little about his intelligence, but speaks volumes about his laziness. ",
author: "Mark Kennedy (Author)"
}, {
quote: "Just because something doesn’t do what you planned it to do doesn’t mean it’s useless.",
author: "Thomas Edison (Inventor)"
}, {
quote: "It has become appallingly obvious that our technology has exceeded our humanity.",
author: "Albert Einstein (Scientist)"
}, {
quote: "One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man.",
author: "Elbert Hubbard (Author)"
}, {
quote: "Technology is a word that describes something that doesn’t work yet.",
author: "Douglas Adams (Author)"
}, {
quote: " Humanity is acquiring all the right technology for all the wrong reasons. ",
author: "R. Buckminster Fuller (Inventor and Author)"
}, {
quote: "Art is anything people do with distinction.",
author: "Louis Dudek"
}, {
quote: "The human spirit must prevail over technology.",
author: "Albert Einstein (Scientist)"
}]
var displayedQuote = "";
var currentID;
var tweet_quote;
function quoteGenerator() {
do {
var qID = Math.floor(Math.random() * quotes.length);
} while (currentID === qID);
currentID = qID;
displayedQuote = quotes[qID];
console.log(displayedQuote);
$(".my_quotes").html(displayedQuote.quote);
$("#quote_by").html("-" + displayedQuote.author);
};
function tweetQuote(){
tweet_quote=displayedQuote.quote;
if(tweet_quote.length > 90){
tweet_quote = tweet_quote.substring(0,100);
tweet_quote=encodeURI(tweet_quote);
tweet_author=encodeURI(displayedQuote.author)
window.open("https://twitter.com/intent/tweet?text=" + "\""+tweet_quote + "..." +"\"" + "&hashtags=" + tweet_author);
}
else{
tweet_quote=encodeURI(tweet_quote);
tweet_author=encodeURI(displayedQuote.author)
window.open("https://twitter.com/intent/tweet?text=" + "\""+tweet_quote + "\"" + "&hashtags="+ tweet_author);
};
}
$(document).ready(function() {
quoteGenerator();
$(".twitter_icon").click(function() {
tweetQuote();
});
$(".next_quote_button").click(function() {
$(".quote_box").fadeOut(0);
quoteGenerator();
$(".quote_box").fadeIn(800);
});
});
<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>
body{
background-image: url("http://wallpapercave.com/wp/888eNxk.jpg");
}
.quote_heading{
font-family: "Open Sans Condensed:300", serif;
display:block;
padding-left:18%;
}
.wrapper{
padding-bottom:20px;
position:absolute;
background:rgba(30, 43, 52, .8);
color:silver;
top:50%;
left:50%;
-webkit-transform:translate(-50%,-50%);
transform:translate(-50%,-50%);
min-width:300px;
min-height:300px;
height:auto;
width:500px;
border-radius: 10px;
}
.my_quotes{
font-family:"Raleway";
font-size:1.3em;
psition:absolute;
margin-left:5%;
margin-top:5%;
}
#quote_by{
font-family:"Raleway";
font-style: italic;
font-size:1.2em;
padding:10px;
position:absolute;
left:60%;
bottom:13%;
width:40%;
height:auto;
text-align:center;
}
.twitter_icon{
position:absolute;
bottom:4%;
left:6%;
font-size:2.3em;
font-weight:bold;
background:none;
border-radius:7px;
padding:0 4px 0 4px;
}
.twitter_icon :hover{
font-size:1.2em;
color: white;
text-decoration:none;
cursor:pointer;
}
.button_quote{
position:absolute;
right:5%;
bottom:4%;
}
.btn-primary:hover {
border-color:#090d11 !important ;
background:#090d11 !important;
color:white !important;
border-radius:20px;
}
.btn-primary:active {
border-color:#090d11;
background:#090d11;
color:white;
outline:none !important;
}
.btn-primary , .btn-primary:focus {
background:silver;
border-color:silver;
color:black;
border-radius:20px;
outline:none;
}
.my_footer{
color:white;
position:absolute;
bottom:0%;
height:40px;
width:100%;
position:fixed;
background:black;
text-align:right;
padding-right:20px;
padding-bottom:10px;
padding-top:10px;
left:0;
}
#my_portfolio:hover{
font-size:1.4em;
text-decoration: none;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment