Last active
December 21, 2015 13:48
-
-
Save sTiLL-iLL/6314713 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Options: | |
* - before (string): HTML code before the tweet. | |
* - after (string): HTML code after the tweet. | |
* - tweets (numeric): number of tweets to display. | |
* | |
* Example: | |
* | |
* <script type="text/javascript" charset="utf-8"> | |
* $(document).ready(function() { | |
* $('#tweets').tweets({ | |
* tweets:114, | |
* username: "developer1" | |
* }); | |
* }); | |
* </script> | |
* | |
*/ | |
(function ($) { | |
$.fn.tweets = function (ops) { | |
$.ajaxSetup({ cache: true }); | |
var dfs = { | |
tweets: 5, | |
before: "<li>", | |
after: "</li>" | |
}; | |
var oNd = $.extend(dfs, ops); | |
return this.each(function () { | |
var obj = $(this); | |
$.getJSON('http://api.twitter.com/1/statuses/user_timeline.json?callback=?&screen_name=' + | |
oNd.username + '&count=' + oNd.tweets, | |
function (data) { | |
$.each(data, function (i, t) { | |
if (t.text !== undefined) { | |
$(obj).append(oNd.before + t.text + oNd.after); | |
} | |
}); | |
} | |
); | |
}); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment