Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
KaptenJansson committed Jun 13, 2017
1 parent 8f7a7ba commit 127baa0
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 108 deletions.
7 changes: 6 additions & 1 deletion build/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
"indent": [
2,
2,
{ "SwitchCase": 1, "VariableDeclarator": 1 }
{
"SwitchCase": 1,
"VariableDeclarator": 2,
"MemberExpression": 2,
"CallExpression": {"arguments": 2}
}
],
"key-spacing": [2, {"beforeColon": false, "afterColon": true}],
"max-len": [2, 80, 2, {"ignoreUrls": true}],
Expand Down
4 changes: 2 additions & 2 deletions src/web_app/js/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ Analytics.prototype.sendEventRequest_ = function(eventObj) {
request[enums.RequestField.EVENT] = eventObj;

sendAsyncUrlRequest('POST', this.analyticsPath_,
JSON.stringify(request)).then(function() {
}.bind(this), function(error) {
JSON.stringify(request))
.then(function() {}.bind(this), function(error) {
trace('Failed to send event request: ' + error.message);
}.bind(this));
};
11 changes: 4 additions & 7 deletions src/web_app/js/appcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ AppController.prototype.createCall_ = function() {
this.hide_(privacyLinks);
this.call_ = new Call(this.loadingParams_);
this.infoBox_ = new InfoBox($(UI_CONSTANTS.infoDiv),
this.remoteVideo_,
this.call_,
this.loadingParams_.versionInfo);
this.remoteVideo_, this.call_, this.loadingParams_.versionInfo);

var roomErrors = this.loadingParams_.errorMessages;
var roomWarnings = this.loadingParams_.warningMessages;
Expand Down Expand Up @@ -275,7 +273,7 @@ AppController.prototype.onRemoteSdpSet_ = function(hasRemoteVideo) {
AppController.prototype.waitForRemoteVideo_ = function() {
// Wait for the actual video to start arriving before moving to the active
// call state.
if (this.remoteVideo_.readyState >= 2) { // i.e. can play
if (this.remoteVideo_.readyState >= 2) { // i.e. can play
trace('Remote video started; currentTime: ' +
this.remoteVideo_.currentTime);
this.transitionToActive_();
Expand Down Expand Up @@ -436,9 +434,8 @@ AppController.prototype.onKeyPress_ = function(event) {

AppController.prototype.pushCallNavigation_ = function(roomId, roomLink) {
if (!isChromeApp()) {
window.history.pushState({'roomId': roomId, 'roomLink': roomLink},
roomId,
roomLink);
window.history.pushState({'roomId': roomId, 'roomLink': roomLink}, roomId,
roomLink);
}
};

Expand Down
8 changes: 4 additions & 4 deletions src/web_app/js/appcontroller_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ describe('AppControllerTest', function() {
// Needed due to a race where the textContent node is not updated in the div
// before testing it.
$(UI_CONSTANTS.confirmJoinRoomSpan)
.addEventListener('DOMSubtreeModified', function() {
done();
});
.addEventListener('DOMSubtreeModified', function() {
done();
});
});

afterEach(function() {
Expand All @@ -94,7 +94,7 @@ describe('AppControllerTest', function() {
setTimeout(function() {
$(UI_CONSTANTS.confirmJoinButton).addEventListener('click', function() {
expect($(UI_CONSTANTS.confirmJoinDiv).classList.contains('hidden'))
.toBeTruthy();
.toBeTruthy();
done();
});
$(UI_CONSTANTS.confirmJoinButton).click();
Expand Down
117 changes: 59 additions & 58 deletions src/web_app/js/call.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ Call.prototype.hangup = function(async) {
var promise = Promise.resolve();
for (var i = 0; i < steps.length; ++i) {
promise = promise.then(steps[i].step).catch(
errorHandler.bind(this, steps[i].errorString));
errorHandler.bind(this, steps[i].errorString));
}

return promise;
Expand Down Expand Up @@ -353,33 +353,34 @@ Call.prototype.maybeGetMedia_ = function() {
var mediaConstraints = this.params_.mediaConstraints;

mediaPromise = navigator.mediaDevices.getUserMedia(mediaConstraints)
.catch(function(error) {
if (error.name !== 'NotFoundError') {
throw error;
}
return navigator.mediaDevices.enumerateDevices().then(function(devices) {
var cam = devices.find(function(device) {
return device.kind === 'videoinput';
});
var mic = devices.find(function(device) {
return device.kind === 'audioinput';
});
var constraints = {
video: cam && mediaConstraints.video,
audio: mic && mediaConstraints.audio
};
return navigator.mediaDevices.getUserMedia(constraints);
});
})
.then(function(stream) {
trace('Got access to local media with mediaConstraints:\n' +
.catch(function(error) {
if (error.name !== 'NotFoundError') {
throw error;
}
return navigator.mediaDevices.enumerateDevices()
.then(function(devices) {
var cam = devices.find(function(device) {
return device.kind === 'videoinput';
});
var mic = devices.find(function(device) {
return device.kind === 'audioinput';
});
var constraints = {
video: cam && mediaConstraints.video,
audio: mic && mediaConstraints.audio
};
return navigator.mediaDevices.getUserMedia(constraints);
});
})
.then(function(stream) {
trace('Got access to local media with mediaConstraints:\n' +
' \'' + JSON.stringify(mediaConstraints) + '\'');

this.onUserMediaSuccess_(stream);
}.bind(this)).catch(function(error) {
this.onError_('Error getting user media: ' + error.message);
this.onUserMediaError_(error);
}.bind(this));
this.onUserMediaSuccess_(stream);
}.bind(this)).catch(function(error) {
this.onError_('Error getting user media: ' + error.message);
this.onUserMediaError_(error);
}.bind(this));
} else {
mediaPromise = Promise.resolve();
}
Expand All @@ -399,11 +400,11 @@ Call.prototype.maybeGetIceServers_ = function() {
var requestUrl = this.params_.iceServerRequestUrl;
iceServerPromise =
requestIceServers(requestUrl, this.params_.iceServerTransports).then(
function(iceServers) {
var servers = this.params_.peerConnectionConfig.iceServers;
this.params_.peerConnectionConfig.iceServers =
function(iceServers) {
var servers = this.params_.peerConnectionConfig.iceServers;
this.params_.peerConnectionConfig.iceServers =
servers.concat(iceServers);
}.bind(this)).catch(function(error) {
}.bind(this)).catch(function(error) {
if (this.onstatusmessage) {
// Error retrieving ICE servers.
var subject =
Expand Down Expand Up @@ -454,7 +455,7 @@ Call.prototype.onUserMediaError_ = function(error) {
Call.prototype.maybeReportGetUserMediaErrors_ = function() {
if (this.errorMessageQueue_.length > 0) {
for (var errorMsg = 0;
errorMsg < this.errorMessageQueue_.length; errorMsg++) {
errorMsg < this.errorMessageQueue_.length; errorMsg++) {
this.pcClient_.reportErrorToCallstats('getUserMedia',
this.errorMessageQueue_[errorMsg]);
}
Expand All @@ -471,16 +472,16 @@ Call.prototype.maybeCreatePcClientAsync_ = function() {
if (typeof RTCPeerConnection.generateCertificate === 'function') {
var certParams = {name: 'ECDSA', namedCurve: 'P-256'};
RTCPeerConnection.generateCertificate(certParams)
.then(function(cert) {
trace('ECDSA certificate generated successfully.');
this.params_.peerConnectionConfig.certificates = [cert];
this.createPcClient_();
resolve();
}.bind(this))
.catch(function(error) {
trace('ECDSA certificate generation failed.');
reject(error);
});
.then(function(cert) {
trace('ECDSA certificate generated successfully.');
this.params_.peerConnectionConfig.certificates = [cert];
this.createPcClient_();
resolve();
}.bind(this))
.catch(function(error) {
trace('ECDSA certificate generation failed.');
reject(error);
});
} else {
this.createPcClient_();
resolve();
Expand Down Expand Up @@ -510,22 +511,22 @@ Call.prototype.startSignaling_ = function() {
this.startTime = window.performance.now();

this.maybeCreatePcClientAsync_()
.then(function() {
if (this.localStream_) {
trace('Adding local stream.');
this.pcClient_.addStream(this.localStream_);
}
if (this.params_.isInitiator) {
this.pcClient_.startAsCaller(this.params_.offerOptions);
} else {
this.pcClient_.startAsCallee(this.params_.messages);
}
this.maybeReportGetUserMediaErrors_();
}.bind(this))
.catch(function(e) {
this.onError_('Create PeerConnection exception: ' + e);
alert('Cannot create RTCPeerConnection: ' + e.message);
}.bind(this));
.then(function() {
if (this.localStream_) {
trace('Adding local stream.');
this.pcClient_.addStream(this.localStream_);
}
if (this.params_.isInitiator) {
this.pcClient_.startAsCaller(this.params_.offerOptions);
} else {
this.pcClient_.startAsCallee(this.params_.messages);
}
this.maybeReportGetUserMediaErrors_();
}.bind(this))
.catch(function(e) {
this.onError_('Create PeerConnection exception: ' + e);
alert('Cannot create RTCPeerConnection: ' + e.message);
}.bind(this));
};

// Join the room and returns room parameters.
Expand Down Expand Up @@ -566,7 +567,7 @@ Call.prototype.joinRoom_ = function() {

Call.prototype.onRecvSignalingChannelMessage_ = function(msg) {
this.maybeCreatePcClientAsync_()
.then(this.pcClient_.receiveSignalingMessage(msg));
.then(this.pcClient_.receiveSignalingMessage(msg));
};

Call.prototype.sendSignalingMessage_ = function(message) {
Expand Down
2 changes: 1 addition & 1 deletion src/web_app/js/infobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ InfoBox.prototype.refreshStats_ = function() {
};

InfoBox.prototype.updateInfoDiv = function() {
var contents = '<pre id=\"info-box-stats\" style=\"line-height: initial\">';
var contents = '<pre id="info-box-stats" style="line-height: initial">';

if (this.stats_) {
var states = this.call_.getPeerConnectionStates();
Expand Down
48 changes: 24 additions & 24 deletions src/web_app/js/peerconnectionclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ PeerConnectionClient.prototype.startAsCaller = function(offerOptions) {
this.setupCallstats_();
this.started_ = true;
var constraints = mergeConstraints(
PeerConnectionClient.DEFAULT_SDP_OFFER_OPTIONS_, offerOptions);
PeerConnectionClient.DEFAULT_SDP_OFFER_OPTIONS_, offerOptions);
trace('Sending offer to peer, with constraints: \n\'' +
JSON.stringify(constraints) + '\'.');
this.pc_.createOffer(constraints)
.then(this.setLocalSdpAndNotify_.bind(this))
.catch(this.onError_.bind(this, 'createOffer'));
.then(this.setLocalSdpAndNotify_.bind(this))
.catch(this.onError_.bind(this, 'createOffer'));

return true;
};
Expand Down Expand Up @@ -192,36 +192,36 @@ PeerConnectionClient.prototype.getPeerConnectionStats = function(callback) {
return;
}
this.pc_.getStats(null)
.then(callback);
.then(callback);
};

PeerConnectionClient.prototype.doAnswer_ = function() {
trace('Sending answer to peer.');
this.pc_.createAnswer()
.then(this.setLocalSdpAndNotify_.bind(this))
.catch(this.onError_.bind(this, 'createAnswer'));
.then(this.setLocalSdpAndNotify_.bind(this))
.catch(this.onError_.bind(this, 'createAnswer'));
};

PeerConnectionClient.prototype.setLocalSdpAndNotify_ =
function(sessionDescription) {
sessionDescription.sdp = maybePreferAudioReceiveCodec(
sessionDescription.sdp,
this.params_);
sessionDescription.sdp,
this.params_);
sessionDescription.sdp = maybePreferVideoReceiveCodec(
sessionDescription.sdp,
this.params_);
sessionDescription.sdp,
this.params_);
sessionDescription.sdp = maybeSetAudioReceiveBitRate(
sessionDescription.sdp,
this.params_);
sessionDescription.sdp,
this.params_);
sessionDescription.sdp = maybeSetVideoReceiveBitRate(
sessionDescription.sdp,
this.params_);
sessionDescription.sdp,
this.params_);
sessionDescription.sdp = maybeRemoveVideoFec(
sessionDescription.sdp,
this.params_);
sessionDescription.sdp,
this.params_);
this.pc_.setLocalDescription(sessionDescription)
.then(trace.bind(null, 'Set session description success.'))
.catch(this.onError_.bind(this, 'setLocalDescription'));
.then(trace.bind(null, 'Set session description success.'))
.catch(this.onError_.bind(this, 'setLocalDescription'));

if (this.onsignalingmessage) {
// Chrome version of RTCSessionDescription can't be serialized directly
Expand All @@ -244,8 +244,8 @@ PeerConnectionClient.prototype.setRemoteSdp_ = function(message) {
message.sdp = maybeSetVideoSendInitialBitRate(message.sdp, this.params_);
message.sdp = maybeRemoveVideoFec(message.sdp, this.params_);
this.pc_.setRemoteDescription(new RTCSessionDescription(message))
.then(this.onSetRemoteDescriptionSuccess_.bind(this))
.catch(this.onError_.bind(this, 'setRemoteDescription'));
.then(this.onSetRemoteDescriptionSuccess_.bind(this))
.catch(this.onError_.bind(this, 'setRemoteDescription'));
};

PeerConnectionClient.prototype.onSetRemoteDescriptionSuccess_ = function() {
Expand Down Expand Up @@ -283,8 +283,8 @@ PeerConnectionClient.prototype.processSignalingMessage_ = function(message) {
});
this.recordIceCandidate_('Remote', candidate);
this.pc_.addIceCandidate(candidate)
.then(trace.bind(null, 'Remote candidate added successfully.'))
.catch(this.onError_.bind(this, 'addIceCandidate'));
.then(trace.bind(null, 'Remote candidate added successfully.'))
.catch(this.onError_.bind(this, 'addIceCandidate'));
} else {
trace('WARNING: unexpected message: ' + JSON.stringify(message));
}
Expand Down Expand Up @@ -449,8 +449,8 @@ PeerConnectionClient.prototype.reportErrorToCallstats =
// property/getter.
var filteredError = (funcName === 'getUserMedia' ? error.name : error);
this.callstats.reportError(this.pc_, this.conferenceId,
supportedWebrtcFuncNames[funcName], new DOMException(filteredError),
localSdp, remoteSdp);
supportedWebrtcFuncNames[funcName], new DOMException(filteredError),
localSdp, remoteSdp);
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/web_app/js/roomselection.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
'use strict';

var RoomSelection = function(roomSelectionDiv,
uiConstants, recentRoomsKey, setupCompletedCallback) {
uiConstants, recentRoomsKey, setupCompletedCallback) {
this.roomSelectionDiv_ = roomSelectionDiv;

this.setupCompletedCallback_ = setupCompletedCallback;
Expand Down
4 changes: 2 additions & 2 deletions src/web_app/js/sdputils.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ function removeCodecByName(sdpLines, codec) {
return sdpLines;
}
sdpLines[mLineIndex] = removePayloadTypeFromMline(sdpLines[mLineIndex],
payloadType);
payloadType);
return sdpLines;
}

Expand All @@ -247,7 +247,7 @@ function removeCodecByPayloadType(sdpLines, payloadType) {
return sdpLines;
}
sdpLines[mLineIndex] = removePayloadTypeFromMline(sdpLines[mLineIndex],
payloadType);
payloadType);
return sdpLines;
}

Expand Down
Loading

0 comments on commit 127baa0

Please sign in to comment.