From 4b90faf89d6aa7b4108a35d26479757fdf79c84b Mon Sep 17 00:00:00 2001 From: jgen Date: Thu, 24 Apr 2014 00:55:14 -0400 Subject: [PATCH] Even more linting of JS files. --- ext/mass_tagger/script.js | 2 ++ ext/notes/script.js | 14 ++++++++------ ext/pools/script.js | 2 ++ ext/tagger/script.js | 2 +- ext/twitter_soc/script.js | 22 +++++++++++----------- lib/shimmie.js | 2 +- 6 files changed, 25 insertions(+), 19 deletions(-) diff --git a/ext/mass_tagger/script.js b/ext/mass_tagger/script.js index 1cc4077c..966e8ac2 100644 --- a/ext/mass_tagger/script.js +++ b/ext/mass_tagger/script.js @@ -1,3 +1,5 @@ +/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */ + function activate_mass_tagger ( image_link ) { $(".shm-thumb").each( function ( index, block ) { diff --git a/ext/notes/script.js b/ext/notes/script.js index c8bafab7..43f492b2 100644 --- a/ext/notes/script.js +++ b/ext/notes/script.js @@ -1,3 +1,5 @@ +/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */ + $(function() { if(window.notes) { $('#main_image').imgNotes({notes: window.notes}); @@ -36,9 +38,9 @@ $(function() { }); function showaddnote (img, area) { - imgOffset = $(img).offset(); - form_left = parseInt(imgOffset.left) + parseInt(area.x1); - form_top = parseInt(imgOffset.top) + parseInt(area.y1) + parseInt(area.height)+5; + var imgOffset = $(img).offset(); + var form_left = parseInt(imgOffset.left) + parseInt(area.x1); + var form_top = parseInt(imgOffset.top) + parseInt(area.y1) + parseInt(area.height)+5; $('#noteform').css({ left: form_left + 'px', top: form_top + 'px'}); $('#noteform').show(); @@ -50,9 +52,9 @@ function showaddnote (img, area) { } function showeditnote (img, area) { - imgOffset = $(img).offset(); - form_left = parseInt(imgOffset.left) + area.x1; - form_top = parseInt(imgOffset.top) + area.y2; + var imgOffset = $(img).offset(); + var form_left = parseInt(imgOffset.left) + area.x1; + var form_top = parseInt(imgOffset.top) + area.y2; $('#noteEditForm').css({ left: form_left + 'px', top: form_top + 'px'}); $('#noteEditForm').show(); diff --git a/ext/pools/script.js b/ext/pools/script.js index 505718a9..c5e91d4e 100644 --- a/ext/pools/script.js +++ b/ext/pools/script.js @@ -1,3 +1,5 @@ +/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */ + $(function() { var order_pool = $.cookie("shm_ui-order-pool") || "created"; $("#order_pool option[value="+order_pool+"]").attr("selected", true); diff --git a/ext/tagger/script.js b/ext/tagger/script.js index 282ec02e..7a10f162 100644 --- a/ext/tagger/script.js +++ b/ext/tagger/script.js @@ -44,7 +44,7 @@ var Tagger = { var id = "tagger_alert-"+type var t_alert = byId(id); if (t_alert) { - if(text == false) { + if(text === false) { // remove t_alert.parentNode.removeChild(t_alert); } else { diff --git a/ext/twitter_soc/script.js b/ext/twitter_soc/script.js index 839a19a5..62e316d0 100644 --- a/ext/twitter_soc/script.js +++ b/ext/twitter_soc/script.js @@ -29,7 +29,7 @@ twitter_search_url: "search.twitter.com", // [string] custom twitter search url, if any (apigee, etc.) template: "{avatar}{time}{join}{text}", // [string or function] template used to construct each tweet
  • - see code for available vars comparator: function(tweet1, tweet2) { // [function] comparator used to sort tweets (see Array.sort) - return tweet2["tweet_time"] - tweet1["tweet_time"]; + return tweet2.tweet_time - tweet1.tweet_time; }, filter: function(tweet) { // [function] whether or not to include a particular tweet (be sure to also set 'fetch') return true; @@ -48,7 +48,7 @@ result = result.replace(new RegExp('{'+key+'}','g'), val === null ? '' : val); } return result; - } else return template(info); + } else { return template(info); } } // Export the t function for use when passing a function as the 'template' option $.extend({tweet: {t: t}}); @@ -71,7 +71,7 @@ linkUser: replacer(/(^|[\W])@(\w+)/gi, "$1@$2"), // Support various latin1 (\u00**) and arabic (\u06**) alphanumeric chars linkHash: replacer(/(?:^| )[\#]+([\w\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0600-\u06ff]+)/gi, - ' #$1'), + ' #$1'), capAwesome: replacer(/\b(awesome)\b/gi, '$1'), capEpic: replacer(/\b(epic)\b/gi, '$1'), makeHeart: replacer(/(<)+[3]/gi, "") @@ -83,7 +83,7 @@ var text = match; for(var i = 0; i < entities.length; ++i) { var entity = entities[i]; - if (entity.url == url && entity.expanded_url) { + if (entity.url === url && entity.expanded_url) { url = entity.expanded_url; text = entity.display_url; break; @@ -139,14 +139,14 @@ } function build_api_url() { - var proto = ('https:' == document.location.protocol ? 'https:' : 'http:'); + var proto = ('https:' === document.location.protocol ? 'https:' : 'http:'); var count = (s.fetch === null) ? s.count : s.fetch; var common_params = '&include_entities=1&callback=?'; if (s.list) { return proto+"//"+s.twitter_api_url+"/1/"+s.username[0]+"/lists/"+s.list+"/statuses.json?page="+s.page+"&per_page="+count+common_params; } else if (s.favorites) { return proto+"//"+s.twitter_api_url+"/favorites/"+s.username[0]+".json?page="+s.page+"&count="+count+common_params; - } else if (s.query === null && s.username.length == 1) { + } else if (s.query === null && s.username.length === 1) { return proto+'//'+s.twitter_api_url+'/1/statuses/user_timeline.json?screen_name='+s.username[0]+'&count='+count+(s.retweets ? '&include_rts=1' : '')+'&page='+s.page+common_params; } else { var query = (s.query || 'from:'+s.username.join(' OR from:')); @@ -174,9 +174,9 @@ o.screen_name = item.from_user || item.user.screen_name; o.avatar_size = s.avatar_size; o.avatar_url = extract_avatar_url(item, (document.location.protocol === 'https:')); - o.retweet = typeof(item.retweeted_status) != 'undefined'; + o.retweet = typeof(item.retweeted_status) !== 'undefined'; o.tweet_time = parse_date(item.created_at); - o.join_text = s.join_text == "auto" ? build_auto_join_text(item.text) : s.join_text; + o.join_text = s.join_text === "auto" ? build_auto_join_text(item.text) : s.join_text; o.tweet_id = item.id_str; o.twitter_base = "http://"+s.twitter_url+"/"; o.user_url = o.twitter_base+o.screen_name; @@ -215,10 +215,10 @@ } $(widget).bind("tweet:load", function(){ - if (s.loading_text) $(widget).empty().append(loading); + if (s.loading_text) { $(widget).empty().append(loading); } $.getJSON(build_api_url(), function(data){ $(widget).empty().append(list); - if (s.intro_text) list.before(intro); + if (s.intro_text) { list.before(intro); } list.empty(); var tweets = $.map(data.results || data, extract_template_data); @@ -228,7 +228,7 @@ children('li:odd').addClass('tweet_even').end(). children('li:even').addClass('tweet_odd'); - if (s.outro_text) list.after(outro); + if (s.outro_text) { list.after(outro); } $(widget).trigger("loaded").trigger((tweets.length === 0 ? "empty" : "full")); if (s.refresh_interval) { window.setTimeout(function() { $(widget).trigger("tweet:load"); }, 1000 * s.refresh_interval); diff --git a/lib/shimmie.js b/lib/shimmie.js index 457cb71b..79419237 100644 --- a/lib/shimmie.js +++ b/lib/shimmie.js @@ -141,7 +141,7 @@ function getHTTPObject() { function getCookie( name ) { var start = document.cookie.indexOf( name + "=" ); var len = start + name.length + 1; - if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) { + if ( ( !start ) && ( name !== document.cookie.substring( 0, name.length ) ) ) { return null; } if ( start === -1 ) { return null; }