JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
HTML Settings
Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
<link href="https://fonts.googleapis.com/css?family=Gloria+Hallelujah" rel="stylesheet">
<div id="background" class="container" style="margin-top:300px">
<div class="jumbotron">
<h1>My Random Quote Generator</h1>
<p id="aQuote">Push my button to get a quote...</p>
<button id="mybutton" class="btn btn-primary" type="button" name="button">Next Quote</button>
</div>
<!-- Twitter Button -->
<a id="tweetIt" class="twitter-share-button" href="#" data-show-count="false" target="_blank">Tweet</a>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
</div>
body{
font-family: 'Gloria Hallelujah', cursive;
text-align: center;
background-repeat: no-repeat;
background-size: cover;
height: 100%;
}
#background{
height: 100vh;
}
var quotes = [
{ "quoter": "Star Wars", "category": "movie", "quote": "May the Force be With You"},
{ "quoter": "Dave Matthews", "category": "music", "quote": "Everybody asks me how she's doing, has she really lost her mind? I couldn't tell you, I've lost mine."},
{ "quoter": "Albert Einstein" , "category": "person" , "quote": "Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning."},
{ "quoter": "Field of Dreams", "category": "movie", "quote": "If you build it, he will come."},
{ "quoter": "Young Frankenstein", "category": "movie", "quote": "Put The Candle Back."},
{ "quoter": "Jim Morrison", "category": "music", "quote": "Expose yourself to your deepest fear; after that, fear has no power. You are free."}
];
var backgrounds = {"movie": "url(http://cdn.wallpapersafari.com/11/10/jfS4bg.jpg)",
"music": "url(http://images.all-free-download.com/images/graphiclarge/music_notes_background_188016.jpg)",
"person": "url(http://210.211.97.114:84/appimages/images/contents/h/i/historical-picture-material-of-the-paper-series-26-0.jpg)"
};
function randomIndex(){ return index = Math.floor(Math.random() * quotes.length);}
function retrieveQuote(index){
// return quotes[index].quote + " - " + retrieveQuoter(index);
return quotes[index].quote;
}
function retrieveQuoter(index){ return quotes[index].quoter; }
function getCategory(index){
return quotes[index].category;
}
function retrieveBackground(index){
return backgrounds[getCategory(index)];
}
$(document).ready(function(){
$("#mybutton").hover(
function(){ $("#mybutton").html("Do it....");},
function(){ $("#mybutton").html("Next Quote");}
);
$("#mybutton").click(function(){
$("p").empty();
var index = randomIndex();
var myQuote = retrieveQuote(index);
var myQuoter = retrieveQuoter(index);
$("#aQuote").html(myQuote + "<br /> -" + myQuoter);
$("body").css("background-image", retrieveBackground(index));
console.log(encodeURI(myQuote+"- "+myQuoter));
$("#tweetIt").attr("href", "https://twitter.com/home?status="+encodeURI(myQuote+"- "+myQuoter));
});
});
Also see: Tab Triggers