Skip to content

Commit b8dcd60

Browse files
committed
added various var declarations, keeping stuff out of global scope
1 parent 0288c18 commit b8dcd60

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

reddit.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function sendRequest(url,callback,postData)
7878
req.onreadystatechange = function () {
7979
if (req.readyState != 4) return;
8080
if (req.status != 200 && req.status != 304) {
81-
errorCode = 'HTTP error: ' + req.status;
81+
var errorCode = 'HTTP error: ' + req.status;
8282
callback(errorCode);
8383
}
8484

@@ -108,7 +108,7 @@ function sendRequest(url,callback,postData)
108108
*@modHash: string. Required for making authenticated requests to Reddit API
109109
*@data: user object passed from Reddit. See Reddit API documentation
110110
***************************************************************************/
111-
user = {
111+
var user = {
112112
modHash : '',
113113
name: '',
114114
password: '',
@@ -123,7 +123,7 @@ var instance = {
123123
read : {
124124
//var subReddit = sr ? sr : 'frontpage';
125125
fetchReddit : function(sr, count, callback){
126-
srCount = count ? count : '25'
126+
var srCount = count ? count : '25'
127127
var sub;
128128
if (sr == 'frontpage'){
129129
sub = '';
@@ -133,7 +133,7 @@ var instance = {
133133
sendRequest("http://www.reddit.com/"+sub+ ".json?count=" + srCount, callback)
134134
},
135135
fetchById : function(type, id, callback){
136-
fullName = type + '_' + id;
136+
var fullName = type + '_' + id;
137137
sendRequest("http://www.reddit.com/by_id/" + fullName + ".json", callback);
138138
},
139139
fetchCommentsById : function(id, callback){
@@ -148,11 +148,11 @@ var instance = {
148148
};
149149
},
150150
myReddits: function(callback){
151-
url = 'http://www.reddit.com/reddits/mine.json';
151+
var url = 'http://www.reddit.com/reddits/mine.json';
152152
sendRequest(url, callback);
153153
},
154154
defaultReddits: function(callback){
155-
url = 'http://www.reddit.com/reddits/.json';
155+
var url = 'http://www.reddit.com/reddits/.json';
156156
sendRequest(url, callback);
157157
},
158158
fetchProfile: function(user, callback){
@@ -175,7 +175,7 @@ var instance = {
175175
}
176176
}
177177
}else{
178-
messages = msg;
178+
var messages = msg;
179179
}
180180
callback(messages);
181181
});
@@ -216,7 +216,7 @@ var instance = {
216216

217217
markMailRead: function(mailId, callback){
218218
var url = 'http://www.reddit.com/api/read_message/';
219-
postData =
219+
var postData =
220220
{
221221
api_type: 'json',
222222
id: mailId,

0 commit comments

Comments
 (0)