vendredi 3 mars 2017

code review. what 1st condition should be?

ok so i want to get random quote(s) through API(forismatic.com) and if it have 140 letters share via tweeter.

var tweetLink = "https://twitter.com/intent/tweet?text=";
var quoteUrl = "http://ift.tt/2mBZYCq?";
function getQuote() {
$.getJSON(quoteUrl, createTweet);
}
function createTweet(input) {


if (!input.quoteAuthor.length) {
    input.quoteAuthor = "Unknown author";
}
var tweetText = "Quote of the day - " + input.quoteText + " Author: " + input.quoteAuthor;
    if (tweetText.length > 140) {
getQuote();
} else {
var tweet = tweetLink + encodeURIComponent(tweetText);
$('.quote').text(input.quoteText);
$('.author').text("Author: " + input.quoteAuthor);
$('.tweet').attr('href', tweet);
}
}
  $(document).ready(function() {
getQuote();
$('.trigger').click(function() {
    getQuote();
})
});

Aucun commentaire:

Enregistrer un commentaire