Fixes or ignores (explicidly, as much as possible) jshint warnings.

This commit is contained in:
Boris Grozev 2015-09-10 22:05:53 -05:00
parent 09eaa0d303
commit 27c297c034
26 changed files with 80 additions and 76 deletions

View File

@ -1,6 +1,8 @@
node_modules
libs
replacement.js
prezi.js
muc.js
app.js
debian
analytics.js
modules/xmpp/strophe.emuc.js
modules/UI/prezi/Prezi.js
modules/RTC/adapter.screenshare.js

View File

@ -1,4 +1,5 @@
{
// Refer to http://jshint.com/docs/options/ for an exhaustive list of options
"asi": false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
"expr": true, // true: Tolerate `ExpressionStatement` as Programs
"loopfunc": true, // true: Tolerate functions being defined in loops
@ -12,5 +13,8 @@
"indent": 4, // {int} Number of spaces to use for indentation
"latedef": true, // true: Require variables/functions to be defined before being used
"newcap": true, // true: Require capitalization of all constructor functions e.g. `new F()`
"maxlen": 80 // {int} Max number of characters per line
}
//TODO: set to 80 when the code is compliant..
"maxlen": 1000, // {int} Max number of characters per line
"latedef": false, //This option prohibits the use of a variable before it was defined
"laxbreak": true //Ignore line breaks around "=", "==", "&&", etc.
}

View File

@ -29,9 +29,9 @@ var JitsiMeetExternalAPI = (function()
*/
function JitsiMeetExternalAPI(domain, room_name, width, height, parentNode,
configOverwrite, interfaceConfigOverwrite) {
if((!width || width < MIN_WIDTH) && !filmStripOnly)
if (!width || width < MIN_WIDTH)
width = MIN_WIDTH;
if((!height || height < MIN_HEIGHT) && !filmStripOnly)
if (!height || height < MIN_HEIGHT)
height = MIN_HEIGHT;
this.parentNode = null;
@ -371,4 +371,4 @@ var JitsiMeetExternalAPI = (function()
return JitsiMeetExternalAPI;
})();
})();

View File

@ -69,14 +69,14 @@ var DataChannels = {
if (type === 'string') {
oldValue = (oldValue == "true");
} else {
oldValue = new Boolean(oldValue).valueOf();
oldValue = Boolean(oldValue).valueOf();
}
}
if ((type = typeof newValue) !== 'boolean') {
if (type === 'string') {
newValue = (newValue == "true");
} else {
newValue = new Boolean(newValue).valueOf();
newValue = Boolean(newValue).valueOf();
}
}
@ -151,7 +151,7 @@ var DataChannels = {
function onSelectedEndpointChanged(userResource) {
console.log('selected endpoint changed: ', userResource);
if (_dataChannels && _dataChannels.length != 0) {
if (_dataChannels && _dataChannels.length !== 0) {
_dataChannels.some(function (dataChannel) {
if (dataChannel.readyState == 'open') {
console.log('sending selected endpoint changed ' +

View File

@ -69,7 +69,7 @@ var RTC = {
var localStream = new LocalStream(stream, type, eventEmitter, videoType, isGUMStream);
//in firefox we have only one stream object
if(this.localStreams.length == 0 ||
if(this.localStreams.length === 0 ||
this.localStreams[0].getOriginalStream() != stream)
this.localStreams.push(localStream);
if(isMuted === true)

View File

@ -1,4 +1,6 @@
/* global APP, config, require, attachMediaStream, getUserMedia */
/* global APP, config, require, attachMediaStream, getUserMedia,
RTCPeerConnection, webkitMediaStream, webkitURL, webkitRTCPeerConnection,
mozRTCIceCandidate, mozRTCSessionDescription, mozRTCPeerConnection */
var RTCBrowserType = require("./RTCBrowserType");
var Resolutions = require("../../service/RTC/Resolutions");
var AdapterJS = require("./adapter.screenshare");
@ -192,8 +194,8 @@ function RTCUtils(RTCService, onTemasysPluginReady)
if(element)
element.mozSrcObject = src;
};
RTCSessionDescription = mozRTCSessionDescription;
RTCIceCandidate = mozRTCIceCandidate;
window.RTCSessionDescription = mozRTCSessionDescription;
window.RTCIceCandidate = mozRTCIceCandidate;
} else {
console.error(
"Firefox version too old: " + FFversion + ". Required >= 40.");

View File

@ -312,7 +312,10 @@ function registerListeners() {
});
APP.xmpp.addListener(XMPPEvents.PROMPT_FOR_LOGIN, function () {
// FIXME: re-use LoginDialog which supports retries
// FIXME^2: This looks like a bug...connect is undefined.
/* jshint -W117 */
UI.showLoginPopup(connect);
/* jshint +W117 */
});
APP.xmpp.addListener(XMPPEvents.FOCUS_DISCONNECTED, function (focusComponent, retrySec) {

View File

@ -1,3 +1,4 @@
/* global Strophe, APP, MD5 */
var Settings = require("../../settings/Settings");
var users = {};

View File

@ -1,3 +1,4 @@
/* global PreziPlayer */
(function() {
"use strict";
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
@ -26,7 +27,7 @@
for(var i=0; i<optionArray.length; i++) {
var optionSet = optionArray[i];
new PreziPlayer(optionSet.id, optionSet);
};
}
};
PreziPlayer.messageReceived = function(event){
@ -51,7 +52,9 @@
} catch (e) { }
};
/*jshint -W004 */
function PreziPlayer(id, options) {
/*jshint +W004 */
var params, paramString = "", _this = this;
if (PreziPlayer.players[id]){
PreziPlayer.players[id].destroy();
@ -59,7 +62,7 @@
for(var i=0; i<PreziPlayer.binded_methods.length; i++) {
var method_name = PreziPlayer.binded_methods[i];
_this[method_name] = __bind(_this[method_name], _this);
};
}
options = options || {};
this.options = options;
this.values = {'status': PreziPlayer.STATUS_LOADING};
@ -78,10 +81,10 @@
{ name: 'explorable', value: options.explorable ? 1 : 0 },
{ name: 'controls', value: options.controls ? 1 : 0 }
];
for(var i=0; i<params.length; i++) {
for (i=0; i<params.length; i++) {
var param = params[i];
paramString += (i===0 ? "?" : "&") + param.name + "=" + param.value;
};
}
this.iframe.src = PreziPlayer.domain + PreziPlayer.path + paramString;
this.iframe.frameBorder = 0;
this.iframe.scrolling = "no";
@ -249,14 +252,14 @@
for (var parameter in dims) {
this.iframe[parameter] = dims[parameter];
}
}
};
PreziPlayer.prototype.getDimensions = function() {
return {
width: parseInt(this.iframe.width, 10),
height: parseInt(this.iframe.height, 10)
}
}
};
};
PreziPlayer.prototype.on = function(event, callback) {
this.callbacks.push({

View File

@ -18,7 +18,7 @@ var commands = {
function getCommand(message) {
if(message) {
for(var command in commands) {
if(message.indexOf("/" + command) == 0)
if(message.indexOf("/" + command) === 0)
return command;
}
}

View File

@ -45,7 +45,7 @@ function smilify(body)
return body;
}
var regexs = Smileys["regexs"];
var regexs = Smileys.regexs;
for(var smiley in regexs) {
if(regexs.hasOwnProperty(smiley)) {
body = body.replace(regexs[smiley],

View File

@ -600,7 +600,7 @@ var Toolbar = (function (my) {
if (config.enableRecording && config.autoRecord) {
toggleRecording(config.autoRecordToken);
}
}
};
// Shows or hides SIP calls button
my.showSipCallButton = function (show) {

View File

@ -1,4 +1,4 @@
/* global $, APP, jQuery, toastr */
/* global $, APP, jQuery, toastr, Impromptu */
/**
* Flag for enable/disable of the notifications.

View File

@ -130,7 +130,7 @@ if (!interfaceConfig.filmStripOnly) {
};
} else {
RemoteVideo.prototype.addRemoteVideoMenu = function() {}
RemoteVideo.prototype.addRemoteVideoMenu = function() {};
}
/**

View File

@ -17,7 +17,7 @@ function animate(word) {
var currentVal = $("#enter_room_field").attr("placeholder");
$("#enter_room_field").attr("placeholder", currentVal + word.substr(0, 1));
animateTimeout = setTimeout(function() {
animate(word.substring(1, word.length))
animate(word.substring(1, word.length));
}, 70);
}

View File

@ -1,4 +1,4 @@
/* global $, $iq, config, interfaceConfig */
/* global $, config, interfaceConfig */
var configUtil = require('./Util');
@ -28,8 +28,8 @@ var HttpConfig = {
data: JSON.stringify({"roomName": roomName}),
dataType: 'json',
error: function(jqXHR, textStatus, errorThrown) {
console.error("Get config error: ", jqXHR, errorThrown)
error = "Get config response status: " + textStatus;
console.error("Get config error: ", jqXHR, errorThrown);
var error = "Get config response status: " + textStatus;
complete(false, error);
},
success: function(data, textStatus, jqXHR) {
@ -40,8 +40,7 @@ var HttpConfig = {
return;
} catch (exception) {
console.error("Parse config error: ", exception);
error = exception;
complete(false, error);
complete(false, exception);
}
}
}

View File

@ -1,4 +1,4 @@
/* global config */
/* global config, AudioContext */
/**
* Provides statistics for the local stream.
*/

View File

@ -482,7 +482,7 @@ JingleSessionPC.prototype.createdOffer = function (sdp) {
JingleSessionPC.onJingleError(self.sid, error);
},
10000);
}
};
sdp.sdp = this.localSDP.raw;
this.peerconnection.setLocalDescription(sdp,
function () {
@ -714,7 +714,6 @@ JingleSessionPC.prototype.createdAnswer = function (sdp, provisional) {
this.localSDP.raw = this.localSDP.session + '\r\n' + this.localSDP.media.join('');
}
}
var self = this;
var sendJingle = function (ssrcs) {
// FIXME why do we generate session-accept in 3 different places ?
var accept = $iq({to: self.peerjid,
@ -746,7 +745,7 @@ JingleSessionPC.prototype.createdAnswer = function (sdp, provisional) {
JingleSessionPC.onJingleError(self.sid, error);
},
10000);
}
};
sdp.sdp = this.localSDP.raw;
this.peerconnection.setLocalDescription(sdp,
function () {
@ -815,9 +814,8 @@ JingleSessionPC.prototype.addSource = function (elem, fromJid) {
var self = this;
// FIXME: dirty waiting
if (!this.peerconnection.localDescription)
{
console.warn("addSource - localDescription not ready yet")
if (!this.peerconnection.localDescription) {
console.warn("addSource - localDescription not ready yet");
setTimeout(function()
{
self.addSource(elem, fromJid);
@ -897,11 +895,9 @@ JingleSessionPC.prototype.removeSource = function (elem, fromJid) {
var self = this;
// FIXME: dirty waiting
if (!this.peerconnection.localDescription)
{
console.warn("removeSource - localDescription not ready yet")
setTimeout(function()
{
if (!this.peerconnection.localDescription) {
console.warn("removeSource - localDescription not ready yet");
setTimeout(function() {
self.removeSource(elem, fromJid);
},
200
@ -1312,7 +1308,7 @@ JingleSessionPC.prototype.getStats = function (interval) {
JingleSessionPC.onJingleError = function (session, error)
{
console.error("Jingle error", error);
}
};
JingleSessionPC.onJingleFatalError = function (session, error)
{
@ -1320,7 +1316,7 @@ JingleSessionPC.onJingleFatalError = function (session, error)
this.connection.emuc.doLeave();
this.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
this.eventEmitter.emit(XMPPEvents.JINGLE_FATAL_ERROR, session, error);
}
};
JingleSessionPC.prototype.setLocalDescription = function () {
var self = this;
@ -1360,7 +1356,7 @@ JingleSessionPC.prototype.setLocalDescription = function () {
self.ssrcOwners[ssrc] = myJid;
}
}
}
};
// an attempt to work around https://github.com/jitsi/jitmeet/issues/32
// TODO: is this hack (along with the XMPPEvent-s used only for it) still needed
@ -1450,6 +1446,6 @@ JingleSessionPC.prototype.remoteStreamAdded = function (data, times) {
sendKeyframe(self.peerconnection);
}, 3000);
}
}
};
module.exports = JingleSessionPC;

View File

@ -111,7 +111,8 @@ SDP.prototype.removeSessionLines = function(prefix) {
});
this.raw = this.session + this.media.join('');
return lines;
}
};
// remove lines matching prefix from a media section specified by mediaindex
// TODO: non-numeric mediaindex could match mid
SDP.prototype.removeMediaLines = function(mediaindex, prefix) {
@ -122,7 +123,7 @@ SDP.prototype.removeMediaLines = function(mediaindex, prefix) {
});
this.raw = this.session + this.media.join('');
return lines;
}
};
// add content's to a jingle element
SDP.prototype.toJingle = function (elem, thecreator, ssrcs) {
@ -236,16 +237,12 @@ SDP.prototype.toJingle = function (elem, thecreator, ssrcs) {
elem.attrs({name: "cname", value:Math.random().toString(36).substring(7)});
elem.up();
var msid = null;
if(mline.media == "audio")
{
if(mline.media == "audio") {
msid = APP.RTC.localAudio.getId();
}
else
{
} else {
msid = APP.RTC.localVideo.getId();
}
if(msid != null)
{
if(msid !== null) {
msid = SDPUtil.filter_special_chars(msid);
elem.c('parameter');
elem.attrs({name: "msid", value:msid});
@ -390,7 +387,7 @@ SDP.prototype.TransportToJingle = function (mediaindex, elem) {
}
}
elem.up(); // end of transport
}
};
SDP.prototype.RtcpFbToJingle = function (mediaindex, elem, payloadtype) { // XEP-0293
var lines = SDPUtil.find_lines(this.media[mediaindex], 'a=rtcp-fb:' + payloadtype);

View File

@ -1,4 +1,4 @@
SDPUtil = {
var SDPUtil = {
filter_special_chars: function (text) {
return text.replace(/[\\\/\{,\}\+]/g, "");
},

View File

@ -1,4 +1,5 @@
/* global $ */
/* global $, config, mozRTCPeerConnection, RTCPeerConnection,
webkitRTCPeerConnection, RTCSessionDescription */
var RTC = require('../RTC/RTC');
var RTCBrowserType = require("../RTC/RTCBrowserType.js");
var XMPPEvents = require("../../service/xmpp/XMPPEvents");
@ -128,7 +129,7 @@ function TraceablePeerConnection(ice_config, constraints, session) {
* Returns a string representation of a SessionDescription object.
*/
var dumpSDP = function(description) {
if (typeof description === 'undefined' || description == null) {
if (typeof description === 'undefined' || description === null) {
return '';
}

View File

@ -33,8 +33,8 @@ module.exports = function(XMPP, eventEmitter) {
this.connection.disco.addFeature('urn:xmpp:jingle:apps:rtp:audio');
this.connection.disco.addFeature('urn:xmpp:jingle:apps:rtp:video');
if (RTCBrowserType.isChrome() || RTCBrowserType.isOpera()
|| RTCBrowserType.isTemasysPluginUsed()) {
if (RTCBrowserType.isChrome() || RTCBrowserType.isOpera() ||
RTCBrowserType.isTemasysPluginUsed()) {
this.connection.disco.addFeature('urn:ietf:rfc:4588');
}
@ -138,12 +138,7 @@ module.exports = function(XMPP, eventEmitter) {
$(document).trigger('callaccepted.jingle', [sess.sid]);
break;
case 'session-terminate':
// If this is not the focus sending the terminate, we have
// nothing more to do here.
if (Object.keys(this.sessions).length < 1
|| !(this.sessions[Object.keys(this.sessions)[0]]
instanceof JingleSession))
{
if (!sess) {
break;
}
console.log('terminating...', sess.sid);

View File

@ -57,4 +57,4 @@ module.exports = function (XMPP, eventEmitter) {
this.connection.emuc.kick(jid);
}
});
}
};

View File

@ -1,3 +1,4 @@
/* global Strophe */
/**
* Strophe logger implementation. Logs from level WARN and above.
*/

View File

@ -1,4 +1,4 @@
/* global $, APP, config, Strophe*/
/* global $, APP, config, Strophe, Base64, $msg */
var Moderator = require("./moderator");
var EventEmitter = require("events");
var Recording = require("./recording");

View File

@ -1,9 +1,9 @@
module.exports = {
getLanguages : function () {
var languages = [];
for(var lang in this)
for (var lang in this)
{
if(typeof this[lang] === "string")
if (typeof this[lang] === "string")
languages.push(this[lang]);
}
return languages;
@ -13,4 +13,4 @@ module.exports = {
DE: "de",
TR: "tr",
FR: "fr"
}
};