From 2ec093a54c1b8a3e8d0ba5d18fa0707d509be2e3 Mon Sep 17 00:00:00 2001 From: Steffen van Bergerem Date: Sun, 8 Feb 2015 22:58:39 +0100 Subject: [PATCH] JSHint boss, evil, loopfunc and scripturl --- app/assets/javascripts/app/app.js | 5 ++++- app/assets/javascripts/app/models/post.js | 3 ++- app/assets/javascripts/app/views/publisher_view.js | 9 ++++++++- app/assets/javascripts/helpers/i18n.js | 5 ++++- config/jshint.yml | 8 ++++---- spec/javascripts/helpers/SpecHelper.js | 6 ++++-- 6 files changed, 26 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/app/app.js b/app/assets/javascripts/app/app.js index d0a6a5158..a3aa65c5e 100644 --- a/app/assets/javascripts/app/app.js +++ b/app/assets/javascripts/app/app.js @@ -35,7 +35,10 @@ var app = { events: _.extend({}, Backbone.Events), user: function(userAttrs) { - if(userAttrs) { return this._user = new app.models.User(userAttrs) } + if(userAttrs) { + this._user = new app.models.User(userAttrs); + return this._user; + } return this._user || false; }, diff --git a/app/assets/javascripts/app/models/post.js b/app/assets/javascripts/app/models/post.js index 73d9de467..30da8f71c 100644 --- a/app/assets/javascripts/app/models/post.js +++ b/app/assets/javascripts/app/models/post.js @@ -22,7 +22,8 @@ app.models.Post = Backbone.Model.extend(_.extend({}, app.models.formatDateMixin, }, reshare : function(){ - return this._reshare = this._reshare || new app.models.Reshare({root_guid : this.get("guid")}); + this._reshare = this._reshare || new app.models.Reshare({root_guid : this.get("guid")}); + return this._reshare; }, reshareAuthor : function(){ diff --git a/app/assets/javascripts/app/views/publisher_view.js b/app/assets/javascripts/app/views/publisher_view.js index 69c2d9c05..48574bfe4 100644 --- a/app/assets/javascripts/app/views/publisher_view.js +++ b/app/assets/javascripts/app/views/publisher_view.js @@ -274,9 +274,16 @@ app.views.Publisher = Backbone.View.extend({ var mentioned_people = [], regexp = new RegExp("@{\(\[\^\;\]\+\); \(\[\^\}\]\+\)}", "g"), user; + + var getMentionedUser = function(handle) { + return Mentions.contacts.filter(function(user) { + return user.handle === handle; + })[0]; + }; + 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 = getMentionedUser(user[2]); if(mentioned_user){ mentioned_people.push({ "id":mentioned_user["id"], diff --git a/app/assets/javascripts/helpers/i18n.js b/app/assets/javascripts/helpers/i18n.js index adcb08c83..9be574c45 100644 --- a/app/assets/javascripts/helpers/i18n.js +++ b/app/assets/javascripts/helpers/i18n.js @@ -22,7 +22,10 @@ Diaspora.I18n = { var rule = this._resolve(locale, ['pluralization_rule']); if (rule !== "") { + /* jshint evil:true */ + // TODO change this to `locale.pluralizationKey = rule`? eval("locale.pluralizationKey = "+rule); + /* jshint evil:false */ } }, @@ -37,7 +40,7 @@ Diaspora.I18n = { _resolve: function(locale, items) { var translatedMessage, nextNamespace, originalItems = items.slice(); - while(nextNamespace = items.shift()) { + while( (nextNamespace = items.shift()) ) { translatedMessage = (translatedMessage) ? translatedMessage[nextNamespace] : locale.data[nextNamespace]; diff --git a/config/jshint.yml b/config/jshint.yml index 67ca0ca14..cde2b3c82 100644 --- a/config/jshint.yml +++ b/config/jshint.yml @@ -27,19 +27,19 @@ options: # relaxing options asi: false - boss: true + boss: false browser: true devel: true eqnull: true - evil: true + evil: false expr: true jasmine: true jquery: true lastsemic: true laxbreak: true laxcomma: true - loopfunc: true - scripturl: true + loopfunc: false + scripturl: false sub: true supernew: true diff --git a/spec/javascripts/helpers/SpecHelper.js b/spec/javascripts/helpers/SpecHelper.js index 0730ab771..9e7ac46cc 100644 --- a/spec/javascripts/helpers/SpecHelper.js +++ b/spec/javascripts/helpers/SpecHelper.js @@ -90,12 +90,14 @@ window.stubView = function stubView(text){ }; window.loginAs = function loginAs(attrs){ - return app.currentUser = app.user(factory.userAttrs(attrs)); + app.currentUser = app.user(factory.userAttrs(attrs)); + return app.currentUser; }; window.logout = function logout(){ this.app._user = undefined; - return app.currentUser = new app.models.User(); + app.currentUser = new app.models.User(); + return app.currentUser; }; window.hipsterIpsumFourParagraphs = "Mcsweeney's mumblecore irony fugiat, ex iphone brunch helvetica eiusmod retro" +