-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.js
More file actions
25 lines (22 loc) · 869 Bytes
/
code.js
File metadata and controls
25 lines (22 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$(document).ready(function() {
function getQuote() {
$.ajax({
headers: {
'X-Mashape-Key': 'gXCPrfTiawmsh9gtszFXIUT4piPZp1Ipk4ljsnQRoT0zyUNu4V',
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/json'
},
url: 'https://andruxnet-random-famous-quotes.p.mashape.com/?cat=',
method: 'POST',
}).done(function(res) {
res = JSON.parse(res);
var tweet = encodeURI(res.quote+'\n- '+res.author);
var tweetUrl = 'https://twitter.com/intent/tweet?text='+tweet;
console.log(tweet);
$("#a-twitter").attr("href", tweetUrl);
$("#i-quote").text(res.quote);
$("#p-author").text('- '+res.author);
});
}
$("#a-quote").on("click", getQuote);
});