-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuote Machine.js
73 lines (40 loc) · 1.21 KB
/
Quote Machine.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
$(document).ready(function(){
$("#get-quote").on("click", function(event){
// Prevents the button from opening a new link
event.preventDefault();
$.ajax({
url: "https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1",
success: function(data){
$(".author").fadeOut("slow");
$(".quote").fadeOut("slow", function(){
$("body").animate({
// Background color will be random every time the button is clicked
backgroundColor: '#'+(Math.random()*0xFFFFFF<<0).toString(16)
}, {
queue: false
});
applyQuote(data[0].content, "- " + data[0].title);
$(".quote").fadeIn({
duration: 400,
queue: false
});
$(".author").fadeIn({
duration: 400,
queue: false
});
});
},
cache: false
});
});
});
function applyQuote(quote, author){
$(".quote").html(quote);
$(".author").html(author);
quote = quote.replace("</p>", "");
quote = quote.replace(" </p>", "");
quote = quote.replace("<p>", "");
$("#twitter-link").attr("href", "https://twitter.com/intent/tweet?text=" + encodeURIComponent(quote));
}
function animateQuote(data){
}