-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
23 lines (16 loc) · 757 Bytes
/
script.js
File metadata and controls
23 lines (16 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var url = "https://api.forismatic.com/api/1.0/?method=getQuote&key=457653&format=jsonp&lang=en&jsonp=?";
var getQuote = function(data) {
$(".message").html( '<i class="fa fa-quote-left" aria-hidden="true">' + '</i>' + ' ' +
data.quoteText + '<i class="fa fa-quote-right" aria-hidden="true">' + '</i>' + ' ' );
var quot = 'https://twitter.com/intent/tweet?hashtags=quotes&text=' + data.quoteText + ' \nSource:' + data.quoteAuthor ;
if (data.quoteAuthor === '') {
data.quoteAuthor = 'Unknown';
}
$("#quote-source").html('— ' + data.quoteAuthor);
$(".twitter-share-button").attr("href", quot);
};
$(document).ready(function(){
$('#getquote').on('click', function(){
$.getJSON(url, getQuote,'jsonp')
});
});