Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

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

Boris Grozev27c297c03420
diff --git a/.jshintignore b/.jshintignore
index 3c7ab2ba9d..edb07dd2bd 100644
--- a/.jshintignore
+++ b/.jshintignore
@@ -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
diff --git a/.jshintrc b/.jshintrc
index 8f9506cdf7..a99d850b81 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -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
-}
\ No newline at end of file
+ //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.
+}
diff --git a/external_api.js b/external_api.js
index 78fbb6f5c9..0c8624a2b5 100644
--- a/external_api.js
+++ b/external_api.js
@@ -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;
-})();
\ No newline at end of file
+})();
diff --git a/modules/RTC/DataChannels.js b/modules/RTC/DataChannels.js
index 8fc1971208..01e8ee7c8a 100644
--- a/modules/RTC/DataChannels.js
+++ b/modules/RTC/DataChannels.js
@@ -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 ' +
diff --git a/modules/RTC/RTC.js b/modules/RTC/RTC.js
index 3c09912ff1..2b7afffd14 100644
--- a/modules/RTC/RTC.js
+++ b/modules/RTC/RTC.js
@@ -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)
diff --git a/modules/RTC/RTCUtils.js b/modules/RTC/RTCUtils.js
index ded4a6c51f..4d85cfb059 100644
--- a/modules/RTC/RTCUtils.js
+++ b/modules/RTC/RTCUtils.js
@@ -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.");
diff --git a/modules/UI/UI.js b/modules/UI/UI.js
index badc96d888..b1781f0ac7 100644
--- a/modules/UI/UI.js
+++ b/modules/UI/UI.js
@@ -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) {
diff --git a/modules/UI/avatar/Avatar.js b/modules/UI/avatar/Avatar.js
index 2f51f0f72e..6ab1327e45 100644
--- a/modules/UI/avatar/Avatar.js
+++ b/modules/UI/avatar/Avatar.js
@@ -1,3 +1,4 @@
+/* global Strophe, APP, MD5 */
var Settings = require("../../settings/Settings");
var users = {};
diff --git a/modules/UI/prezi/PreziPlayer.js b/modules/UI/prezi/PreziPlayer.js
index e6a42c1e57..f7c5222961 100644
--- a/modules/UI/prezi/PreziPlayer.js
+++ b/modules/UI/prezi/PreziPlayer.js
@@ -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({
diff --git a/modules/UI/side_pannels/chat/Commands.js b/modules/UI/side_pannels/chat/Commands.js
index 7dbd07523c..c3fc3abae4 100644
--- a/modules/UI/side_pannels/chat/Commands.js
+++ b/modules/UI/side_pannels/chat/Commands.js
@@ -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;
}
}
diff --git a/modules/UI/side_pannels/chat/Replacement.js b/modules/UI/side_pannels/chat/Replacement.js
index 123a94a392..b7d0442204 100644
--- a/modules/UI/side_pannels/chat/Replacement.js
+++ b/modules/UI/side_pannels/chat/Replacement.js
@@ -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],
diff --git a/modules/UI/toolbars/Toolbar.js b/modules/UI/toolbars/Toolbar.js
index a0d0d1d787..7ed5a0c62d 100644
--- a/modules/UI/toolbars/Toolbar.js
+++ b/modules/UI/toolbars/Toolbar.js
@@ -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) {
diff --git a/modules/UI/util/MessageHandler.js b/modules/UI/util/MessageHandler.js
index baaa4f721f..bb08841396 100644
--- a/modules/UI/util/MessageHandler.js
+++ b/modules/UI/util/MessageHandler.js
@@ -1,4 +1,4 @@
-/* global $, APP, jQuery, toastr */
+/* global $, APP, jQuery, toastr, Impromptu */
/**
* Flag for enable/disable of the notifications.
diff --git a/modules/UI/videolayout/RemoteVideo.js b/modules/UI/videolayout/RemoteVideo.js
index 511c36491b..8ffff14d8a 100644
--- a/modules/UI/videolayout/RemoteVideo.js
+++ b/modules/UI/videolayout/RemoteVideo.js
@@ -130,7 +130,7 @@ if (!interfaceConfig.filmStripOnly) {
};
} else {
- RemoteVideo.prototype.addRemoteVideoMenu = function() {}
+ RemoteVideo.prototype.addRemoteVideoMenu = function() {};
}
/**
diff --git a/modules/UI/welcome_page/WelcomePage.js b/modules/UI/welcome_page/WelcomePage.js
index 04040df760..3a7b9692df 100644
--- a/modules/UI/welcome_page/WelcomePage.js
+++ b/modules/UI/welcome_page/WelcomePage.js
@@ -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);
}
diff --git a/modules/config/HttpConfigFetch.js b/modules/config/HttpConfigFetch.js
index b66ba8a529..d7f4cf59ad 100644
--- a/modules/config/HttpConfigFetch.js
+++ b/modules/config/HttpConfigFetch.js
@@ -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);
}
}
}
diff --git a/modules/statistics/LocalStatsCollector.js b/modules/statistics/LocalStatsCollector.js
index c2f622ef2b..420ba9a2df 100644
--- a/modules/statistics/LocalStatsCollector.js
+++ b/modules/statistics/LocalStatsCollector.js
@@ -1,4 +1,4 @@
-/* global config */
+/* global config, AudioContext */
/**
* Provides statistics for the local stream.
*/
diff --git a/modules/xmpp/JingleSessionPC.js b/modules/xmpp/JingleSessionPC.js
index 18ae10d4ab..4deef71f75 100644
--- a/modules/xmpp/JingleSessionPC.js
+++ b/modules/xmpp/JingleSessionPC.js
@@ -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;
diff --git a/modules/xmpp/SDP.js b/modules/xmpp/SDP.js
index d9c85ce3ef..6837d64d81 100644
--- a/modules/xmpp/SDP.js
+++ b/modules/xmpp/SDP.js
@@ -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);
diff --git a/modules/xmpp/SDPUtil.js b/modules/xmpp/SDPUtil.js
index 92eeb3378e..bde0841f6b 100644
--- a/modules/xmpp/SDPUtil.js
+++ b/modules/xmpp/SDPUtil.js
@@ -1,4 +1,4 @@
-SDPUtil = {
+var SDPUtil = {
filter_special_chars: function (text) {
return text.replace(/[\\\/\{,\}\+]/g, "");
},
diff --git a/modules/xmpp/TraceablePeerConnection.js b/modules/xmpp/TraceablePeerConnection.js
index 0acd33dd93..a099e79d1e 100644
--- a/modules/xmpp/TraceablePeerConnection.js
+++ b/modules/xmpp/TraceablePeerConnection.js
@@ -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 '';
}
diff --git a/modules/xmpp/strophe.jingle.js b/modules/xmpp/strophe.jingle.js
index f1adc5f6bf..ed92072b9b 100644
--- a/modules/xmpp/strophe.jingle.js
+++ b/modules/xmpp/strophe.jingle.js
@@ -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);
diff --git a/modules/xmpp/strophe.moderate.js b/modules/xmpp/strophe.moderate.js
index 33f73d15bb..55e396462d 100644
--- a/modules/xmpp/strophe.moderate.js
+++ b/modules/xmpp/strophe.moderate.js
@@ -57,4 +57,4 @@ module.exports = function (XMPP, eventEmitter) {
this.connection.emuc.kick(jid);
}
});
-}
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/modules/xmpp/strophe.util.js b/modules/xmpp/strophe.util.js
index b7d834828c..56a26d54fa 100644
--- a/modules/xmpp/strophe.util.js
+++ b/modules/xmpp/strophe.util.js
@@ -1,3 +1,4 @@
+/* global Strophe */
/**
* Strophe logger implementation. Logs from level WARN and above.
*/
diff --git a/modules/xmpp/xmpp.js b/modules/xmpp/xmpp.js
index e5183ce49b..fce4d9fafe 100644
--- a/modules/xmpp/xmpp.js
+++ b/modules/xmpp/xmpp.js
@@ -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");
diff --git a/service/translation/languages.js b/service/translation/languages.js
index 30a6719194..e00bc2c06a 100644
--- a/service/translation/languages.js
+++ b/service/translation/languages.js
@@ -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"
-}
\ No newline at end of file
+};
\ No newline at end of file