diff --git a/Gruntfile.js b/Gruntfile.js index ba80ce4e..98343aee 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -151,7 +151,21 @@ module.exports = function(grunt) { } }, jshint: { - files: ['Gruntfile.js', 'js/background.js'], // add 'src/**/*.js', 'test/**/*.js' + files: [ + 'Gruntfile.js', + 'js/background.js', + 'js/chromium.js', + 'js/bimap.js', + 'js/conversation_panel.js', + 'js/database.js', + 'js/inbox_controller.js', + 'js/index.js', + 'js/libphonenumber-util.js', + 'js/options.js', + 'js/panel_controller.js', + 'js/models/*.js', + 'js/views/*.js', + ], options: { jshintrc: '.jshintrc' }, }, jscs: { diff --git a/js/libphonenumber-util.js b/js/libphonenumber-util.js index 3bf13e29..45b38538 100644 --- a/js/libphonenumber-util.js +++ b/js/libphonenumber-util.js @@ -43,7 +43,7 @@ getCountryCode: function(regionCode) { var cc = libphonenumber.getCountryCodeForRegion(regionCode); - return (cc != 0) ? cc : ""; + return (cc !== 0) ? cc : ""; }, verifyNumber: function(number, regionCode) { diff --git a/js/models/conversations.js b/js/models/conversations.js index 3507bfed..167ad8c4 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -136,7 +136,7 @@ } this.save({unreadCount: this.get('unreadCount') + 1, active: true}); - return new Promise(function (resolve) { m.save().then(resolve(m)) }); + return new Promise(function (resolve) { m.save().then(resolve(m)); }); }, fetchMessages: function(options) { diff --git a/js/models/messages.js b/js/models/messages.js index 2b48f798..a375423c 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -81,4 +81,4 @@ return this.fetch(options); } }); -})() +})(); diff --git a/js/options.js b/js/options.js index c9840d87..7d7ba174 100644 --- a/js/options.js +++ b/js/options.js @@ -20,11 +20,11 @@ if (verificationCode.length == 6) { return verificationCode; } - }; + } function displayError(error) { $('#error').hide().text(error).addClass('in').fadeIn(); - }; + } $(function() { var phoneView = new Whisper.PhoneInputView({el: $('#phone-number-input')}); @@ -146,7 +146,7 @@ '?uuid=' + proto.uuid + '&pub_key=' + encodeURIComponent(btoa(getString(cryptoInfo.pubKey)))); $('img').removeAttr('style'); - $('#multi-device .status').text("Use your phone to scan the QR code.") + $('#multi-device .status').text("Use your phone to scan the QR code."); request.respond(200, 'OK'); } else if (request.path == "/v1/message" && request.verb == "PUT") { $('#init-setup').hide(); @@ -173,8 +173,7 @@ $('#verify4done').text('done'); //$('#complete-number').text(parsedNumber); textsecure.registration.done(); - case 5: - //TODO: Do sync to get 5! + //case 5: //TODO: Do sync to get 5! $('#verify').hide(); $('#setup-complete').show().addClass('in'); textsecure.registration.done(); diff --git a/js/panel_controller.js b/js/panel_controller.js index 05c14898..fbe77812 100644 --- a/js/panel_controller.js +++ b/js/panel_controller.js @@ -30,7 +30,7 @@ }; window.updateConversation = function(conversationId) { - var conversation = conversations.get(conversationId) + var conversation = conversations.get(conversationId); if (conversation) { conversation.fetch(); conversation.fetchMessages(); @@ -39,7 +39,7 @@ function closeConversation (windowId) { windowMap.remove('windowId', windowId); - }; + } window.openConversation = function openConversation (modelId) { var conversation = conversations.add({id: modelId}); diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index 9dbe2f0a..a334549a 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -110,7 +110,6 @@ toggleSettings: function (e) { $('body').toggleClass('settings-open'); console.log('toggling'); - debugger; } }); })(); diff --git a/js/views/file_input_view.js b/js/views/file_input_view.js index 6ed3d3b3..4bb367c9 100644 --- a/js/views/file_input_view.js +++ b/js/views/file_input_view.js @@ -68,20 +68,23 @@ var Whisper = Whisper || {}; var promises = []; var files = this.$input.prop('files'); for (var i = 0; i < files.length; i++) { - var contentType = files[i].type; - var p = new Promise(function(resolve, reject) { - var FR = new FileReader(); - FR.onload = function(e) { - resolve({data: e.target.result, contentType: contentType}); - }; - FR.readAsArrayBuffer(files[i]); - }.bind(this)); - promises.push(p); + promises.push(readFile(files[i])); } this.clearForm(); return Promise.all(promises); }, + readFile: function(file) { + var contentType = file.type; + return new Promise(function(resolve, reject) { + var FR = new FileReader(); + FR.onload = function(e) { + resolve({data: e.target.result, contentType: contentType}); + }; + FR.readAsArrayBuffer(file); + }); + }, + clearForm: function() { this.thumb.remove(); }, diff --git a/js/views/notifications.js b/js/views/notifications.js deleted file mode 100644 index a0f649b0..00000000 --- a/js/views/notifications.js +++ /dev/null @@ -1,34 +0,0 @@ -var Whisper = Whisper || {}; -(function () { - 'use strict'; - - // This is an ephemeral collection of global notification messages to be - // presented in some nice way to the user. In this case they will fade in/out - // one at a time. - - var queue = new Backbone.Collection(); - var view = new (Backbone.View.extend({ - className: 'help', - initialize: function() { - this.$el.appendTo($('body')); - this.listenToOnce(queue, 'add', this.presentNext); - }, - presentNext: function() { - var next = queue.shift(); - if (next) { - this.$el.text(next.get('message')).fadeIn(this.setFadeOut.bind(this)); - } else { - this.listenToOnce(queue, 'add', this.presentNext); - } - }, - setFadeOut: function() { - setTimeout(this.fadeOut.bind(this), 1500); - }, - fadeOut: function() { - this.$el.fadeOut(this.presentNext.bind(this)); - }, - }))(); - - Whisper.notify = function(str) { queue.add({message: str}); } - -})();