JSHint eqeqeq

This commit is contained in:
Steffen van Bergerem 2015-02-08 22:38:53 +01:00
parent 5fa6b8253e
commit ab6732cac1
37 changed files with 62 additions and 62 deletions

View file

@ -61,7 +61,7 @@ Handlebars.registerHelper('sharingMessage', function(person) {
// allow hovercards for users that are not the current user.
// returns the html class name used to trigger hovercards.
Handlebars.registerHelper('hovercardable', function(person) {
if( app.currentUser.get('guid') != person.guid ) {
if( app.currentUser.get('guid') !== person.guid ) {
return 'hovercardable';
}
return '';
@ -104,7 +104,7 @@ Handlebars.registerHelper('fmtText', function(text) {
Handlebars.registerHelper('isCurrentPage', function(path_helper, id, options){
var currentPage = "/"+Backbone.history.fragment;
if (currentPage == Handlebars.helpers.urlTo(path_helper, id, options.data)) {
if (currentPage === Handlebars.helpers.urlTo(path_helper, id, options.data)) {
return options.fn(this);
} else {
return options.inverse(this);
@ -121,7 +121,7 @@ Handlebars.registerHelper('aspectMembershipIndicator', function(contact,in_aspec
if(!app.aspect || !app.aspect.get('id')) return '<div class="aspect_membership_dropdown placeholder"></div>';
var html = '<i class="entypo ';
if( in_aspect == 'in_aspect' ) {
if( in_aspect === 'in_aspect' ) {
html += 'circled-cross contact_remove-from-aspect" ';
html += 'title="' + Diaspora.I18n.t('contacts.remove_contact') + '" ';
} else {

View file

@ -6,7 +6,7 @@
if (!o_embed_cache) { return "" }
var data = o_embed_cache.data;
if (data.type == "photo") {
if (data.type === "photo") {
return '<img src="' + data.url + '" width="' + data.width + '" height="' + data.height + '" />';
} else {
return data.html || "";

View file

@ -6,7 +6,7 @@
var punycodeURL = function(url){
try {
while(url.indexOf("%") !== -1 && url != decodeURI(url)) url = decodeURI(url);
while(url.indexOf("%") !== -1 && url !== decodeURI(url)) url = decodeURI(url);
}
catch(e){}
@ -15,7 +15,7 @@
url = // rebuild the url
(!addr.scheme ? '' : addr.scheme +
( (addr.scheme.toLowerCase()=="mailto" || addr.scheme.toLowerCase()=="xmpp") ? ':' : '://')) +
( (addr.scheme.toLowerCase() === "mailto" || addr.scheme.toLowerCase() === "xmpp") ? ':' : '://')) +
(!addr.user ? '' : addr.user +
(!addr.pass ? '' : ':'+addr.pass) + '@') +
punycode.toASCII(addr.host) +

View file

@ -7,7 +7,7 @@ app.models.Contact = Backbone.Model.extend({
},
inAspect : function(id) {
return this.aspect_memberships.any(function(membership){ return membership.get('aspect').id == id; });
return this.aspect_memberships.any(function(membership){ return membership.get('aspect').id === id; });
}
});
// @license-end

View file

@ -12,20 +12,20 @@ app.models.Person = Backbone.Model.extend({
isSharing: function() {
var rel = this.get('relationship');
return (rel == 'mutual' || rel == 'sharing');
return (rel === 'mutual' || rel === 'sharing');
},
isReceiving: function() {
var rel = this.get('relationship');
return (rel == 'mutual' || rel == 'receiving');
return (rel === 'mutual' || rel === 'receiving');
},
isMutual: function() {
return (this.get('relationship') == 'mutual');
return (this.get('relationship') === 'mutual');
},
isBlocked: function() {
return (this.get('relationship') == 'blocked');
return (this.get('relationship') === 'blocked');
},
block: function() {

View file

@ -44,12 +44,12 @@ app.models.Post.Interactions = Backbone.Model.extend({
},
userLike : function(){
return this.likes.select(function(like){ return like.get("author").guid == app.currentUser.get("guid")})[0];
return this.likes.select(function(like){ return like.get("author").guid === app.currentUser.get("guid")})[0];
},
userReshare : function(){
return this.reshares.select(function(reshare){
return reshare.get("author") && reshare.get("author").guid == app.currentUser.get("guid")})[0];
return reshare.get("author") && reshare.get("author").guid === app.currentUser.get("guid")})[0];
},
toggleLike : function() {
@ -126,11 +126,11 @@ app.models.Post.Interactions = Backbone.Model.extend({
},
userCanReshare : function(){
var isReshare = this.post.get("post_type") == "Reshare"
var isReshare = this.post.get("post_type") === "Reshare"
, rootExists = (isReshare ? this.post.get("root") : true)
, publicPost = this.post.get("public")
, userIsNotAuthor = this.post.get("author").diaspora_id != app.currentUser.get("diaspora_id")
, userIsNotRootAuthor = rootExists && (isReshare ? this.post.get("root").author.diaspora_id != app.currentUser.get("diaspora_id") : true)
, userIsNotAuthor = this.post.get("author").diaspora_id !== app.currentUser.get("diaspora_id")
, userIsNotRootAuthor = rootExists && (isReshare ? this.post.get("root").author.diaspora_id !== app.currentUser.get("diaspora_id") : true)
, notReshared = !this.userReshare();
return publicPost && app.currentUser.authenticated() && userIsNotAuthor && userIsNotRootAuthor && notReshared;

View file

@ -35,7 +35,7 @@ app.models.Stream = Backbone.Collection.extend({
},
isFetching : function() {
return (this.deferred && this.deferred.state() == "pending");
return (this.deferred && this.deferred.state() === "pending");
},
triggerFetchedEvents : function(resp){

View file

@ -20,7 +20,7 @@ app.models.User = Backbone.Model.extend({
},
isAuthorOf: function(model) {
return this.authenticated() && model.get("author").id == this.id;
return this.authenticated() && model.get("author").id === this.id;
}
});
// @license-end

View file

@ -143,10 +143,10 @@ app.Router = Backbone.Router.extend({
},
_hideInactiveStreamLists: function() {
if(this.aspects_list && Backbone.history.fragment != "aspects")
if(this.aspects_list && Backbone.history.fragment !== "aspects")
this.aspects_list.hideAspectsList();
if(this.followedTagsView && Backbone.history.fragment != "followed_tags")
if(this.followedTagsView && Backbone.history.fragment !== "followed_tags")
this.followedTagsView.hideFollowedTags();
},

View file

@ -157,11 +157,11 @@ app.views.AspectMembershipBlueprint = Backbone.View.extend({
_pluralSummaryTxt: function(cnt) {
var all_aspects_cnt = this.dropdown.find('li').length;
if( cnt == 1 ) {
if( cnt === 1 ) {
return this.dropdown.find('li.selected').first().text();
}
if( cnt == all_aspects_cnt ) {
if( cnt === all_aspects_cnt ) {
return Diaspora.I18n.t('aspect_dropdown.all_aspects');
}

View file

@ -37,7 +37,7 @@ app.views.AspectsDropdown = app.views.Base.extend({
buttonText = Diaspora.I18n.t("aspect_dropdown.select_aspects");
} else {
button.removeClass('btn-default').addClass(inAspectClass);
if (selectedAspects == 1) {
if (selectedAspects === 1) {
buttonText = this.$(".dropdown-menu > li.selected .text").first().text();
} else {
buttonText = Diaspora.I18n.t("aspect_dropdown.toggle", { count: selectedAspects.toString() });

View file

@ -57,7 +57,7 @@ app.views.CommentStream = app.views.Base.extend({
},
keyDownOnCommentBox: function(evt) {
if(evt.keyCode == 13 && evt.ctrlKey) {
if(evt.keyCode === 13 && evt.ctrlKey) {
this.$("form").submit();
return false;
}

View file

@ -25,11 +25,11 @@ app.views.Comment = app.views.Content.extend({
},
ownComment : function() {
return app.currentUser.authenticated() && this.model.get("author").diaspora_id == app.currentUser.get("diaspora_id");
return app.currentUser.authenticated() && this.model.get("author").diaspora_id === app.currentUser.get("diaspora_id");
},
postOwner : function() {
return app.currentUser.authenticated() && this.model.get("parent").author.diaspora_id == app.currentUser.get("diaspora_id");
return app.currentUser.authenticated() && this.model.get("parent").author.diaspora_id === app.currentUser.get("diaspora_id");
},
canRemove : function() {

View file

@ -57,7 +57,7 @@ app.views.Contact = app.views.Base.extend({
removeContactFromAspect: function(){
var self = this;
this.model.aspect_memberships
.find(function(membership){ return membership.get('aspect').id == app.aspect.id; })
.find(function(membership){ return membership.get('aspect').id === app.aspect.id; })
.destroy({
success: function(){
self.render();

View file

@ -40,7 +40,7 @@ app.views.Header = app.views.Base.extend({
toggleSearchActive: function(ev) {
// jQuery produces two events for focus/blur (for bubbling)
// don't rely on which event arrives first, by allowing for both variants
var is_active = (_.indexOf(['focus','focusin'], ev.type) != -1);
var is_active = (_.indexOf(['focus','focusin'], ev.type) !== -1);
$(ev.target).toggleClass('active', is_active);
return false;
}

View file

@ -49,7 +49,7 @@ app.views.Hovercard = app.views.Base.extend({
el = el.parents('a');
}
if( el.attr('href').indexOf('/people') == -1 ) {
if( el.attr('href').indexOf('/people') === -1 ) {
// can't fetch data from that URL, aborting
return false;
}

View file

@ -34,7 +34,7 @@ app.views.InfScroll = app.views.Base.extend({
createPostView : function(post){
var postView = new this.postClass({ model: post, stream: this.stream });
if (this.collection.at(0).id == post.id) {
if (this.collection.at(0).id === post.id) {
// post is first in collection - insert view at top of the list
this.postViews.unshift(postView);
} else {
@ -46,7 +46,7 @@ app.views.InfScroll = app.views.Base.extend({
// called for every item inserted in this.collection
addPostView : function(post) {
var el = this.createPostView(post).render().el;
if (this.collection.at(0).id == post.id) {
if (this.collection.at(0).id === post.id) {
this.prependedPosts.insertBefore(el, this.prependedPosts.firstChild);
} else {
this.appendedPosts.appendChild(el);

View file

@ -35,7 +35,7 @@ app.views.PublisherAspectSelector = app.views.AspectsDropdown.extend({
// update the globe or lock icon
var icon = this.$('#visibility-icon');
if (target.find('.text').text().trim() == Diaspora.I18n.t('stream.public')) {
if (target.find('.text').text().trim() === Diaspora.I18n.t('stream.public')) {
icon.removeClass('lock');
icon.addClass('globe');
} else {

View file

@ -65,7 +65,7 @@ app.views.PublisherGettingStarted = Backbone.View.extend({
var close = $(popup).find('.close');
close.click(function() {
if( $('.popover').length==1 ) {
if( $('.popover').length === 1 ) {
$.get('/getting_started_completed', {success: function() {
$("#welcome-to-diaspora, #welcome-to-diaspora~br").remove();
}});

View file

@ -74,7 +74,7 @@ app.views.Publisher = Backbone.View.extend({
var _this = this;
$('body').on('click', function(event){
// if the click event is happened outside the publisher view, then try to close the box
if( _this.el && $(event.target).closest('#publisher').attr('id') != _this.el.id){
if( _this.el && $(event.target).closest('#publisher').attr('id') !== _this.el.id){
_this.tryClose();
}
});
@ -245,7 +245,7 @@ app.views.Publisher = Backbone.View.extend({
// avoid submitting form when pressing Enter key
avoidEnter: function(evt){
if(evt.keyCode == 13)
if(evt.keyCode === 13)
return false;
},
@ -276,7 +276,7 @@ app.views.Publisher = Backbone.View.extend({
user;
while( (user = regexp.exec(serializedForm["status_message[text]"])) ){
// user[1]: name, user[2]: handle
var mentioned_user = Mentions.contacts.filter(function(item) { return item.handle == user[2];})[0];
var mentioned_user = Mentions.contacts.filter(function(item) { return item.handle === user[2];})[0];
if(mentioned_user){
mentioned_people.push({
"id":mentioned_user["id"],
@ -309,7 +309,7 @@ app.views.Publisher = Backbone.View.extend({
var previewMessage = {
"id" : 0,
"text" : serializedForm["status_message[text]"],
"public" : serializedForm["aspect_ids[]"]=="public",
"public" : serializedForm["aspect_ids[]"] === "public",
"created_at" : date,
"interacted_at" : date,
"post_type" : "StatusMessage",
@ -350,7 +350,7 @@ app.views.Publisher = Backbone.View.extend({
},
keyDown : function(evt) {
if( evt.keyCode == 13 && evt.ctrlKey ) {
if( evt.keyCode === 13 && evt.ctrlKey ) {
this.$("form").submit();
this.open();
return false;
@ -484,7 +484,7 @@ app.views.Publisher = Backbone.View.extend({
},
_beforeUnload: function(e) {
if(this._submittable() && this.el_input.val() != this.prefillText){
if(this._submittable() && this.el_input.val() !== this.prefillText){
var confirmationMessage = Diaspora.I18n.t("confirm_unload");
(e || window.event).returnValue = confirmationMessage; //Gecko + IE
return confirmationMessage; //Webkit, Safari, Chrome, etc.

View file

@ -32,7 +32,7 @@ app.views.SinglePostActions = app.views.Feedback.extend({
},
authorIsNotCurrentUser: function() {
return app.currentUser.authenticated() && this.model.get("author").id != app.user().id;
return app.currentUser.authenticated() && this.model.get("author").id !== app.user().id;
}
});
// @license-end

View file

@ -19,7 +19,7 @@ app.views.SinglePostModeration = app.views.Feedback.extend({
},
authorIsCurrentUser: function() {
return app.currentUser.authenticated() && this.model.get("author").id == app.user().id;
return app.currentUser.authenticated() && this.model.get("author").id === app.user().id;
},
destroyModel: function(evt) {

View file

@ -41,7 +41,7 @@ app.views.TagFollowingList = app.views.Base.extend({
});
this.$("input").bind('keydown', function(evt){
if(evt.keyCode == 13 || evt.keyCode == 9 || evt.keyCode == 32){
if(evt.keyCode === 13 || evt.keyCode === 9 || evt.keyCode === 32){
evt.preventDefault();
if( $('li.as-result-item.active').length === 0 ){
$('li.as-result-item').first().click();

View file

@ -23,9 +23,9 @@ var AspectsDropdown = {
message = Diaspora.I18n.t("aspect_dropdown.stopped_sharing_with", {name: dropdown.data('person-short-name')});
Diaspora.page.flashMessages.render({success: true, notice: message});
}
} else if (selectedAspects == allAspects) {
} else if (selectedAspects === allAspects) {
replacement = Diaspora.I18n.t('aspect_dropdown.all_aspects');
} else if (number == 1) {
} else if (number === 1) {
button.addClass(inAspectClass);
replacement = dropdown.find(".selected").first().text();
/* flash message prompt */
@ -40,7 +40,7 @@ var AspectsDropdown = {
// if we are in the publisher, we add the visibility icon
if (isInPublisher) {
var icon = $('#visibility-icon');
if (replacement.trim() == Diaspora.I18n.t('stream.public')) {
if (replacement.trim() === Diaspora.I18n.t('stream.public')) {
icon.removeClass('lock');
icon.addClass('globe');
} else {

View file

@ -10,7 +10,7 @@ $.fn.clearForm = function() {
$(this).attr('checked', false);
} else if ($(this).is('select')) {
this.selectedIndex = -1;
} else if ($(this).attr('name') == 'photos[]') {
} else if ($(this).attr('name') === 'photos[]') {
$(this).val('');
}
$(this).blur();

View file

@ -6,7 +6,7 @@ Diaspora.I18n = {
pluralizationKey: function(n) { return this.fallback.pluralizationKey(n); },
data: {},
fallback: {
pluralizationKey: function(n) { return n == 1 ? "one" : "other"; },
pluralizationKey: function(n) { return n === 1 ? "one" : "other"; },
data: {}
}
},

View file

@ -24,7 +24,7 @@ $(document).ready(function(){
cBadge.html().replace(/\d+/, function(num){
num = parseInt(num);
cBadge.html(parseInt(num)-1);
if(num == 1) {
if(num === 1) {
cBadge.addClass("hidden");
}
});

View file

@ -73,7 +73,7 @@ Diaspora.Pages.UsersGettingStarted = function() {
});
autocompleteInput.bind('keydown', function(evt){
if(evt.keyCode == 13 || evt.keyCode == 9 || evt.keyCode == 32){
if(evt.keyCode === 13 || evt.keyCode === 9 || evt.keyCode === 32){
evt.preventDefault();
if( $('li.as-result-item.active').length === 0 ){
$('li.as-result-item').first().click();

View file

@ -38,7 +38,7 @@ var View = {
$(this).attr('checked', false);
} else if ($(this).is('select')) {
this.selectedIndex = -1;
} else if ($(this).attr('name') == 'photos[]') {
} else if ($(this).attr('name') === 'photos[]') {
$(this).val('');
}
$(this).blur();

View file

@ -130,7 +130,7 @@ jQuery.fn.center = (function() {
"data-full-photo": image.attr("data-full-photo")
});
if(image.attr("data-full-photo") == imageUrl) {
if(image.attr("data-full-photo") === imageUrl) {
imageThumb = thumb;
}

View file

@ -100,7 +100,7 @@
$('.notifications').scroll(function() {
var bottom = $('.notifications').prop('scrollHeight') - $('.notifications').height();
var currentPosition = $('.notifications').scrollTop();
isLoading = ($('.loading').length == 1);
isLoading = ($('.loading').length === 1);
if (currentPosition + 50 >= bottom && notificationsLoaded <= self.notifications.length && !isLoading) {
$('.notifications').addClass("loading");
++currentPage;

View file

@ -84,7 +84,7 @@
var itemID = data["guid"];
var isUnread = data["unread"];
self.notificationMenu.find('.read,.unread').each(function() {
if ( $(this).data("guid") == itemID ) {
if ( $(this).data("guid") === itemID ) {
if ( isUnread ) {
self.notificationMenu.find('a#mark_all_read_link').removeClass('disabled');
self.setUpUnread( $(this) );

View file

@ -11,7 +11,7 @@
$.timeago.settings.lang = Diaspora.I18n.language;
$.timeago.settings.strings[Diaspora.I18n.language] = {};
$.each($.timeago.settings.strings["en"], function(index) {
if(index == "numbers") {
if(index === "numbers") {
$.timeago.settings.strings[Diaspora.I18n.language][index] = [];
}
else {

View file

@ -10,7 +10,7 @@ options:
bitwise: false
camelcase: false
curly: false
eqeqeq: false
eqeqeq: true
forin: true
freeze: true
immed: true

View file

@ -14,7 +14,7 @@ describe("app.views.Help", function(){
});
it('should initially show getting help section', function(){
expect(this.view.$el.find('#faq').children().first().data('template') == 'faq_getting_help').toBeTruthy();
expect(this.view.$el.find('#faq').children().first().data('template')).toBe('faq_getting_help');
});
it('should show account and data management section', function(){
@ -39,7 +39,7 @@ describe("app.views.Help", function(){
it('should show posts and posting section', function(){
this.view.$el.find('a[data-section=posts_and_posting]').trigger('click');
expect(this.view.$el.find('#faq').children().first().data('template') == 'faq_posts_and_posting').toBeTruthy();
expect(this.view.$el.find('#faq').children().first().data('template')).toBe('faq_posts_and_posting');
});
it('should show private posts section', function(){
@ -69,17 +69,17 @@ describe("app.views.Help", function(){
it('should show sharing section', function(){
this.view.$el.find('a[data-section=sharing]').trigger('click');
expect(this.view.$el.find('#faq').children().first().data('template') == 'faq_sharing').toBeTruthy();
expect(this.view.$el.find('#faq').children().first().data('template')).toBe('faq_sharing');
});
it('should show tags section', function(){
this.view.$el.find('a[data-section=tags]').trigger('click');
expect(this.view.$el.find('#faq').children().first().data('template') == 'faq_tags').toBeTruthy();
expect(this.view.$el.find('#faq').children().first().data('template')).toBe('faq_tags');
});
it('should show keyboard shortcuts section', function(){
this.view.$el.find('a[data-section=keyboard_shortcuts]').trigger('click');
expect(this.view.$el.find('#faq').children().first().data('template') == 'faq_keyboard_shortcuts').toBeTruthy();
expect(this.view.$el.find('#faq').children().first().data('template')).toBe('faq_keyboard_shortcuts');
});
it('should show miscellaneous section', function(){

View file

@ -238,7 +238,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
url_to_match(requests[i])) {
matching_requests.push(requests[i]);
} else {
if (requests[i].url == url_to_match) {
if (requests[i].url === url_to_match) {
matching_requests.push(requests[i]);
}
}

View file

@ -8,7 +8,7 @@ describe("Locator", function(){
};
$.getJSON = function(url, myCallback){
if(url == "https://nominatim.openstreetmap.org/reverse?format=json&lat=1&lon=2&addressdetails=3")
if(url === "https://nominatim.openstreetmap.org/reverse?format=json&lat=1&lon=2&addressdetails=3")
{
return myCallback({ display_name: 'locator address' });
}