-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
39 lines (34 loc) · 1.47 KB
/
script.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
$(document).ready( function() {
$.getJSON("https://raw.githubusercontent.com/pwizla/saucedallas/gh-pages/quotes.json", function(json) {
console.log('How many quotes in the json file? ', json.contents.quotes.length);
var whichQuote = Math.floor(Math.random() * (json.contents.quotes.length));
console.log('whichQuote', whichQuote);
quote = '"' + json.contents.quotes[whichQuote].quote + '"';
$(".quote").html(quote);
getTweetContent();
});
$("#getQuote").click(function () {
$.getJSON("https://raw.githubusercontent.com/pwizla/saucedallas/gh-pages/quotes.json", function(json) {
console.log('How many quotes in the json file? ', json.contents.quotes.length);
whichQuote = Math.floor(Math.random() * (json.contents.quotes.length));
console.log('whichQuote', whichQuote);
quote = '"' + json.contents.quotes[whichQuote].quote + '"';
$(".quote").html(quote);
getTweetContent();
});
});
function getTweetContent () {
var quoteToTweet = $(".quote").html();
quoteToTweet = quoteToTweet.replace(/<br>/g, ' ');
console.log('quoteToTweet: ', quoteToTweet);
return quoteToTweet;
if (quoteToTweet.length > 130) {
console.log("OVER LENGTH");
}
};
$("#tweetButton").click(function() {
var quoteToTweet = $(".quote").html();
quoteToTweet = quoteToTweet.replace(/<br>/g, ' ');
$("#tweetButton").attr("href", "http://twitter.com/intent/tweet?text=" + quoteToTweet + "&hashtags=Dikkenek,10ans&via=SurLesBoulettes");
});
});