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

View File

@ -1,3 +1,4 @@
/*global chrome*/
/* vim: ts=4:sw=4
*
* 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
* 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() {
var self = {};
var tabs = {};
tabs.create = function(url){
chrome.tabs.create({url: url});
};
self.tabs = tabs;
self.setBadgeText = function(text){
chrome.browserAction.setBadgeText({text: text + ""});
};
return self;
}();
self.setBadgeText = function (text) {
chrome.browserAction.setBadgeText({text: String(text)});
};
// Random shared utilities that are used only by chromium things
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() {
localStorage.setItem("chromiumRegistrationDone", "");
chrome.runtime.sendMessage('registration_done');
window.location = '/index.html';
}
function addRegistrationListener(callback) {
chrome.runtime.onMessage.addListener(function(message) {
if (message === 'registration_done') {
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:
*
* 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
* 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({
initialize: function() {
this.gutter = $('#gutter');
this.contacts = $('#contacts');
this.resize();
new Whisper.ConversationListView({el: $('#contacts')});
window.addEventListener('resize', this.resize.bind(this));
window.addEventListener('storage', function () {Whisper.Threads.fetch(); });
Whisper.Threads.fetch({reset: true});
},
events: {
'click #new-message': 'new_message',
'click #new-group': 'new_group'
},
new Whisper.ConversationListView({el: $('#contacts')});
window.addEventListener('resize', this.resize.bind(this));
window.addEventListener('storage', function(){Whisper.Threads.fetch();});
Whisper.Threads.fetch({reset: true});
},
events: {
'click #new-message': 'new_message',
'click #new-group': 'new_group'
},
new_message: function (e) {
e.preventDefault();
$('.conversation').hide().trigger('close'); // detach any existing conversation views
this.view = new Whisper.NewConversationView();
//todo: less new
},
new_message: function(e) {
e.preventDefault();
$('.conversation').hide().trigger('close'); // detach any existing conversation views
this.view = new Whisper.NewConversationView();
//todo: less new
},
new_group: function(e) {
e.preventDefault();
$('.conversation').trigger('close'); // detach any existing conversation views
new Whisper.NewGroupView();
},
resize: function (e) {
var windowheight = window.innerHeight;
var form = $('.send-message-area').outerHeight();
var gutter_offset = this.gutter.offset().top;
var contacts_offset = this.contacts.offset().top;
if (window.innerWidth < 480) {
this.gutter.css('height', windowheight - gutter_offset - form);
this.contacts.css('height', windowheight - contacts_offset - form);
} else {
this.gutter.css('height', windowheight - gutter_offset);
this.contacts.css('height', windowheight - contacts_offset);
new_group: function (e) {
e.preventDefault();
$('.conversation').trigger('close'); // detach any existing conversation views
new Whisper.NewGroupView();
},
resize: function (e) {
var windowheight = window.innerHeight,
form = $('.send-message-area').outerHeight(),
gutter_offset = this.gutter.offset().top,
contacts_offset = this.contacts.offset().top;
if (window.innerWidth < 480) {
this.gutter.css('height', windowheight - gutter_offset - form);
this.contacts.css('height', windowheight - contacts_offset - form);
} else {
this.gutter.css('height', windowheight - gutter_offset);
this.contacts.css('height', windowheight - contacts_offset);
}
$('.discussion').css('height', windowheight - gutter_offset - form);
},
setContent: function (content) {
$(content).insertAfter(this.gutter);
this.resize();
}
$('.discussion').css('height', windowheight - gutter_offset - form);
},
setContent: function(content) {
$(content).insertAfter(this.gutter);
this.resize();
}
}))({el: document});
}))({el: document});
if (textsecure.storage.getUnencrypted("number_id") === undefined) {
window.location = '/options.html';
} else {
textsecure.storage.putUnencrypted("unreadCount", 0);
extension.navigator.setBadgeText("");
if (Whisper.Threads.length) {
Whisper.Threads.at(0).trigger('render');
if (textsecure.storage.getUnencrypted("number_id") === undefined) {
window.location = '/options.html';
} else {
textsecure.storage.putUnencrypted("unreadCount", 0);
extension.navigator.setBadgeText("");
if (Whisper.Threads.length) {
Whisper.Threads.at(0).trigger('render');
}
}
}
}());