jshint cleanups

- equality operators
- missing/excess semicolons
- trailing whitespace
This commit is contained in:
Matthew Duggan 2014-03-01 16:39:39 +09:00
parent ab23f571ab
commit 8314936a14
6 changed files with 75 additions and 76 deletions

84
app.js
View File

@ -19,7 +19,7 @@ function init() {
if (RTC === null) { if (RTC === null) {
window.location.href = 'webrtcrequired.html'; window.location.href = 'webrtcrequired.html';
return; return;
} else if (RTC.browser != 'chrome') { } else if (RTC.browser !== 'chrome') {
window.location.href = 'chromeonly.html'; window.location.href = 'chromeonly.html';
return; return;
} }
@ -44,12 +44,12 @@ function init() {
var jid = document.getElementById('jid').value || config.hosts.domain || window.location.hostname; var jid = document.getElementById('jid').value || config.hosts.domain || window.location.hostname;
connection.connect(jid, document.getElementById('password').value, function (status) { connection.connect(jid, document.getElementById('password').value, function (status) {
if (status == Strophe.Status.CONNECTED) { if (status === Strophe.Status.CONNECTED) {
console.log('connected'); console.log('connected');
if (config.useStunTurn) { if (config.useStunTurn) {
connection.jingle.getStunAndTurnCredentials(); connection.jingle.getStunAndTurnCredentials();
} }
if (RTC.browser == 'firefox') { if (RTC.browser === 'firefox') {
getUserMediaWithConstraints(['audio']); getUserMediaWithConstraints(['audio']);
} else { } else {
getUserMediaWithConstraints(['audio', 'video'], config.resolution || '360'); getUserMediaWithConstraints(['audio', 'video'], config.resolution || '360');
@ -118,7 +118,7 @@ $(document).bind('mediaready.jingle', function (event, stream) {
updateLargeVideo($(this).attr('src'), true, 0); updateLargeVideo($(this).attr('src'), true, 0);
$('video').each(function (idx, el) { $('video').each(function (idx, el) {
if (el.id.indexOf('mixedmslabel') != -1) { if (el.id.indexOf('mixedmslabel') !== -1) {
el.volume = 0; el.volume = 0;
el.volume = 1; el.volume = 1;
} }
@ -135,7 +135,7 @@ $(document).bind('mediafailure.jingle', function () {
$(document).bind('remotestreamadded.jingle', function (event, data, sid) { $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
function waitForRemoteVideo(selector, sid) { function waitForRemoteVideo(selector, sid) {
var sess = connection.jingle.sessions[sid]; var sess = connection.jingle.sessions[sid];
if (data.stream.id == 'mixedmslabel') return; if (data.stream.id === 'mixedmslabel') return;
videoTracks = data.stream.getVideoTracks(); videoTracks = data.stream.getVideoTracks();
if (videoTracks.length === 0 || selector[0].currentTime > 0) { if (videoTracks.length === 0 || selector[0].currentTime > 0) {
RTC.attachMediaStream(selector, data.stream); // FIXME: why do i have to do this for FF? RTC.attachMediaStream(selector, data.stream); // FIXME: why do i have to do this for FF?
@ -148,10 +148,10 @@ $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
var sess = connection.jingle.sessions[sid]; var sess = connection.jingle.sessions[sid];
// look up an associated JID for a stream id // look up an associated JID for a stream id
if (data.stream.id.indexOf('mixedmslabel') == -1) { if (data.stream.id.indexOf('mixedmslabel') === -1) {
var ssrclines = SDPUtil.find_lines(sess.peerconnection.remoteDescription.sdp, 'a=ssrc'); var ssrclines = SDPUtil.find_lines(sess.peerconnection.remoteDescription.sdp, 'a=ssrc');
ssrclines = ssrclines.filter(function (line) { ssrclines = ssrclines.filter(function (line) {
return line.indexOf('mslabel:' + data.stream.label) != -1; return line.indexOf('mslabel:' + data.stream.label) !== -1;
}); });
if (ssrclines.length) { if (ssrclines.length) {
thessrc = ssrclines[0].substring(7).split(' ')[0]; thessrc = ssrclines[0].substring(7).split(' ')[0];
@ -179,7 +179,7 @@ $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
//console.log('found container for', data.peerjid); //console.log('found container for', data.peerjid);
} }
} else { } else {
if (data.stream.id != 'mixedmslabel') { if (data.stream.id !== 'mixedmslabel') {
console.warn('can not associate stream', data.stream.id, 'with a participant'); console.warn('can not associate stream', data.stream.id, 'with a participant');
} }
// FIXME: for the mixed ms we dont need a video -- currently // FIXME: for the mixed ms we dont need a video -- currently
@ -195,7 +195,7 @@ $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
vid.oncontextmenu = function () { return false; }; vid.oncontextmenu = function () { return false; };
container.appendChild(vid); container.appendChild(vid);
// TODO: make mixedstream display:none via css? // TODO: make mixedstream display:none via css?
if (id.indexOf('mixedmslabel') != -1) { if (id.indexOf('mixedmslabel') !== -1) {
container.id = 'mixedstream'; container.id = 'mixedstream';
$(container).hide(); $(container).hide();
} }
@ -232,8 +232,8 @@ $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
} }
); );
// an attempt to work around https://github.com/jitsi/jitmeet/issues/32 // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
if (data.peerjid && sess.peerjid == data.peerjid && if (data.peerjid && sess.peerjid === data.peerjid &&
data.stream.getVideoTracks().length == 0 && data.stream.getVideoTracks().length === 0 &&
connection.jingle.localStream.getVideoTracks().length > 0) { connection.jingle.localStream.getVideoTracks().length > 0) {
window.setTimeout(function() { window.setTimeout(function() {
sendKeyframe(sess.peerconnection); sendKeyframe(sess.peerconnection);
@ -244,7 +244,7 @@ $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
// an attempt to work around https://github.com/jitsi/jitmeet/issues/32 // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
function sendKeyframe(pc) { function sendKeyframe(pc) {
console.log('sendkeyframe', pc.iceConnectionState); console.log('sendkeyframe', pc.iceConnectionState);
if (pc.iceConnectionState != 'connected') return; // safe... if (pc.iceConnectionState !== 'connected') return; // safe...
pc.setRemoteDescription( pc.setRemoteDescription(
pc.remoteDescription, pc.remoteDescription,
function () { function () {
@ -350,7 +350,7 @@ $(document).bind('callincoming.jingle', function (event, sid) {
}); });
$(document).bind('callactive.jingle', function (event, videoelem, sid) { $(document).bind('callactive.jingle', function (event, videoelem, sid) {
if (videoelem.attr('id').indexOf('mixedmslabel') == -1) { if (videoelem.attr('id').indexOf('mixedmslabel') === -1) {
// ignore mixedmslabela0 and v0 // ignore mixedmslabela0 and v0
videoelem.show(); videoelem.show();
resizeThumbnails(); resizeThumbnails();
@ -464,7 +464,7 @@ $(document).bind('left.muc', function (event, jid) {
$(container).hide(); $(container).hide();
resizeThumbnails(); resizeThumbnails();
} }
if (focus === null && connection.emuc.myroomjid == connection.emuc.list_members[0]) { if (focus === null && connection.emuc.myroomjid === connection.emuc.list_members[0]) {
console.log('welcome to our new focus... myself'); console.log('welcome to our new focus... myself');
focus = new ColibriFocus(connection, config.hosts.bridge); focus = new ColibriFocus(connection, config.hosts.bridge);
if (Object.keys(connection.emuc.members).length > 0) { if (Object.keys(connection.emuc.members).length > 0) {
@ -494,7 +494,7 @@ $(document).bind('presence.muc', function (event, jid, info, pres) {
ssrc2jid[ssrc.getAttribute('ssrc')] = jid; ssrc2jid[ssrc.getAttribute('ssrc')] = jid;
// might need to update the direction if participant just went from sendrecv to recvonly // might need to update the direction if participant just went from sendrecv to recvonly
if (ssrc.getAttribute('type') == 'video') { if (ssrc.getAttribute('type') === 'video') {
var el = $('#participant_' + Strophe.getResourceFromJid(jid) + '>video'); var el = $('#participant_' + Strophe.getResourceFromJid(jid) + '>video');
switch(ssrc.getAttribute('direction')) { switch(ssrc.getAttribute('direction')) {
case 'sendrecv': case 'sendrecv':
@ -532,7 +532,7 @@ $(document).bind('passwordrequired.muc', function (event, jid) {
{ {
var lockKey = document.getElementById('lockKey'); var lockKey = document.getElementById('lockKey');
if (lockKey.value != null) if (lockKey.value !== null)
{ {
setSharedKey(lockKey.value); setSharedKey(lockKey.value);
connection.emuc.doJoin(jid, lockKey.value); connection.emuc.doJoin(jid, lockKey.value);
@ -551,7 +551,7 @@ $(document).bind('presentationremoved.muc', function(event, jid, presUrl) {
setPresentationVisible(false); setPresentationVisible(false);
$('#participant_' + Strophe.getResourceFromJid(jid) + '_' + presId).remove(); $('#participant_' + Strophe.getResourceFromJid(jid) + '_' + presId).remove();
$('#presentation>iframe').remove(); $('#presentation>iframe').remove();
if (preziPlayer != null) { if (preziPlayer !== null) {
preziPlayer.destroy(); preziPlayer.destroy();
preziPlayer = null; preziPlayer = null;
} }
@ -585,8 +585,8 @@ $(document).bind('presentationadded.muc', function (event, jid, presUrl, current
else { else {
var e = event.toElement || event.relatedTarget; var e = event.toElement || event.relatedTarget;
while(e && e.parentNode && e.parentNode != window) { while(e && e.parentNode && e.parentNode !== window) {
if (e.parentNode == this || e == this) { if (e.parentNode === this || e === this) {
return false; return false;
} }
e = e.parentNode; e = e.parentNode;
@ -608,8 +608,8 @@ $(document).bind('presentationadded.muc', function (event, jid, presUrl, current
preziPlayer.on(PreziPlayer.EVENT_STATUS, function(event) { preziPlayer.on(PreziPlayer.EVENT_STATUS, function(event) {
console.log("prezi status", event.value); console.log("prezi status", event.value);
if (event.value == PreziPlayer.STATUS_CONTENT_READY) { if (event.value === PreziPlayer.STATUS_CONTENT_READY) {
if (jid != connection.emuc.myroomjid) if (jid !== connection.emuc.myroomjid)
preziPlayer.flyToStep(currentSlide); preziPlayer.flyToStep(currentSlide);
} }
}); });
@ -680,8 +680,8 @@ function setPresentationVisible(visible) {
} }
} }
var isPresentationVisible = function () { function isPresentationVisible() {
return ($('#presentation>iframe') != null && $('#presentation>iframe').css('opacity') == 1); return ($('#presentation>iframe') !== null && $('#presentation>iframe').css('opacity') == 1);
} }
/** /**
@ -692,7 +692,7 @@ function updateLargeVideo(newSrc, localVideo, vol) {
setPresentationVisible(false); setPresentationVisible(false);
if ($('#largeVideo').attr('src') != newSrc) { if ($('#largeVideo').attr('src') !== newSrc) {
document.getElementById('largeVideo').volume = vol; document.getElementById('largeVideo').volume = vol;
@ -700,10 +700,10 @@ function updateLargeVideo(newSrc, localVideo, vol) {
$(this).attr('src', newSrc); $(this).attr('src', newSrc);
var videoTransform = document.getElementById('largeVideo').style.webkitTransform; var videoTransform = document.getElementById('largeVideo').style.webkitTransform;
if (localVideo && videoTransform != 'scaleX(-1)') { if (localVideo && videoTransform !== 'scaleX(-1)') {
document.getElementById('largeVideo').style.webkitTransform = "scaleX(-1)"; document.getElementById('largeVideo').style.webkitTransform = "scaleX(-1)";
} }
else if (!localVideo && videoTransform == 'scaleX(-1)') { else if (!localVideo && videoTransform === 'scaleX(-1)') {
document.getElementById('largeVideo').style.webkitTransform = "none"; document.getElementById('largeVideo').style.webkitTransform = "none";
} }
@ -880,7 +880,7 @@ function buttonClick(id, classname) {
*/ */
function openLockDialog() { function openLockDialog() {
// Only the focus is able to set a shared key. // Only the focus is able to set a shared key.
if (focus == null) { if (focus === null) {
if (sharedKey) if (sharedKey)
$.prompt("This conversation is currently protected by a shared secret key.", $.prompt("This conversation is currently protected by a shared secret key.",
{ {
@ -1013,7 +1013,7 @@ function openPreziDialog() {
} }
}); });
} }
else if (preziPlayer != null) { else if (preziPlayer !== null) {
$.prompt("Another participant is already sharing a Prezi." + $.prompt("Another participant is already sharing a Prezi." +
"This conference allows only one Prezi at a time.", "This conference allows only one Prezi at a time.",
{ {
@ -1044,8 +1044,8 @@ function openPreziDialog() {
var urlValue var urlValue
= encodeURI(Util.escapeHtml(preziUrl.value)); = encodeURI(Util.escapeHtml(preziUrl.value));
if (urlValue.indexOf('http://prezi.com/') != 0 if (urlValue.indexOf('http://prezi.com/') !== 0
&& urlValue.indexOf('https://prezi.com/') != 0) && urlValue.indexOf('https://prezi.com/') !== 0)
{ {
$.prompt.goToState('state1'); $.prompt.goToState('state1');
return false; return false;
@ -1077,7 +1077,7 @@ function openPreziDialog() {
defaultButton: 1, defaultButton: 1,
submit:function(e,v,m,f) { submit:function(e,v,m,f) {
e.preventDefault(); e.preventDefault();
if(v==0) if (v === 0)
$.prompt.close(); $.prompt.close();
else else
$.prompt.goToState('state0'); $.prompt.goToState('state0');
@ -1127,7 +1127,7 @@ function updateLockButton() {
*/ */
function showToolbar() { function showToolbar() {
$('#toolbar').css({visibility:"visible"}); $('#toolbar').css({visibility:"visible"});
if (focus != null) if (focus !== null)
{ {
// TODO: Enable settings functionality. Need to uncomment the settings button in index.html. // TODO: Enable settings functionality. Need to uncomment the settings button in index.html.
// $('#settingsButton').css({visibility:"visible"}); // $('#settingsButton').css({visibility:"visible"});
@ -1145,7 +1145,7 @@ function updateRoomUrl(newRoomUrl) {
* Warning to the user that the conference window is about to be closed. * Warning to the user that the conference window is about to be closed.
*/ */
function closePageWarning() { function closePageWarning() {
if (focus != null) if (focus !== null)
return "You are the owner of this conference call and you are about to end it."; return "You are the owner of this conference call and you are about to end it.";
else else
return "You are about to leave this conversation."; return "You are about to leave this conversation.";
@ -1157,10 +1157,10 @@ function closePageWarning() {
* from the connection.jingle.sessions. * from the connection.jingle.sessions.
*/ */
function showFocusIndicator() { function showFocusIndicator() {
if (focus != null) { if (focus !== null) {
var indicatorSpan = $('#localVideoContainer .focusindicator'); var indicatorSpan = $('#localVideoContainer .focusindicator');
if (indicatorSpan.children().length == 0) if (indicatorSpan.children().length === 0)
{ {
createFocusIndicatorElement(indicatorSpan[0]); createFocusIndicatorElement(indicatorSpan[0]);
} }
@ -1172,7 +1172,7 @@ function showFocusIndicator() {
var focusContainer = document.getElementById(focusId); var focusContainer = document.getElementById(focusId);
var indicatorSpan = $('#' + focusId + ' .focusindicator'); var indicatorSpan = $('#' + focusId + ' .focusindicator');
if (!indicatorSpan || indicatorSpan.length == 0) { if (!indicatorSpan || indicatorSpan.length === 0) {
indicatorSpan = document.createElement('span'); indicatorSpan = document.createElement('span');
indicatorSpan.className = 'focusindicator'; indicatorSpan.className = 'focusindicator';
focusContainer.appendChild(indicatorSpan); focusContainer.appendChild(indicatorSpan);
@ -1197,7 +1197,7 @@ function addRemoteVideoContainer(id) {
function createFocusIndicatorElement(parentElement) { function createFocusIndicatorElement(parentElement) {
var focusIndicator = document.createElement('i'); var focusIndicator = document.createElement('i');
focusIndicator.className = 'fa fa-star'; focusIndicator.className = 'fa fa-star';
focusIndicator.title = "The owner of this conference" focusIndicator.title = "The owner of this conference";
parentElement.appendChild(focusIndicator); parentElement.appendChild(focusIndicator);
} }
@ -1243,8 +1243,8 @@ function showDisplayName(videoSpanId, displayName) {
if (nameSpan.length > 0) { if (nameSpan.length > 0) {
var nameSpanElement = nameSpan.get(0); var nameSpanElement = nameSpan.get(0);
if (nameSpanElement.id == 'localDisplayName' if (nameSpanElement.id === 'localDisplayName'
&& $('#localDisplayName').html() != escDisplayName) && $('#localDisplayName').html() !== escDisplayName)
$('#localDisplayName').html(escDisplayName); $('#localDisplayName').html(escDisplayName);
else else
$('#' + videoSpanId + '_name').html(escDisplayName); $('#' + videoSpanId + '_name').html(escDisplayName);
@ -1252,7 +1252,7 @@ function showDisplayName(videoSpanId, displayName) {
else { else {
var editButton = null; var editButton = null;
if (videoSpanId == 'localVideoContainer') { if (videoSpanId === 'localVideoContainer') {
editButton = createEditDisplayNameButton(); editButton = createEditDisplayNameButton();
} }
if (escDisplayName.length) { if (escDisplayName.length) {
@ -1289,7 +1289,7 @@ function showDisplayName(videoSpanId, displayName) {
$('#editDisplayName').select(); $('#editDisplayName').select();
var inputDisplayNameHandler = function(name) { var inputDisplayNameHandler = function(name) {
if (nickname != name) { if (nickname !== name) {
nickname = Util.escapeHtml(name); nickname = Util.escapeHtml(name);
window.localStorage.displayname = nickname; window.localStorage.displayname = nickname;
connection.emuc.addDisplayNameToPresence(nickname); connection.emuc.addDisplayNameToPresence(nickname);
@ -1310,7 +1310,7 @@ function showDisplayName(videoSpanId, displayName) {
}); });
$('#editDisplayName').on('keydown', function (e) { $('#editDisplayName').on('keydown', function (e) {
if (e.keyCode == 13) { if (e.keyCode === 13) {
e.preventDefault(); e.preventDefault();
inputDisplayNameHandler(this.value); inputDisplayNameHandler(this.value);
} }

10
chat.js
View File

@ -17,7 +17,7 @@ var Chat = (function (my) {
} }
$('#nickinput').keydown(function(event) { $('#nickinput').keydown(function(event) {
if (event.keyCode == 13) { if (event.keyCode === 13) {
event.preventDefault(); event.preventDefault();
var val = Util.escapeHtml(this.value); var val = Util.escapeHtml(this.value);
this.value = ''; this.value = '';
@ -36,7 +36,7 @@ var Chat = (function (my) {
}); });
$('#usermsg').keydown(function(event) { $('#usermsg').keydown(function(event) {
if (event.keyCode == 13) { if (event.keyCode === 13) {
event.preventDefault(); event.preventDefault();
var message = Util.escapeHtml(this.value); var message = Util.escapeHtml(this.value);
$('#usermsg').val('').trigger('autosize.resize'); $('#usermsg').val('').trigger('autosize.resize');
@ -64,7 +64,7 @@ var Chat = (function (my) {
my.updateChatConversation = function (from, displayName, message) { my.updateChatConversation = function (from, displayName, message) {
var divClassName = ''; var divClassName = '';
if (connection.emuc.myroomjid == from) { if (connection.emuc.myroomjid === from) {
divClassName = "localuser"; divClassName = "localuser";
} }
else { else {
@ -124,7 +124,7 @@ var Chat = (function (my) {
} }
// Request the focus in the nickname field or the chat input field. // Request the focus in the nickname field or the chat input field.
if ($('#nickname').css('visibility') == 'visible') if ($('#nickname').css('visibility') === 'visible')
$('#nickinput').focus(); $('#nickinput').focus();
else { else {
$('#usermsg').focus(); $('#usermsg').focus();
@ -171,7 +171,7 @@ var Chat = (function (my) {
$('#chatconversation').width($('#chatspace').width() - 10); $('#chatconversation').width($('#chatspace').width() - 10);
$('#chatconversation') $('#chatconversation')
.height(window.innerHeight - 50 - parseInt(usermsgHeight)); .height(window.innerHeight - 50 - parseInt(usermsgHeight));
}; }
/** /**
* Shows/hides a visual notification, indicating that a message has arrived. * Shows/hides a visual notification, indicating that a message has arrived.

View File

@ -4,8 +4,8 @@ Strophe.addConnectionPlugin('logger', {
log: [], log: [],
init: function (conn) { init: function (conn) {
this.connection = conn; this.connection = conn;
this.connection.rawInput = this.log_incoming.bind(this);; this.connection.rawInput = this.log_incoming.bind(this);
this.connection.rawOutput = this.log_outgoing.bind(this);; this.connection.rawOutput = this.log_outgoing.bind(this);
}, },
log_incoming: function (stanza) { log_incoming: function (stanza) {
this.log.push([new Date().getTime(), 'incoming', stanza]); this.log.push([new Date().getTime(), 'incoming', stanza]);

View File

@ -40,7 +40,7 @@ var Etherpad = (function (my) {
else else
largeVideo = $('#largeVideo'); largeVideo = $('#largeVideo');
if ($('#etherpad>iframe').css('visibility') == 'hidden') { if ($('#etherpad>iframe').css('visibility') === 'hidden') {
largeVideo.fadeOut(300, function () { largeVideo.fadeOut(300, function () {
if (isPresentationVisible()) if (isPresentationVisible())
largeVideo.css({opacity:'0'}); largeVideo.css({opacity:'0'});
@ -123,7 +123,7 @@ var Etherpad = (function (my) {
if (!config.etherpad_base) if (!config.etherpad_base)
return; return;
if (etherpadIFrame && etherpadIFrame.style.visibility != 'hidden') if (etherpadIFrame && etherpadIFrame.style.visibility !== 'hidden')
Etherpad.toggleEtherpad(isPresentation); Etherpad.toggleEtherpad(isPresentation);
}); });

View File

@ -64,6 +64,5 @@ function smilify(body)
body = body.replace(/(:-\0|\(shocked\))/gi, "<img src="+smiley19+ ">"); body = body.replace(/(:-\0|\(shocked\))/gi, "<img src="+smiley19+ ">");
body = body.replace(/(\(oops\))/gi, "<img src="+smiley20+ ">"); body = body.replace(/(\(oops\))/gi, "<img src="+smiley20+ ">");
return body return body;
}; }