Fixing lint errors

Fixing JSLint Problems
This commit is contained in:
Sumit Bindal 2014-11-09 05:17:26 -05:00 committed by lilia
parent 0956d328da
commit d537d6a91f
3 changed files with 105 additions and 99 deletions

View file

@ -16,7 +16,7 @@
window.textsecure = window.textsecure || {}; window.textsecure = window.textsecure || {};
window.textsecure.api = function() { window.textsecure.api = function () {
'use strict'; 'use strict';
var self = {}; var self = {};
@ -27,19 +27,19 @@ window.textsecure.api = function() {
// Staging server // Staging server
var URL_BASE = "https://textsecure-service-staging.whispersystems.org"; var URL_BASE = "https://textsecure-service-staging.whispersystems.org";
self.relay = "textsecure-service-staging.whispersystems.org"; self.relay = "textsecure-service-staging.whispersystems.org";
var ATTACHMENT_HOST = "whispersystems-textsecure-attachments-staging.s3.amazonaws.com" var ATTACHMENT_HOST = "whispersystems-textsecure-attachments-staging.s3.amazonaws.com";
// This is the real server // This is the real server
//var URL_BASE = "https://textsecure-service.whispersystems.org"; //var URL_BASE = "https://textsecure-service.whispersystems.org";
var URL_CALLS = {}; var URL_CALLS = {};
URL_CALLS['accounts'] = "/v1/accounts"; URL_CALLS.accounts = "/v1/accounts";
URL_CALLS['devices'] = "/v1/devices"; URL_CALLS.devices = "/v1/devices";
URL_CALLS['keys'] = "/v2/keys"; URL_CALLS.keys = "/v2/keys";
URL_CALLS['push'] = "/v1/websocket"; URL_CALLS.push = "/v1/websocket";
URL_CALLS['temp_push'] = "/v1/temp_websocket"; URL_CALLS.temp_push = "/v1/temp_websocket";
URL_CALLS['messages'] = "/v1/messages"; URL_CALLS.messages = "/v1/messages";
URL_CALLS['attachment'] = "/v1/attachments"; URL_CALLS.attachment = "/v1/attachments";
/** /**
* REQUIRED PARAMS: * REQUIRED PARAMS:
@ -54,23 +54,24 @@ window.textsecure.api = function() {
* do_auth: alternative to user/password where user/password are figured out automagically * do_auth: alternative to user/password where user/password are figured out automagically
* jsonData: JSON data sent in the request body * jsonData: JSON data sent in the request body
*/ */
var doAjax = function(param) { var doAjax = function (param) {
if (param.urlParameters === undefined) if (param.urlParameters === undefined) {
param.urlParameters = ""; param.urlParameters = "";
}
if (param.do_auth) { if (param.do_auth) {
param.user = textsecure.storage.getUnencrypted("number_id"); param.user = textsecure.storage.getUnencrypted("number_id");
param.password = textsecure.storage.getEncrypted("password"); param.password = textsecure.storage.getEncrypted("password");
} }
return new Promise(function(resolve, reject) { return new Promise(function (resolve, reject) {
$.ajax(URL_BASE + URL_CALLS[param.call] + param.urlParameters, { $.ajax(URL_BASE + URL_CALLS[param.call] + param.urlParameters, {
type : param.httpType, type : param.httpType,
data : param.jsonData && textsecure.utils.jsonThing(param.jsonData), data : param.jsonData && textsecure.utils.jsonThing(param.jsonData),
contentType : 'application/json; charset=utf-8', contentType : 'application/json; charset=utf-8',
dataType : 'json', dataType : 'json',
beforeSend : function(xhr) { beforeSend : function (xhr) {
if (param.user !== undefined && if (param.user !== undefined &&
param.password !== undefined) param.password !== undefined)
xhr.setRequestHeader("Authorization", "Basic " + btoa(getString(param.user) + ":" + getString(param.password))); xhr.setRequestHeader("Authorization", "Basic " + btoa(getString(param.user) + ":" + getString(param.password)));
@ -82,7 +83,7 @@ window.textsecure.api = function() {
error : function(jqXHR, textStatus, errorThrown) { error : function(jqXHR, textStatus, errorThrown) {
var code = jqXHR.status; var code = jqXHR.status;
if (code == 200) { if (code === 200) {
// happens sometimes when we get no response // happens sometimes when we get no response
// (TODO: Fix server to return 204? instead) // (TODO: Fix server to return 204? instead)
resolve(null); resolve(null);
@ -153,7 +154,7 @@ window.textsecure.api = function() {
jsonData : { signalingKey : btoa(getString(signaling_key)), jsonData : { signalingKey : btoa(getString(signaling_key)),
supportsSms : false, supportsSms : false,
fetchesMessages : true, fetchesMessages : true,
registrationId : registrationId}, registrationId : registrationId}
}); });
}; };

View file

@ -1,3 +1,4 @@
/*global chrome*/
/* vim: ts=4:sw=4 /* vim: ts=4:sw=4
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -13,41 +14,42 @@
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
(function () {
'use strict';
window.extension = window.extension || {};
window.extension = window.extension || {}; window.extension.navigator = (function () {
var self = {},
tabs = {};
tabs.create = function (url) {
chrome.tabs.create({url: url});
};
self.tabs = tabs;
window.extension.navigator = function() { self.setBadgeText = function (text) {
var self = {}; chrome.browserAction.setBadgeText({text: String(text)});
};
var tabs = {}; return self;
tabs.create = function(url){ }());
chrome.tabs.create({url: url});
};
self.tabs = tabs;
self.setBadgeText = function(text){ // Random shared utilities that are used only by chromium things
chrome.browserAction.setBadgeText({text: text + ""});
};
return self; function registrationDone() {
}(); localStorage.setItem("chromiumRegistrationDone", "");
chrome.runtime.sendMessage('registration_done');
window.location = '/index.html';
}
// Random shared utilities that are used only by chromium things function isRegistrationDone() {
return localStorage.getItem("chromiumRegistrationDone") !== null;
}
function registrationDone() { function addRegistrationListener(callback) {
localStorage.setItem("chromiumRegistrationDone", ""); chrome.runtime.onMessage.addListener(function(message) {
chrome.runtime.sendMessage('registration_done'); if (message === 'registration_done') {
window.location = '/index.html'; callback();
} }
});
function isRegistrationDone() { }
return localStorage.getItem("chromiumRegistrationDone") !== null; }());
}
function addRegistrationListener(callback) {
chrome.runtime.onMessage.addListener(function(message) {
if (message === 'registration_done') {
callback();
}
});
};

View file

@ -1,3 +1,4 @@
/*global $, Whisper, Backbone, textsecure, extension*/
/* vim: ts=4:sw=4:expandtab: /* vim: ts=4:sw=4:expandtab:
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -13,61 +14,63 @@
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
(function () {
'use strict';
Whisper.Layout = new (Backbone.View.extend({
initialize: function () {
this.gutter = $('#gutter');
this.contacts = $('#contacts');
this.resize();
Whisper.Layout = new (Backbone.View.extend({ new Whisper.ConversationListView({el: $('#contacts')});
initialize: function() { window.addEventListener('resize', this.resize.bind(this));
this.gutter = $('#gutter'); window.addEventListener('storage', function () {Whisper.Threads.fetch(); });
this.contacts = $('#contacts'); Whisper.Threads.fetch({reset: true});
this.resize(); },
events: {
'click #new-message': 'new_message',
'click #new-group': 'new_group'
},
new Whisper.ConversationListView({el: $('#contacts')}); new_message: function (e) {
window.addEventListener('resize', this.resize.bind(this)); e.preventDefault();
window.addEventListener('storage', function(){Whisper.Threads.fetch();}); $('.conversation').hide().trigger('close'); // detach any existing conversation views
Whisper.Threads.fetch({reset: true}); this.view = new Whisper.NewConversationView();
}, //todo: less new
events: { },
'click #new-message': 'new_message',
'click #new-group': 'new_group'
},
new_message: function(e) { new_group: function (e) {
e.preventDefault(); e.preventDefault();
$('.conversation').hide().trigger('close'); // detach any existing conversation views $('.conversation').trigger('close'); // detach any existing conversation views
this.view = new Whisper.NewConversationView(); new Whisper.NewGroupView();
//todo: less new },
}, resize: function (e) {
var windowheight = window.innerHeight,
new_group: function(e) { form = $('.send-message-area').outerHeight(),
e.preventDefault(); gutter_offset = this.gutter.offset().top,
$('.conversation').trigger('close'); // detach any existing conversation views contacts_offset = this.contacts.offset().top;
new Whisper.NewGroupView(); if (window.innerWidth < 480) {
}, this.gutter.css('height', windowheight - gutter_offset - form);
resize: function (e) { this.contacts.css('height', windowheight - contacts_offset - form);
var windowheight = window.innerHeight; } else {
var form = $('.send-message-area').outerHeight(); this.gutter.css('height', windowheight - gutter_offset);
var gutter_offset = this.gutter.offset().top; this.contacts.css('height', windowheight - contacts_offset);
var contacts_offset = this.contacts.offset().top; }
if (window.innerWidth < 480) { $('.discussion').css('height', windowheight - gutter_offset - form);
this.gutter.css('height', windowheight - gutter_offset - form); },
this.contacts.css('height', windowheight - contacts_offset - form); setContent: function (content) {
} else { $(content).insertAfter(this.gutter);
this.gutter.css('height', windowheight - gutter_offset); this.resize();
this.contacts.css('height', windowheight - contacts_offset);
} }
$('.discussion').css('height', windowheight - gutter_offset - form); }))({el: document});
},
setContent: function(content) {
$(content).insertAfter(this.gutter);
this.resize();
}
}))({el: document});
if (textsecure.storage.getUnencrypted("number_id") === undefined) { if (textsecure.storage.getUnencrypted("number_id") === undefined) {
window.location = '/options.html'; window.location = '/options.html';
} else { } else {
textsecure.storage.putUnencrypted("unreadCount", 0); textsecure.storage.putUnencrypted("unreadCount", 0);
extension.navigator.setBadgeText(""); extension.navigator.setBadgeText("");
if (Whisper.Threads.length) { if (Whisper.Threads.length) {
Whisper.Threads.at(0).trigger('render'); Whisper.Threads.at(0).trigger('render');
}
} }
} }());