-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
33 lines (25 loc) · 1.1 KB
/
main.js
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
26
27
28
29
30
31
$(document).ready(function(){
randomQuote();
$('#new-quote').on("click",randomQuote);
});
function randomQuote(){
$(".quote-text, .quote-author,.quote-text>i").animate({
opacity: '0'
},500);
var randomColorChange = '#'+(Math.random()*0xFFFFFF<<0).toString(16);
$('body').css('background',randomColorChange);
$('body').css('color',randomColorChange);
$('#new-quote').css('background',randomColorChange);
$.getJSON("https://api.forismatic.com/api/1.0/?method=getQuote&format=jsonp&lang=en&jsonp=?",function(json){
// var obj=$.parseJSON(json);
var quote=json['quoteText'];
var author=json['quoteAuthor'];
author=author===""?"unknown":author;
$('#text').html(quote);
$('#author').html(author);
$('#twitter').attr("href", 'https://twitter.com/intent/tweet?hashtags=quotes&related=RandomQuoteMachine&text=' + "\""+quote+"\""+" - "+author);
$(".quote-text, .quote-author").animate({
opacity: '1'
},500);
});
}