Skip to content

Commit

Permalink
Added option to display profile image on tweets
Browse files Browse the repository at this point in the history
  • Loading branch information
pinceladasdaweb committed Oct 18, 2015
1 parent e09f1eb commit e0705ef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build/tweetlight.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 12 additions & 9 deletions src/tweetlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
return new Tweetlight(options);
}

this.username = options.username;
this.hashtag = options.hashtag;
this.container = options.container;
this.counter = options.counter;
this.endpoint = '../request.php';
this.onComplete = options.onComplete || function () {};
this.username = options.username;
this.hashtag = options.hashtag;
this.container = options.container;
this.counter = options.counter;
this.showImageProfile = options.showImageProfile || false;
this.endpoint = '../request.php';
this.onComplete = options.onComplete || function () {};

this.fetch();
};
Expand Down Expand Up @@ -70,12 +71,14 @@
}
},
displayTweets: function (tweets) {
var timeline = document.querySelector(this.container), content = '', i;
var timeline = document.querySelector(this.container), content = '', imageProfile, i;

for (i in tweets) {
if (tweets.hasOwnProperty(i)) {
if (tweets[i].text) {
content += '<li><span class="tweet">' + this.twitterLinks(tweets[i].text) + '</span><span class="created">' + this.prettyDate(tweets[i].created_at) + '</span></li>';
imageProfile = this.showImageProfile ? '<img class="image-profile" src="' + tweets[i].user.profile_image_url_https + '" alt="' + tweets[i].user.name + '">' : '';

content += '<li>' + imageProfile + '<span class="tweet">' + this.twitterLinks(tweets[i].text) + '</span><span class="created">' + this.prettyDate(tweets[i].created_at) + '</span></li>';
}
}
}
Expand All @@ -85,7 +88,7 @@
displayError: function (tweets) {
var timeline = document.querySelector(this.container);

timeline.innerHTML = '<li class="error">' + tweets.errors.message + '</li>';
timeline.innerHTML = '<li class="error">' + tweets.errors[0].message + '</li>';
},
prettyDate: function (dateString) {
var rightNow = new Date(),
Expand Down

0 comments on commit e0705ef

Please sign in to comment.