Fix comparison warnings.

This commit is contained in:
Boris Grozev 2015-09-10 22:26:29 -05:00
parent b0795e5db9
commit 09eaa0d303
16 changed files with 25 additions and 28 deletions

View File

@ -171,14 +171,13 @@ function onSelectedEndpointChanged(userResource) {
function onPinnedEndpointChanged(userResource) {
console.log('pinned endpoint changed: ', userResource);
if (_dataChannels && _dataChannels.length != 0) {
if (_dataChannels && _dataChannels.length !== 0) {
_dataChannels.some(function (dataChannel) {
if (dataChannel.readyState == 'open') {
dataChannel.send(JSON.stringify({
'colibriClass': 'PinnedEndpointChangedEvent',
'pinnedEndpoint':
(!userResource || userResource == null)?
null : userResource
userResource ? userResource : null
}));
return true;

View File

@ -101,7 +101,7 @@ var RTC = {
// check the video muted state from last stored presence if any
var muted = false;
var pres = APP.xmpp.getLastPresence(jid);
if(pres != null && pres.videoMuted) {
if (pres && pres.videoMuted) {
muted = pres.videoMuted;
}

View File

@ -13,7 +13,7 @@ function getPreviousResolution(resolution) {
var resName = null;
for(var i in Resolutions) {
var tmp = Resolutions[i];
if(res == null || (res.order < tmp.order && tmp.order < order)) {
if (!res || (res.order < tmp.order && tmp.order < order)) {
resName = i;
res = tmp;
}
@ -455,7 +455,7 @@ RTCUtils.prototype.errorCallback = function (error) {
error.name == "OverconstrainedError") &&
(error.constraintName == "minWidth" || error.constraintName == "maxWidth" ||
error.constraintName == "minHeight" || error.constraintName == "maxHeight")
&& resolution != null)
&& resolution)
{
self.getUserMediaWithConstraints(['audio', 'video'],
function (stream) {

View File

@ -755,7 +755,7 @@ UI.showLoginPopup = function(callback) {
"dialog.Ok",
function (e, v, m, f) {
if (v) {
if (f.username !== null && f.password != null) {
if (f.username && f.password) {
callback(f.username, f.password);
}
}

View File

@ -126,7 +126,7 @@ var AudioLevels = (function(my) {
return;
ASDrawContext.clearRect(0, 0, 300, 300);
if(audioLevel == 0)
if (!audioLevel)
return;
ASDrawContext.shadowBlur = getShadowLevel(audioLevel);

View File

@ -168,7 +168,7 @@
}
// jump to animation steps by calling flyToNextStep()
function doAnimationSteps() {
if (obj.values.isMoving == true) {
if (obj.values.isMoving) {
setTimeout(doAnimationSteps, 100); // wait until the flight ends
return;
}

View File

@ -86,7 +86,7 @@ ConnectionIndicator.prototype.generateText = function () {
}
var resolutionValue = null;
if(this.resolution && this.jid != null) {
if(this.resolution && this.jid) {
var keys = Object.keys(this.resolution);
for(var ssrc in this.resolution) {
resolutionValue = this.resolution[ssrc];

View File

@ -2,8 +2,6 @@
var ConnectionIndicator = require("./ConnectionIndicator");
var SmallVideo = require("./SmallVideo");
var AudioLevels = require("../audio_levels/AudioLevels");
var LargeVideo = require("./LargeVideo");
var Avatar = require("../avatar/Avatar");
var RTCBrowserType = require("../../RTC/RTCBrowserType");
var UIUtils = require("../util/UIUtil");
@ -84,10 +82,10 @@ if (!interfaceConfig.filmStripOnly) {
var self = this;
muteLinkItem.onclick = function(){
if ($(this).attr('disabled') != undefined) {
if ($(this).attr('disabled')) {
event.preventDefault();
}
var isMute = self.isMuted == true;
var isMute = !!self.isMuted;
APP.xmpp.setMute(self.peerJid, !isMute);
popupmenuElement.setAttribute('style', 'display:none;');

View File

@ -171,7 +171,7 @@ SmallVideo.prototype.showAudioIndicator = function(isMuted) {
}
}
else {
if(audioMutedSpan.length == 0 ) {
if (!audioMutedSpan.length) {
audioMutedSpan = document.createElement('span');
audioMutedSpan.className = 'audioMuted';
UIUtil.setTooltip(audioMutedSpan,
@ -204,7 +204,7 @@ SmallVideo.prototype.showVideoIndicator = function(isMuted) {
}
}
else {
if(videoMutedSpan.length == 0) {
if (!videoMutedSpan.length) {
videoMutedSpan = document.createElement('span');
videoMutedSpan.className = 'videoMuted';

View File

@ -49,7 +49,7 @@ var VideoLayout = (function (my) {
my.isInLastN = function(resource) {
return lastNCount < 0 || // lastN is disabled
// lastNEndpoints cache not built yet
(lastNCount > 0 && lastNEndpointsCache.length == 0) ||
(lastNCount > 0 && !lastNEndpointsCache.length) ||
(lastNEndpointsCache &&
lastNEndpointsCache.indexOf(resource) !== -1);
};

View File

@ -87,7 +87,7 @@ var ConnectionQuality = {
updateLocalStats: function (data) {
stats = data;
eventEmitter.emit(CQEvents.LOCALSTATS_UPDATED, 100 - stats.packetLoss.total, stats);
if (sendIntervalId == null) {
if (!sendIntervalId) {
startSendingStats();
}
},
@ -98,7 +98,7 @@ var ConnectionQuality = {
* @param data the statistics
*/
updateRemoteStats: function (jid, data) {
if (data == null || data.packetLoss_total == null) {
if (!data || !data.packetLoss_total) {
eventEmitter.emit(CQEvents.REMOTESTATS_UPDATED, jid, null, null);
return;
}

View File

@ -844,7 +844,7 @@ JingleSessionPC.prototype.addSource = function (elem, fromJid) {
return this.getAttribute('ssrc');
}).get();
if (ssrcs.length != 0) {
if (!ssrcs.length) {
lines += 'a=ssrc-group:' + semantics + ' ' + ssrcs.join(' ') + '\r\n';
}
});
@ -923,7 +923,7 @@ JingleSessionPC.prototype.removeSource = function (elem, fromJid) {
return this.getAttribute('ssrc');
}).get();
if (ssrcs.length != 0) {
if (ssrcs.length) {
lines += 'a=ssrc-group:' + semantics + ' ' + ssrcs.join(' ') + '\r\n';
}
});
@ -1328,7 +1328,7 @@ JingleSessionPC.prototype.setLocalDescription = function () {
var session = transform.parse(this.peerconnection.localDescription.sdp);
session.media.forEach(function (media) {
if (media.ssrcs != null && media.ssrcs.length > 0) {
if (media.ssrcs && media.ssrcs.length > 0) {
// TODO(gp) maybe exclude FID streams?
media.ssrcs.forEach(function (ssrc) {
if (ssrc.attribute !== 'cname') {

View File

@ -45,7 +45,7 @@ SDP.prototype.getMediaSsrcMap = function() {
tmp.forEach(function(line){
var semantics = line.substr(0, idx).substr(13);
var ssrcs = line.substr(14 + semantics.length).split(' ');
if (ssrcs.length != 0) {
if (ssrcs.length) {
media.ssrcGroups.push({
semantics: semantics,
ssrcs: ssrcs
@ -266,7 +266,7 @@ SDP.prototype.toJingle = function (elem, thecreator, ssrcs) {
idx = line.indexOf(' ');
var semantics = line.substr(0, idx).substr(13);
var ssrcs = line.substr(14 + semantics.length).split(' ');
if (ssrcs.length != 0) {
if (ssrcs.length) {
elem.c('ssrc-group', { semantics: semantics, xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0' });
ssrcs.forEach(function(ssrc) {
elem.c('source', { ssrc: ssrc })
@ -597,7 +597,7 @@ SDP.prototype.jingle2media = function (content) {
return this.getAttribute('ssrc');
}).get();
if (ssrcs.length != 0) {
if (ssrcs.length) {
media += 'a=ssrc-group:' + semantics + ' ' + ssrcs.join(' ') + '\r\n';
}
});

View File

@ -143,7 +143,7 @@ SDPDiffer.prototype.toJingle = function(modify) {
// generate source groups from lines
media.ssrcGroups.forEach(function(ssrcGroup) {
if (ssrcGroup.ssrcs.length != 0) {
if (ssrcGroup.ssrcs.length) {
modify.c('ssrc-group', {
semantics: ssrcGroup.semantics,

View File

@ -179,7 +179,7 @@ var normalizePlanB = function(desc) {
for (i = 0; i<mLine.ssrcs.length; i++){
if (typeof mLine.ssrcs[i] === 'object'
&& typeof mLine.ssrcs[i].id !== 'undefined'
&& $.inArray(mLine.ssrcs[i].id, firstSsrcs) == 0) {
&& !$.inArray(mLine.ssrcs[i].id, firstSsrcs)) {
newSsrcLines.push(mLine.ssrcs[i]);
delete mLine.ssrcs[i];
}

View File

@ -84,7 +84,7 @@ function setRecordingColibri(state, token, callback, connection) {
recordingEnabled = newState;
callback(newState);
if (newState === 'pending' && recordingStateChangeCallback == null) {
if (newState === 'pending' && !recordingStateChangeCallback) {
recordingStateChangeCallback = callback;
connection.addHandler(function(iq){
var state = $(iq).find('recording').attr('state');