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.
<head>
<script src="https://use.fontawesome.com/c0dce8fba3.js"></script>
</head>
<div class="outerBox">
<div class="buttons" id="topButton"><!--top button-->
<button type="button" class="btn btn-default btn-lg">New Quote</button>
</div>
<div class="quote"><!--text quote area-->
<h1></h1>
</div>
<div class="author"><!--author-->
<p></p>
</div>
<div id="botButton"><!--bottom button-->
<a class="btn btn-default btn-lg"
href="https://twitter.com/home/?status=absdjasdka"
target="_blank">
<span class="fa fa-twitter-square"></span>
Tweet</a>
</div>
</div>
body{
background-color: #E6E6FA;
}
.outerBox{
border-radius: 20px;
background-color: #87CEFA;
position: relative;
width: 500px;
margin: auto;
top: 80px;
padding: 40px;
}
.quote{
width:400px;
padding: 10px;
text-align: center;
}
.author{
margin-right: 5%;
text-align: right;
padding: 10px;
}
#topButton{
margin-left: 35%;
padding-bottom: 20px;
}
#botButton{
margin-left: 38%;
padding-top: 20px;
}
$(document).ready(function(){
$.ajax({
url: 'https://andruxnet-random-famous-quotes.p.mashape.com/', // The URL to the API
type: 'GET', // The HTTP Method, can be GET POST PUT DELETE etc
dataType: 'json',
success: function(data) {
$('.quote h1').text(data.quote).prepend('"').append('"');
$('.author').text(data.author);
$('#botButton a').replaceWith('<a class="btn btn-default btn-lg" href="https://twitter.com/home/?status='+ data.quote+'%20'+'%28'+data.author+'%29'+'" target="_blank"><span class="fa fa-twitter-square"></span> Tweet</a>');
},
error: function(err) {
alert(err);
},
beforeSend: function(xhr) {
xhr.setRequestHeader("X-Mashape-Authorization", "FBozgJ3jMGmshCl5vNX6duTY1Zuop1wJypcjsnL0HOmBEK4Jm4"); // Enter here your Mashape key
}
});
$('#topButton').on('click',function(){
$.ajax({
url: 'https://andruxnet-random-famous-quotes.p.mashape.com/', // The URL to the API
type: 'GET', // The HTTP Method, can be GET POST PUT DELETE etc
dataType: 'json',
success: function(data) {
$('.quote h1').text(data.quote).prepend('"').append('"');
$('.author').text(data.author);
$('#botButton a').replaceWith('<a class="btn btn-default btn-lg" href="https://twitter.com/home/?status='+ data.quote+'%20'+'%28'+data.author+'%29'+'" target="_blank"><span class="fa fa-twitter-square"></span> Tweet</a>');
},
error: function(err) {
alert(err);
},
beforeSend: function(xhr) {
xhr.setRequestHeader("X-Mashape-Authorization", "FBozgJ3jMGmshCl5vNX6duTY1Zuop1wJypcjsnL0HOmBEK4Jm4"); // Enter here your Mashape key
}
});
});
});
Also see: Tab Triggers