having such generic variables as feed and i global is a recipe for
trouble waiting to happen.
These variables aren't used outside of the twitter plugin, so we can
easily make them local to getTwitterFeed
... | ... |
@@ -1,13 +1,15 @@ |
1 | 1 |
// JSON-P Twitter fetcher for Octopress |
2 | 2 |
// (c) Brandon Mathis // MIT Lisence |
3 | 3 |
function getTwitterFeed(user, count, replies) { |
4 |
- feed = new jXHR(); |
|
4 |
+ var feed = new jXHR(); |
|
5 |
+ |
|
5 | 6 |
feed.onerror = function (msg,url) { |
6 | 7 |
$('#tweets li.loading').addClass('error').text("Twitter's busted"); |
7 | 8 |
} |
8 | 9 |
feed.onreadystatechange = function(data){ |
9 | 10 |
if (feed.readyState === 4) { |
10 | 11 |
var tweets = new Array(); |
12 |
+ var i = 0; |
|
11 | 13 |
for (i in data){ |
12 | 14 |
if(tweets.length < count){ |
13 | 15 |
if(replies || data[i].in_reply_to_user_id == null){ |