Skip to content
Browse files

Eliminating errors and warnings reported by Javascript Lint

  • Loading branch information...
1 parent afef29e commit c8ebf40700579cb6df8a84386c81d19c7c640e77 @cezarsa committed Oct 10, 2010
View
49 background.html
@@ -103,7 +103,6 @@
this.initIconAndAlerts();
- var _this = this;
this.twitterBackend = new TwitterLib(
function onAuthenticated() {
TimelineTemplate.initAfterAuthentication();
@@ -124,8 +123,7 @@
OptionsBackend.get('base_signing_url'),
OptionsBackend.get('base_oauth_signing_url'),
OptionsBackend.get('base_search_url'),
- this.oauthTokenData
- );
+ this.oauthTokenData);
this.sendQueue = new SendQueue(this.twitterBackend);
}
@@ -270,9 +268,9 @@
/* Lists timelines won't be included as they'll only be shown later */
orderedEachTimeline: function(callback, includeLists) {
- var retList = [];
- for(var tId in this.timelines) {
- var timeline = this.timelines[tId];
+ var retList = [], tId, timeline;
+ for(tId in this.timelines) {
+ timeline = this.timelines[tId];
if(!includeLists && timeline.template.id == TimelineTemplate.LISTS) {
continue;
}
@@ -287,9 +285,9 @@
}
}
for(var i = 0; i < retList.length; ++i) {
- var tId = retList[i];
+ tId = retList[i];
if(tId) {
- var timeline = this.timelines[tId];
+ timeline = this.timelines[tId];
if(timeline.template.visible) {
var ret = callback.call(tId, timeline);
if(ret === false) {
@@ -360,7 +358,7 @@
}
}, true);
var totalUnreadNewCount = this.unique(totalUnreadNewIds).length;
- if(colors.length == 0) {
+ if(colors.length === 0) {
chrome.browserAction.setTitle({title: "Chromed Bird"});
chrome.browserAction.setIcon({imageData: IconCreator.paintIcon(this.iconImg, OptionsBackend.get('idle_color'))});
chrome.browserAction.setBadgeText({text: ''});
@@ -385,7 +383,7 @@
},
showTweetsNotifications: function(tweetsToNotify, forceOnPage) {
- if(!tweetsToNotify || tweetsToNotify.length == 0) {
+ if(!tweetsToNotify || tweetsToNotify.length === 0) {
return;
}
var maxTweetsNotifications = OptionsBackend.get('notification_max_popups');
@@ -424,8 +422,7 @@
for(var i = 0; i < tweetsToNotify.length; ++i) {
var notification = notificationCenter.createHTMLNotification(
- chrome.extension.getURL('tweets_notifier.html')
- );
+ chrome.extension.getURL('tweets_notifier.html'));
(function inClosure(tweet) {
notification.onclose = function(e) {
setTimeout(function() {
@@ -538,8 +535,6 @@
getTweet: function(callback, id) {
var _this = this;
return this.twitterBackend.showTweet(function(success, data, status) {
- if(success) {
- }
callback(success, data, status);
}, id);
},
@@ -661,6 +656,7 @@
return null;
}
timeline.changeList(listId);
+ return undefined;
},
getListId: function(timelineId) {
@@ -706,7 +702,7 @@
var timeline = this.timelines[timelineId];
if(!timeline) {
callback([], timelineId);
- return;
+ return undefined;
}
if(syncNew && timeline.template.includeInUnified) {
var originalCallback = callback;
@@ -780,8 +776,8 @@
onHitsUpdated: function(remainingHits, nextHitsReset, hourlyLimit) {
var nextResetDate = new Date();
- nextResetDate.setTime(parseInt(nextHitsReset) * 1000);
- if(remainingHits == 0) {
+ nextResetDate.setTime(parseInt(nextHitsReset, 10) * 1000);
+ if(remainingHits === 0) {
this.autoClearWarning = true;
this.setWarning(chrome.i18n.getMessage("exceededAPIHits", [chrome.extension.getURL('options.html'), nextResetDate.toLocaleDateString(), nextResetDate.toLocaleTimeString()]));
return;
@@ -798,7 +794,7 @@
}
}
- this.apiHitsStates.push([(new Date()).getTime(), parseInt(remainingHits)]);
+ this.apiHitsStates.push([(new Date()).getTime(), parseInt(remainingHits, 10)]);
if(this.apiHitsStates.length > this.maxApiHitsStates) {
this.apiHitsStates.shift();
}
@@ -867,7 +863,7 @@
getUsersToComplete: function() {
return this.followingUsers;
}
-}
+};
/* Clean up old versions mess */
Persistence.cleanupOldData();
@@ -879,8 +875,8 @@
for(var i = 0; i < maxLen; ++i) {
if(v1[i] === undefined) return -1;
if(v2[i] === undefined) return 1;
- if(parseInt(v1[i]) > parseInt(v2[i])) return 1;
- if(parseInt(v1[i]) < parseInt(v2[i])) return -1;
+ if(parseInt(v1[i], 10) > parseInt(v2[i], 10)) return 1;
+ if(parseInt(v1[i], 10) < parseInt(v2[i], 10)) return -1;
}
return 0;
}
@@ -890,6 +886,7 @@
var currentVersion = manifest.version.split('.');
var storageData = Persistence.version();
var storageVersion = storageData.val();
+ var options, baseUrl;
if(storageVersion) {
storageVersion = JSON.parse(storageVersion);
} else {
@@ -898,12 +895,12 @@
return;
}
- if(compareVersions(currentVersion, storageVersion) != 0) {
+ if(compareVersions(currentVersion, storageVersion) !== 0) {
// if last version is < 1.3.0
if(compareVersions(storageVersion, [1, 3, 0]) < 0) {
//Old default refresh interval, let's update it for the new version
if(OptionsBackend.get('home_refresh_interval') == 60000) {
- var options = OptionsBackend.load();
+ options = OptionsBackend.load();
options['home_refresh_interval'] = OptionsBackend.defaultOptions['home_refresh_interval'];
OptionsBackend.save(options);
}
@@ -920,8 +917,8 @@
timelineOrderData.save(JSON.stringify(storedOrder));
}
if(compareVersions(storageVersion, [1, 6, 1]) <= 0) {
- var options = OptionsBackend.load();
- var baseUrl = options['base_url'];
+ options = OptionsBackend.load();
+ baseUrl = options['base_url'];
if(baseUrl.match(/http:\/\/twitter\.com/)) {
options['base_url'] = 'http://api.twitter.com/1/';
options['base_signing_url'] = 'http://api.twitter.com/1/';
@@ -960,7 +957,7 @@
initializeJQueryOptions();
}
- var baseUrl = OptionsBackend.get('base_url');
+ baseUrl = OptionsBackend.get('base_url');
var baseSigningUrl = OptionsBackend.get('base_signing_url');
if(baseUrl == baseSigningUrl && baseUrl == 'http://api.twitter.com/1/') {
// This days the SSL endpoint seems more reliable, let's make it the
View
127 jsl.conf
@@ -0,0 +1,127 @@
+#
+# Configuration File for JavaScript Lint 0.3.0
+# Developed by Matthias Miller (http://www.JavaScriptLint.com)
+#
+# This configuration file can be used to lint a collection of scripts, or to enable
+# or disable warnings for scripts that are linted via the command line.
+#
+
+### Warnings
+# Enable or disable warnings based on requirements.
+# Use "+WarningName" to display or "-WarningName" to suppress.
+#
++no_return_value # function {0} does not always return a value
++duplicate_formal # duplicate formal argument {0}
++equal_as_assign # test for equality (==) mistyped as assignment (=)?{0}
++var_hides_arg # variable {0} hides argument
++redeclared_var # redeclaration of {0} {1}
++anon_no_return_value # anonymous function does not always return a value
++missing_semicolon # missing semicolon
++meaningless_block # meaningless block; curly braces have no impact
++comma_separated_stmts # multiple statements separated by commas (use semicolons?)
++unreachable_code # unreachable code
++missing_break # missing break statement
++missing_break_for_last_case # missing break statement for last case in switch
++comparison_type_conv # comparisons against null, 0, true, false, or an empty string allowing implicit type conversion (use === or !==)
++inc_dec_within_stmt # increment (++) and decrement (--) operators used as part of greater statement
++useless_void # use of the void type may be unnecessary (void is always undefined)
++multiple_plus_minus # unknown order of operations for successive plus (e.g. x+++y) or minus (e.g. x---y) signs
++use_of_label # use of label
+-block_without_braces # block statement without curly braces
++leading_decimal_point # leading decimal point may indicate a number or an object member
++trailing_decimal_point # trailing decimal point may indicate a number or an object member
++octal_number # leading zeros make an octal number
++nested_comment # nested comment
++misplaced_regex # regular expressions should be preceded by a left parenthesis, assignment, colon, or comma
++ambiguous_newline # unexpected end of line; it is ambiguous whether these lines are part of the same statement
++empty_statement # empty statement or extra semicolon
+-missing_option_explicit # the "option explicit" control comment is missing
++partial_option_explicit # the "option explicit" control comment, if used, must be in the first script tag
++dup_option_explicit # duplicate "option explicit" control comment
++useless_assign # useless assignment
++ambiguous_nested_stmt # block statements containing block statements should use curly braces to resolve ambiguity
++ambiguous_else_stmt # the else statement could be matched with one of multiple if statements (use curly braces to indicate intent)
++missing_default_case # missing default case in switch statement
++duplicate_case_in_switch # duplicate case in switch statements
++default_not_at_end # the default case is not at the end of the switch statement
++legacy_cc_not_understood # couldn't understand control comment using /*@keyword@*/ syntax
++jsl_cc_not_understood # couldn't understand control comment using /*jsl:keyword*/ syntax
++useless_comparison # useless comparison; comparing identical expressions
++with_statement # with statement hides undeclared variables; use temporary variable instead
++trailing_comma_in_array # extra comma is not recommended in array initializers
++assign_to_function_call # assignment to a function call
++parseint_missing_radix # parseInt missing radix parameter
+
+
+### Output format
+# Customize the format of the error message.
+# __FILE__ indicates current file path
+# __FILENAME__ indicates current file name
+# __LINE__ indicates current line
+# __ERROR__ indicates error message
+#
+# Visual Studio syntax (default):
++output-format __FILE__(__LINE__): __ERROR__
+# Alternative syntax:
+#+output-format __FILE__:__LINE__: __ERROR__
+
+
+### Context
+# Show the in-line position of the error.
+# Use "+context" to display or "-context" to suppress.
+#
++context
+
+
+### Semicolons
+# By default, assignments of an anonymous function to a variable or
+# property (such as a function prototype) must be followed by a semicolon.
+#
++lambda_assign_requires_semicolon
+
+
+### Control Comments
+# Both JavaScript Lint and the JScript interpreter confuse each other with the syntax for
+# the /*@keyword@*/ control comments and JScript conditional comments. (The latter is
+# enabled in JScript with @cc_on@). The /*jsl:keyword*/ syntax is preferred for this reason,
+# although legacy control comments are enabled by default for backward compatibility.
+#
++legacy_control_comments
+
+
+### JScript Function Extensions
+# JScript allows member functions to be defined like this:
+# function MyObj() { /*constructor*/ }
+# function MyObj.prototype.go() { /*member function*/ }
+#
+# It also allows events to be attached like this:
+# function window::onload() { /*init page*/ }
+#
+# This is a Microsoft-only JavaScript extension. Enable this setting to allow them.
+#
+-jscript_function_extensions
+
+
+### Defining identifiers
+# By default, "option explicit" is enabled on a per-file basis.
+# To enable this for all files, use "+always_use_option_explicit"
+-always_use_option_explicit
+
+# Define certain identifiers of which the lint is not aware.
+# (Use this in conjunction with the "undeclared identifier" warning.)
+#
+# Common uses for webpages might be:
+#+define window
+#+define document
+
+
+### Files
+# Specify which files to lint
+# Use "+recurse" to enable recursion (disabled by default).
+# To add a set of files, use "+process FileName", "+process Folder\Path\*.js",
+# or "+process Folder\Path\*.htm".
+#
++process ./*.js
++process ./lib/*.js
++process ./lib/options/*.js
++process ./lib/timelines/*.js
View
10 lib/expander_lib.js
@@ -101,9 +101,9 @@ Expander.prototype = {
expand: function(url, callback) {
var longUrl = this.urlsCache[url];
+ var isShortened = true;
+ var success = true;
if(longUrl) {
- var isShortened = true;
- var success = true;
callback(success, isShortened, longUrl);
return;
}
@@ -120,8 +120,8 @@ Expander.prototype = {
}
}
} else {
- var isShortened = false;
- var success = true;
+ isShortened = false;
+ success = true;
callback(success, isShortened, url);
}
} else {
@@ -162,4 +162,4 @@ Expander.prototype = {
}
);
}
-}
+};
View
6 lib/icon_creator.js
@@ -62,7 +62,7 @@ IconCreator = {
},
HexToRGB: function (hex) {
- var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
+ hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF), a: 1};
},
RGBAStrToRGB: function(rgbaStr) {
@@ -72,7 +72,7 @@ IconCreator = {
g: parseInt($.trim(brokenValue[1]), 10),
b: parseInt($.trim(brokenValue[2]), 10),
a: parseFloat($.trim(brokenValue[3]))
- }
+ };
return rgbaValue;
},
StrToRGB: function(colorStr) {
@@ -104,7 +104,7 @@ IconCreator = {
var colorChangeInterval = (19 * 4) / color.length;
for(var x = 0; x < 19; ++x) {
for(var y = 0; y < (19 * 4); y += 4) {
- var currentColor = color[parseInt(y / colorChangeInterval)];
+ var currentColor = color[parseInt(y / colorChangeInterval, 10)];
var pos = (x * 19 * 4) + y;
var dist = this.colorDistance(referenceColor, {r: pixelData[pos + 0], g: pixelData[pos + 1], b: pixelData[pos + 2]});
if(dist < 27) {
View
18 lib/math_utils.js
@@ -3,14 +3,14 @@ Math.createLinearFunction = function(m, b) {
/* f(x) = mx + b */
return function(x) {
return m * x + b;
- }
+ };
};
Math.linearLeastSquares = function(points, xOffset) {
/* Using linear least squares method to create an equation in the form f(x) = mx + b */
var n = points.length;
- if(n == 0) {
+ if(n === 0) {
return null;
}
if(!xOffset) {
@@ -75,7 +75,7 @@ Math.generateTendencyGraph = function(canvas, points, xLimit) {
}
var x = ((pointOrX[0] - xOffset) * xScale) + xMargin;
var y = ((yOffset - pointOrX[1]) * yScale) + yMargin;
- return [parseInt(x), parseInt(y)];
+ return [parseInt(x, 10), parseInt(y, 10)];
};
ctx.clearRect(0, 0, w, h);
@@ -84,12 +84,12 @@ Math.generateTendencyGraph = function(canvas, points, xLimit) {
ctx.setStrokeColor(0, 0, 0, 1);
ctx.beginPath();
for(var i = 0; i < pointsLen - 1; ++i) {
- var p1 = adjustPoint(points[i]),
- p2 = adjustPoint(points[i + 1]);
- if(i == 0) {
- ctx.moveTo(p1[0], p1[1]);
+ var p1Graph = adjustPoint(points[i]),
+ p2Graph = adjustPoint(points[i + 1]);
+ if(i === 0) {
+ ctx.moveTo(p1Graph[0], p1Graph[1]);
}
- ctx.lineTo(p2[0], p2[1]);
+ ctx.lineTo(p2Graph[0], p2Graph[1]);
}
ctx.stroke();
ctx.beginPath();
@@ -98,7 +98,7 @@ Math.generateTendencyGraph = function(canvas, points, xLimit) {
ctx.setStrokeColor('#aaa');
ctx.textBaseline = 'bottom';
- for(var i = 0; i < pointsLen; ++i) {
+ for(i = 0; i < pointsLen; ++i) {
var y = points[i][1];
var adjY = adjustPoint(0, y)[1];
ctx.fillText(y, 0, adjY);
View
6 lib/oauth_authorizer.js
@@ -5,9 +5,9 @@ function getAuthPin() {
var pin = $.trim($("#oauth_pin").text());
$("div.message-content").hide();
var message = "<h2>" + chrome.i18n.getMessage("authorizing") + "</h2>" + chrome.i18n.getMessage("yourPIN", pin);
- var newDiv = $("<div class='message-content new_div'>")
- .html(message)
- .insertAfter("div.message-content");
+ var newDiv = $("<div class='message-content new_div'>").
+ html(message).
+ insertAfter("div.message-content");
var nextOpacity = 1;
function animateLoop() {
View
16 lib/options/options.js
@@ -79,6 +79,7 @@ function Options() {
}
}
}
+ return true;
});
var validInfo = Validator.global();
if(validInfo !== true) {
@@ -106,7 +107,7 @@ function Options() {
newValue = $this.attr('strColor');
} else {
var elValue = $this.val();
- var intValue = parseInt(elValue);
+ var intValue = parseInt(elValue, 10);
if(intValue == elValue) {
elValue = intValue;
}
@@ -123,6 +124,7 @@ function Options() {
_this.optionsMap[name] = newValue;
}
}
+ return true;
});
OptionsBackend.save(this.optionsMap);
TimelineTemplate.reloadOptions();
@@ -178,7 +180,7 @@ Converters = {
$el.val(val / 1000);
},
save: function($el) {
- return parseInt($el.val()) * 1000;
+ return parseInt($el.val(), 10) * 1000;
}
}
};
@@ -204,27 +206,27 @@ Validator = {
},
required: function ($el) {
- var val = $el.val()
+ var val = $el.val();
if(!val)
return 'It can\'t be empty.';
return true;
},
number: function ($el) {
- var intVal = parseInt($el.val());
+ var intVal = parseInt($el.val(), 10);
if(isNaN(intVal))
return 'It should be a number.';
return true;
},
positive: function ($el) {
- if(parseInt($el.val()) <= 0)
+ if(parseInt($el.val(), 10) <= 0)
return 'It should be positive.';
return true;
},
minRefresh: function ($el) {
- if(parseInt($el.val()) < 10)
+ if(parseInt($el.val(), 10) < 10)
return 'Minimum interval is 10s';
return true;
},
@@ -256,5 +258,5 @@ Validator = {
}
return true;
}
-}
+};
/* ---- end validation ---- */
View
4 lib/options_backend.js
@@ -112,14 +112,14 @@ OptionsBackend = {
return map;
},
saveOption: function(option, value) {
- if(this.cachedOptions == null) {
+ if(this.cachedOptions === null) {
this.cachedOptions = this.load();
}
this.cachedOptions[option] = value;
this.save(this.cachedOptions, true);
},
get: function(option) {
- if(this.cachedOptions == null) {
+ if(this.cachedOptions === null) {
this.cachedOptions = this.load();
}
return this.cachedOptions[option];
View
4 lib/persistence.js
@@ -30,7 +30,7 @@ Persistence = {
this[methodName] = (function(key) {
return function() {
return _this.load(key);
- }
+ };
})(currentKey);
}
},
@@ -61,7 +61,7 @@ ValueWrapper.prototype = {
val: function() {
var value = localStorage[this.key];
if(!value) {
- return;
+ return undefined;
}
if(Persistence.isObject(this.key)) {
value = JSON.parse(value);
View
4 lib/send_queue.js
@@ -26,7 +26,7 @@ SendQueue.prototype = {
abortedStatus: function() {
if(!this.abortedQueue)
- return;
+ return undefined;
var ret = this.abortedQueue.slice(0);
this.abortedQueue = [];
return ret;
@@ -75,7 +75,7 @@ SendQueue.prototype = {
},
_sender: function() {
- if(this.queue.length == 0) {
+ if(this.queue.length === 0) {
this._safeCallbackCall(this.onQueueEmptyCallback);
return;
}
View
54 lib/shortener_lib.js
@@ -17,9 +17,9 @@ Shortener.prototype = {
function(errorCode, msg) {
var cbMsg = null;
var success = true;
- if(errorCode == 0 && msg) {
+ if(errorCode === 0 && msg) {
cbMsg = _this.shortenerInfo.baseUrl + msg;
- } else if(errorCode != 0 && msg) {
+ } else if(errorCode !== 0 && msg) {
cbMsg = 'Error ' + errorCode + ': ' + msg;
success = false;
} else {
@@ -29,7 +29,7 @@ Shortener.prototype = {
callback(success, cbMsg);
});
}
-}
+};
BitLyShortener = {
shorten: function(longUrl, useAcct, login, apiKey, serviceUrl, callback) {
@@ -38,7 +38,7 @@ BitLyShortener = {
version: '2.0.1',
format: 'json',
longUrl: longUrl
- }
+ };
if(useAcct) {
params['login'] = login;
params['apiKey'] = apiKey;
@@ -55,9 +55,9 @@ BitLyShortener = {
dataType: 'json',
success: function(data, status) {
var ecAPI = data.errorCode;
- if(ecAPI == 0) {
+ if(ecAPI === 0) {
var ecURL = data.results[longUrl].errorCode;
- if(!ecURL || ecURL==0) {
+ if(!ecURL || ecURL === 0) {
callback(0, data.results[longUrl].userHash);
} else {
callback(ecURL, data.results[longUrl].errorMessage);
@@ -71,14 +71,14 @@ BitLyShortener = {
}
});
}
-}
+};
TrimShortener = {
shorten: function(longUrl, useAcct, login, apiKey, serviceUrl, callback) {
var url = "http://api.tr.im/v1/trim_url.json";
var params = {
url: longUrl
- }
+ };
$.ajax({
type: 'GET',
url: url,
@@ -96,22 +96,22 @@ TrimShortener = {
}
});
}
-}
+};
MigremeShortener = {
shorten: function(longUrl, useAcct, login, apiKey, serviceUrl, callback) {
var url = "http://migre.me/api.xml";
var params = {
url: longUrl
- }
+ };
$.ajax({
type: 'GET',
url: url,
data: params,
dataType: 'xml',
success: function(data, status) {
var errorId = $('error', data).text();
- if(errorId != 0) {
+ if(errorId !== 0) {
callback(errorId, $('errormessage', data).text());
return;
}
@@ -122,14 +122,14 @@ MigremeShortener = {
}
});
}
-}
+};
IsGdShortener = {
shorten: function(longUrl, useAcct, login, apiKey, serviceUrl, callback) {
var url = "http://is.gd/api.php";
var params = {
longurl: longUrl
- }
+ };
$.ajax({
type: 'GET',
url: url,
@@ -147,14 +147,14 @@ IsGdShortener = {
}
});
}
-}
+};
MiudinShortener = {
shorten: function(longUrl, useAcct, login, apiKey, serviceUrl, callback) {
var url = "http://miud.in/api-create.php";
var params = {
url: longUrl
- }
+ };
$.ajax({
type: 'GET',
url: url,
@@ -168,7 +168,7 @@ MiudinShortener = {
}
});
}
-}
+};
UdanaxShortener = {
shorten: function(longUrl, useAcct, login, apiKey, serviceUrl, callback) {
@@ -191,7 +191,7 @@ UdanaxShortener = {
}
});
}
-}
+};
URLinlShortener = {
shorten: function(longUrl, useAcct, login, apiKey, serviceUrl, callback) {
@@ -218,14 +218,14 @@ URLinlShortener = {
}
});
}
-}
+};
URLcortaShortener = {
shorten: function(longUrl, useAcct, login, apiKey, serviceUrl, callback) {
var url = "http://urlcorta.es/api/text/";
var params = {
url: longUrl
- }
+ };
$.ajax({
type: 'GET',
url: url,
@@ -239,7 +239,7 @@ URLcortaShortener = {
}
});
}
-}
+};
GooglShortener = {
shorten: function(longUrl, useAcct, login, apiKey, serviceUrl, callback) {
@@ -270,7 +270,7 @@ GooglShortener = {
}
});
}
-}
+};
KCYShortener = {
shorten : function(longUrl, useAcct, login, apiKey, serviceUrl, callback) {
@@ -297,15 +297,15 @@ KCYShortener = {
}
});
}
-}
+};
YourlsShortener = {
shorten: function(longUrl, useAcct, login, apiKey, serviceUrl, callback) {
var params = {
signature: apiKey,
action: 'shorturl',
format: 'json',
- url: longUrl,
+ url: longUrl
};
$.ajax({
@@ -325,15 +325,15 @@ YourlsShortener = {
}
});
}
-}
+};
McafeeShortener = {
shorten: function(longUrl, useAcct, login, apiKey, serviceUrl, callback) {
var url = "http://mcaf.ee/api/shorten";
var params = {
input_url: longUrl,
format: 'json'
- }
+ };
$.ajax({
type: 'GET',
url: url,
@@ -354,7 +354,7 @@ McafeeShortener = {
}
});
}
-}
+};
SHORTENERS_BACKEND = {
bitly: {
@@ -422,4 +422,4 @@ SHORTENERS_BACKEND = {
baseUrl: '',
backend: McafeeShortener
}
-}
+};
View
4 lib/simple_select.js
@@ -5,13 +5,13 @@
});
};
- $.simpleSelect = function(selectEl, options) {
+ $.simpleSelect = function(selectEl, simpleSelectOptions) {
// One of my goals is to render this as fast as possible, so I'm going
// to avoid using jQuery in this contructor and work directly with the DOM.
if(selectEl.tagName.toUpperCase() != "SELECT")
return;
- this.changeCallback = options.change;
+ this.changeCallback = simpleSelectOptions.change;
this.selectEl = selectEl;
if(selectEl.simpleSelectEl) {
$(selectEl.simpleSelectEl.replacementDiv).remove();
View
4 lib/timeline_factory.js
@@ -71,7 +71,7 @@ MultipleTimelineFactory.prototype = $.extend({}, TimelineFactory.prototype, {
create: function() {
if(this.template.visible) {
var currentData = this.template.getUserData();
- if(!currentData || currentData.length == 0) {
+ if(!currentData || currentData.length === 0) {
currentData = [null];
}
this.template.setUserData(currentData);
@@ -97,7 +97,7 @@ MultipleTimelineFactory.prototype = $.extend({}, TimelineFactory.prototype, {
},
_instantiateTimeline: function(timelineId, manager, template, data, orderNumber) {
- throw '_instantiateTimeline must be overridden'
+ throw '_instantiateTimeline must be overridden';
}
});
View
3 lib/timeline_template.js
@@ -81,6 +81,9 @@ function TimelineTemplate(timelineTemplateId, tweetManager) {
this.factory = new SearchTimelineFactory(this);
this.multipleTimelines = true;
break;
+ default:
+ // bug
+ break;
}
};
View
4 lib/timelines/multiple_timeline.js
@@ -1,7 +1,7 @@
function MultipleTweetsTimeline(timelineId, manager, template, timelineData, orderNumber) {
TweetsTimeline.call(this, timelineId, manager, template);
this.timelineData = timelineData;
- this.orderNumber = parseInt(orderNumber);
+ this.orderNumber = parseInt(orderNumber, 10);
}
$.extend(MultipleTweetsTimeline.prototype, TweetsTimeline.prototype, {
@@ -22,7 +22,7 @@ $.extend(MultipleTweetsTimeline.prototype, TweetsTimeline.prototype, {
currentData.splice(this.orderNumber, 1);
this.template.setUserData(currentData);
- if(currentData.length == 0) {
+ if(currentData.length === 0) {
this.template.setVisible(false);
} else {
var _this = this;
View
7 lib/timelines/timeline.js
@@ -47,6 +47,7 @@ TweetsTimeline.prototype = {
callback([], this.timelineId, this);
return;
}
+ var _this = this;
if(this.currentCallback) {
if(this.unifiedRunning) {
try {
@@ -67,7 +68,6 @@ TweetsTimeline.prototype = {
//We should fetch new tweets, update the cache and then return the
//cached results.
var oldNewTweetsCallback = this.manager.newTweetsCallback;
- var _this = this;
this.currentCallback = callback;
this.manager.newTweetsCallback = null;
var onFinishCallback = function() {
@@ -78,7 +78,7 @@ TweetsTimeline.prototype = {
_this.manager.updateAlert();
_this.giveMeTweets(tweetsCallback, false, true);
_this.manager.newTweetsCallback = oldNewTweetsCallback;
- }
+ };
this._fetchNewTweets(onFinishCallback);
return;
}
@@ -98,7 +98,6 @@ TweetsTimeline.prototype = {
//from twitter's API.
this.currentCallback = callback;
- var _this = this;
var params = this._makeOldTweetsRequestParams(suggestedCount);
var context = {
usingMaxId: !!params.max_id
@@ -270,7 +269,7 @@ TweetsTimeline.prototype = {
},
_cleanUpCache: function() {
- if(this.currentScroll != 0) {
+ if(this.currentScroll !== 0) {
return;
}
var len = this.tweetsCache.length;
View
12 lib/timelines/unified_timeline.js
@@ -47,10 +47,10 @@ $.extend(UnifiedTweetsTimeline.prototype, TweetsTimeline.prototype, {
var tweetsPerPage = OptionsBackend.get('tweets_per_page');
var maxCachedTweets = OptionsBackend.get('max_cached_tweets');
- var maxCachedPages = parseInt((maxCachedTweets / tweetsPerPage) - 1);
+ var maxCachedPages = parseInt((maxCachedTweets / tweetsPerPage) - 1, 10);
if(cacheOnly || syncNew) {
- if(this.currentScroll == 0) {
+ if(this.currentScroll === 0) {
if(this.currentPage > maxCachedPages) {
this.currentPage = maxCachedPages;
this._eachTimeline(function(timeline) {
@@ -109,7 +109,7 @@ $.extend(UnifiedTweetsTimeline.prototype, TweetsTimeline.prototype, {
usedTweetsMap[maxBeforeTweet.id] = true;
}
return maxBeforeTweet;
- }
+ };
var joinFunction = function() {
if(errorAbort) {
@@ -133,7 +133,7 @@ $.extend(UnifiedTweetsTimeline.prototype, TweetsTimeline.prototype, {
break;
}
var timelineTweetsCache = externalTweetsCache[nextTweet.timelineId];
- var isLastInTimelineCache = timelineTweetsCache[timelineTweetsCache.length - 1].id == nextTweet.id
+ var isLastInTimelineCache = timelineTweetsCache[timelineTweetsCache.length - 1].id == nextTweet.id;
if(isLastInTimelineCache) {
/* 3rd step: Some timeline went empty because all other tweets are already in
the unified timeline, now we need to get more tweets from this timeline.
@@ -174,7 +174,7 @@ $.extend(UnifiedTweetsTimeline.prototype, TweetsTimeline.prototype, {
}
var currentTweets = externalTweetsCache[timelineId];
externalTweetsCache[timelineId] = tweets;
- }
+ };
/* 1st step: Let's get cached results from each timeline and call
joinFunction when we get all the results.
@@ -257,7 +257,7 @@ Utils = {
return function() {
joinCount--;
eachCallback.apply(this, arguments);
- if(joinCount == 0) {
+ if(joinCount === 0) {
joinCallback();
}
};
View
6 lib/tweet_transforms.js
@@ -20,17 +20,17 @@ transformFactory:
}
}
- if (bestLeft.length != 0) {
+ if (bestLeft.length !== 0) {
var span = document.createElement("span");
span.innerHTML = bestLeft;
content.appendChild(document.createTextNode(span.textContent));
}
- if (bestTransform != null) {
+ if (bestTransform !== null) {
content.appendChild(bestTransform);
}
oldText = bestRight;
- } while (oldText != "");
+ } while (oldText !== "");
return content;
};
View
28 lib/tweets_assembler.js
@@ -40,19 +40,19 @@ var Renderer = {
} else if(diff < 60) {
return chrome.i18n.getMessage("minuteAgo");
} else if(diff < 60 * 60) {
- var minutes = parseInt(diff / 60);
+ var minutes = parseInt(diff / 60, 10);
var minute_string = minutes > 1 ? "minute_plural" : "minute_singular";
return chrome.i18n.getMessage('minutes', [minutes, chrome.i18n.getMessage(minute_string)]);
} else if(diff < 60 * 60 * 24) {
- var hours = parseInt(diff / (60 * 60));
+ var hours = parseInt(diff / (60 * 60), 10);
var hour_string = hours > 1 ? "hour_plural" : "hour_singular";
return chrome.i18n.getMessage("timeAgo", [hours, chrome.i18n.getMessage(hour_string)]);
} else if(diff < 60 * 60 * 24 * 30) {
- var days = parseInt(diff / (60 * 60 * 24));
+ var days = parseInt(diff / (60 * 60 * 24), 10);
var day_string = days > 1 ? "day_plural" : "day_singular";
return chrome.i18n.getMessage("timeAgo", [days, chrome.i18n.getMessage(day_string)]);
} else if(diff < 60 * 60 * 24 * 30 * 12) {
- var months = parseInt(diff / (60 * 60 * 24 * 30));
+ var months = parseInt(diff / (60 * 60 * 24 * 30), 10);
var month_string = months > 1 ? "month_plural" : "month_singular";
return chrome.i18n.getMessage("timeAgo", [months, chrome.i18n.getMessage(month_string)]);
} else {
@@ -65,16 +65,16 @@ var Renderer = {
return new Date(inputTimestamp).toLocaleDateString() + " " + new Date(inputTimestamp).toLocaleTimeString();
},
- geoImage: function (aElement, lat, long, name) {
+ geoImage: function (aElement, lat, longitude, name) {
if(this.isOnPage()) {
return;
}
var url = 'http://maps.google.com/maps/api/staticmap?' + $.param({
- center: lat + ',' + long,
+ center: lat + ',' + longitude,
zoom: 14,
size: '160x160',
maptype: 'roadmap',
- markers: 'size:small|' + lat + ',' + long,
+ markers: 'size:small|' + lat + ',' + longitude,
sensor: false
});
$(aElement).tipsy({
@@ -162,7 +162,7 @@ var Renderer = {
var url = RegExp.$1;
var scheme = RegExp.$3;
- if (scheme != null && !/^(https?|ftp)$/i.exec(scheme)) {
+ if (scheme && !(/^(https?|ftp)$/i.exec(scheme))) {
// possibly dangerous scheme, suppress it
return document.createTextNode(url);
}
@@ -253,8 +253,8 @@ var Renderer = {
var text = tweet.text;
var tweetId = tweet.id;
if(tweet.retweeted_status) {
- user = tweet.retweeted_status.user
- text = tweet.retweeted_status.text
+ user = tweet.retweeted_status.user;
+ text = tweet.retweeted_status.text;
tweetId = tweet.retweeted_status.id;
}
var content = this.transformTweetText(text);
@@ -274,7 +274,7 @@ var Renderer = {
var geo = null;
if(tweet.source) {
var tweetSource = tweet.source;
- if(tweetSource.indexOf('&lt;') == 0) {
+ if(tweetSource.indexOf('&lt;') === 0) {
// The source attribute for tweets returned by the Search API is
// different from the regular source attribute. For search results
// it contains a string with escaped html entities.
@@ -287,10 +287,10 @@ var Renderer = {
ClickEmulator.handleClick(linkElement, function() { openTab(linkElement.href); });
}
if(tweet.geo) {
- var href = "http://maps.google.com/maps?q=loc:" + tweet.geo.coordinates[0] + "," + tweet.geo.coordinates[1] + " "
+ var href = "http://maps.google.com/maps?q=loc:" + tweet.geo.coordinates[0] + "," + tweet.geo.coordinates[1] + " ";
href += encodeURI("(" + tweet.user.screen_name + ")");
- var geo = Renderer.makeElem('a', {
+ geo = Renderer.makeElem('a', {
href: href,
onmouseover: "Renderer.geoImage(this, " + tweet.geo.coordinates[0] + "," + tweet.geo.coordinates[1] + ")"
}, "<img src=\"data:image/gif;base64, R0lGODlhCgAKAMZZAKRFP7NDN5s5RphLU6dUTLdpVbVZbopycK1vZKNxZqxyZ79oe8hSRMVST8xdTNJaWcRlU8FlWtNzXdVpZsh5atN6aKqEe7yFfsaGa8uVe9GUf791hN55h4yGiI6FipuRkKqHhbasrbi2t8KZg8Cal8mRmuObjMehls+nn/2njvewnMO+u8m6v/ykoPCusubFvsG6wv+/yM3Ex//Lz+7Qxe/Ryf/J2f/lzf/l4f/m5//j7//t7P/47f3z8f/19f/39f/88P/59P/49v/59//69v/69/L6/Pb6/fr4+fj6+f/7+fr8+f79+//9+/z5///4//z7//37///6/v/6//n//fn+//v+//39/f/9/f///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////yH5BAEAAH8ALAAAAAAKAAoAAAdJgH+CfyUbBgs2g38gMzMcAgMugjQXLRMPDQAEgi8KEAEMDhUFgwkUEBIpGBmDFggmKhojgywHJCgkijAeIYqCMh0ivoIfK8OCgQA7\" alt=\"[GEO]\"/>");
@@ -410,7 +410,7 @@ var Renderer = {
span.appendChild(from);
footer.appendChild(span);
}
- if (geo) {
+ if(geo) {
var span = Renderer.makeElem("span", {class:"geo_tag"});
span.appendChild(Renderer.makeText(" "));
span.appendChild(geo);
View
6 lib/twitter_lib.js
@@ -88,10 +88,10 @@ TwitterLib.prototype = {
callback(false, null, fmtError, context);
};
var successCallback = function(data, status, request) {
- if(request.status == 0) {
+ if(request.status === 0) {
// Empty responses are a pain, before failing, we'll first try
// this same request with HTTPS.
- if(TwitterLib.URLS.BASE.indexOf('https') != 0) {
+ if(TwitterLib.URLS.BASE.indexOf('https') !== 0) {
TwitterLib.URLS.BASE = TwitterLib.URLS.BASE.replace(/^http:/, 'https:');
TwitterLib.URLS.BASE_SIGNING = TwitterLib.URLS.BASE.replace(/^http:/, 'https:');
_this.ajaxRequest(url, callback, context, params, httpMethod, useSearchAPI, overriddenTimeout);
@@ -436,4 +436,4 @@ TwitterOAuth.prototype = {
this.oauth_token = null;
this.makeRequest('request_token', {}, this.requestTokenCallback);
}
-}
+};
View
31 options.html
@@ -49,11 +49,11 @@
var hitsInfo = twitterBackend.remainingHitsInfo();
$(".twitter_hits_left").text(hitsInfo[0]);
- resetDateObj.setTime(parseInt(hitsInfo[1]) * 1000);
+ resetDateObj.setTime(parseInt(hitsInfo[1], 10) * 1000);
$(".twitter_hits_reset").text(resetDateObj.toLocaleDateString() + " " + resetDateObj.toLocaleTimeString());
if(hitsInfo[2]) {
- hourlyLimit = parseInt(hitsInfo[2]);
+ hourlyLimit = parseInt(hitsInfo[2], 10);
}
}
$(".__hourly_limit").text(hourlyLimit);
@@ -64,7 +64,7 @@
}
var onShortenerChange = function() {
- var shortenerSelect = $("select[name='url_shortener']")[0]
+ var shortenerSelect = $("select[name='url_shortener']")[0];
if(shortenerSelect.value == 'bitly' || shortenerSelect.value == 'jmp' || shortenerSelect.value == 'karmacracy') {
$("#shortener_opts").show();
$("#yourls_opts").hide();
@@ -131,16 +131,16 @@
onSigningUrlCheck();
});
options.onsaveChangedOption(function(optionName, oldValue, newValue) {
- var idx;
+ var idx, templateId;
if((idx = optionName.indexOf('_visible')) != -1) {
- var templateId = optionName.substring(0, idx);
+ templateId = optionName.substring(0, idx);
if(newValue) {
tweetManager.showTimelineTemplate(templateId, true);
} else {
tweetManager.hideTimelineTemplate(templateId);
}
} else if((idx = optionName.indexOf('_include_unified')) != -1) {
- var templateId = optionName.substring(0, idx);
+ templateId = optionName.substring(0, idx);
tweetManager.toggleUnified(templateId, newValue);
}
});
@@ -155,7 +155,7 @@
if(authStatus == 1 || authStatus == 2) { // Not allowed or Denied
notificationCenter.requestPermission(function() {
var authStatus = notificationCenter.checkPermission();
- if(authStatus != 0) { // Permission denied
+ if(authStatus !== 0) { // Permission denied
$("#noti_on_page").click();
options.save();
}
@@ -170,11 +170,11 @@
options.load();
updatePredictedHitsCount();
- $('table.timelines input, table.timelines select')
- .keyup(updatePredictedHitsCount)
- .blur(updatePredictedHitsCount)
- .click(updatePredictedHitsCount)
- .change(updatePredictedHitsCount);
+ $('table.timelines input, table.timelines select').
+ keyup(updatePredictedHitsCount).
+ blur(updatePredictedHitsCount).
+ click(updatePredictedHitsCount).
+ change(updatePredictedHitsCount);
$("input[name='microblogging_service'],label[for='service_twitter'],label[for='service_identica']").mousedown(function(e) {
var el = $(e.target);
@@ -239,17 +239,18 @@
}
var inputRefreshEl = $('input[name="' + template.id + '_refresh_interval"]');
- var intVal = parseInt(inputRefreshEl.val());
+ var intVal = parseInt(inputRefreshEl.val(), 10);
var timelineHits = (60 * 60) / intVal;
var timelineCount = 1;
var userData = template.getUserData();
if(userData && userData.length > 0) {
timelineCount = userData.length;
}
totalHits += timelineHits * timelineCount;
+ return true;
});
- totalHits += (60 * 60) / parseInt($('input[name="blockedusers_refresh_interval"]').val());
- totalHits = parseInt(totalHits);
+ totalHits += (60 * 60) / parseInt($('input[name="blockedusers_refresh_interval"]').val(), 10);
+ totalHits = parseInt(totalHits, 10);
$('#predicted_hits_count').text(totalHits);
if(totalHits >= hourlyLimit) {
$('#predicted_hits_count').css('backgroundColor', 'red');
View
4 tweets_notifier.html
@@ -33,8 +33,8 @@
setTimeout(function() {
$("#progress").text(chrome.i18n.getMessage("preventClosing"));
- $('#progress').show().css('bottom', '0px').css('width', '100%')
- .animate({width: '0px'}, fadeTimeout, 'linear', function() {
+ $('#progress').show().css('bottom', '0px').css('width', '100%').
+ animate({width: '0px'}, fadeTimeout, 'linear', function() {
// Tell manager that this tweet shouldn't be marked as read
tweetManager.shouldNotReadMap[tweet.id] = true;
window.close();

0 comments on commit c8ebf40

Please sign in to comment.
Something went wrong with that request. Please try again.