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 node_modules
libs libs
replacement.js debian
prezi.js analytics.js
muc.js
app.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) "asi": false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
"expr": true, // true: Tolerate `ExpressionStatement` as Programs "expr": true, // true: Tolerate `ExpressionStatement` as Programs
"loopfunc": true, // true: Tolerate functions being defined in loops "loopfunc": true, // true: Tolerate functions being defined in loops
@ -12,5 +13,8 @@
"indent": 4, // {int} Number of spaces to use for indentation "indent": 4, // {int} Number of spaces to use for indentation
"latedef": true, // true: Require variables/functions to be defined before being used "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()` "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, function JitsiMeetExternalAPI(domain, room_name, width, height, parentNode,
configOverwrite, interfaceConfigOverwrite) { configOverwrite, interfaceConfigOverwrite) {
if((!width || width < MIN_WIDTH) && !filmStripOnly) if (!width || width < MIN_WIDTH)
width = MIN_WIDTH; width = MIN_WIDTH;
if((!height || height < MIN_HEIGHT) && !filmStripOnly) if (!height || height < MIN_HEIGHT)
height = MIN_HEIGHT; height = MIN_HEIGHT;
this.parentNode = null; this.parentNode = null;

View File

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

View File

@ -69,7 +69,7 @@ var RTC = {
var localStream = new LocalStream(stream, type, eventEmitter, videoType, isGUMStream); var localStream = new LocalStream(stream, type, eventEmitter, videoType, isGUMStream);
//in firefox we have only one stream object //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[0].getOriginalStream() != stream)
this.localStreams.push(localStream); this.localStreams.push(localStream);
if(isMuted === true) 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 RTCBrowserType = require("./RTCBrowserType");
var Resolutions = require("../../service/RTC/Resolutions"); var Resolutions = require("../../service/RTC/Resolutions");
var AdapterJS = require("./adapter.screenshare"); var AdapterJS = require("./adapter.screenshare");
@ -192,8 +194,8 @@ function RTCUtils(RTCService, onTemasysPluginReady)
if(element) if(element)
element.mozSrcObject = src; element.mozSrcObject = src;
}; };
RTCSessionDescription = mozRTCSessionDescription; window.RTCSessionDescription = mozRTCSessionDescription;
RTCIceCandidate = mozRTCIceCandidate; window.RTCIceCandidate = mozRTCIceCandidate;
} else { } else {
console.error( console.error(
"Firefox version too old: " + FFversion + ". Required >= 40."); "Firefox version too old: " + FFversion + ". Required >= 40.");

View File

@ -312,7 +312,10 @@ function registerListeners() {
}); });
APP.xmpp.addListener(XMPPEvents.PROMPT_FOR_LOGIN, function () { APP.xmpp.addListener(XMPPEvents.PROMPT_FOR_LOGIN, function () {
// FIXME: re-use LoginDialog which supports retries // FIXME: re-use LoginDialog which supports retries
// FIXME^2: This looks like a bug...connect is undefined.
/* jshint -W117 */
UI.showLoginPopup(connect); UI.showLoginPopup(connect);
/* jshint +W117 */
}); });
APP.xmpp.addListener(XMPPEvents.FOCUS_DISCONNECTED, function (focusComponent, retrySec) { 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 Settings = require("../../settings/Settings");
var users = {}; var users = {};

View File

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

View File

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

View File

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

View File

@ -600,7 +600,7 @@ var Toolbar = (function (my) {
if (config.enableRecording && config.autoRecord) { if (config.enableRecording && config.autoRecord) {
toggleRecording(config.autoRecordToken); toggleRecording(config.autoRecordToken);
} }
} };
// Shows or hides SIP calls button // Shows or hides SIP calls button
my.showSipCallButton = function (show) { 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. * Flag for enable/disable of the notifications.

View File

@ -130,7 +130,7 @@ if (!interfaceConfig.filmStripOnly) {
}; };
} else { } 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"); var currentVal = $("#enter_room_field").attr("placeholder");
$("#enter_room_field").attr("placeholder", currentVal + word.substr(0, 1)); $("#enter_room_field").attr("placeholder", currentVal + word.substr(0, 1));
animateTimeout = setTimeout(function() { animateTimeout = setTimeout(function() {
animate(word.substring(1, word.length)) animate(word.substring(1, word.length));
}, 70); }, 70);
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,5 @@
/* global $ */ /* global $, config, mozRTCPeerConnection, RTCPeerConnection,
webkitRTCPeerConnection, RTCSessionDescription */
var RTC = require('../RTC/RTC'); var RTC = require('../RTC/RTC');
var RTCBrowserType = require("../RTC/RTCBrowserType.js"); var RTCBrowserType = require("../RTC/RTCBrowserType.js");
var XMPPEvents = require("../../service/xmpp/XMPPEvents"); var XMPPEvents = require("../../service/xmpp/XMPPEvents");
@ -128,7 +129,7 @@ function TraceablePeerConnection(ice_config, constraints, session) {
* Returns a string representation of a SessionDescription object. * Returns a string representation of a SessionDescription object.
*/ */
var dumpSDP = function(description) { var dumpSDP = function(description) {
if (typeof description === 'undefined' || description == null) { if (typeof description === 'undefined' || description === null) {
return ''; 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:audio');
this.connection.disco.addFeature('urn:xmpp:jingle:apps:rtp:video'); this.connection.disco.addFeature('urn:xmpp:jingle:apps:rtp:video');
if (RTCBrowserType.isChrome() || RTCBrowserType.isOpera() if (RTCBrowserType.isChrome() || RTCBrowserType.isOpera() ||
|| RTCBrowserType.isTemasysPluginUsed()) { RTCBrowserType.isTemasysPluginUsed()) {
this.connection.disco.addFeature('urn:ietf:rfc:4588'); this.connection.disco.addFeature('urn:ietf:rfc:4588');
} }
@ -138,12 +138,7 @@ module.exports = function(XMPP, eventEmitter) {
$(document).trigger('callaccepted.jingle', [sess.sid]); $(document).trigger('callaccepted.jingle', [sess.sid]);
break; break;
case 'session-terminate': case 'session-terminate':
// If this is not the focus sending the terminate, we have if (!sess) {
// nothing more to do here.
if (Object.keys(this.sessions).length < 1
|| !(this.sessions[Object.keys(this.sessions)[0]]
instanceof JingleSession))
{
break; break;
} }
console.log('terminating...', sess.sid); console.log('terminating...', sess.sid);

View File

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

View File

@ -1,3 +1,4 @@
/* global Strophe */
/** /**
* Strophe logger implementation. Logs from level WARN and above. * 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 Moderator = require("./moderator");
var EventEmitter = require("events"); var EventEmitter = require("events");
var Recording = require("./recording"); var Recording = require("./recording");

View File

@ -13,4 +13,4 @@ module.exports = {
DE: "de", DE: "de",
TR: "tr", TR: "tr",
FR: "fr" FR: "fr"
} };