From 71229bdba9206549a18e61d4927aa0f7601d439f Mon Sep 17 00:00:00 2001 From: Boris Grozev Date: Tue, 28 Jul 2015 12:49:58 -0500 Subject: [PATCH] Minor formatting fixes. --- modules/URLProcessor/URLProcessor.js | 1 + modules/statistics/LocalStatsCollector.js | 20 ++++++-------- modules/statistics/RTPStatsCollector.js | 31 +++++++--------------- modules/statistics/statistics.js | 32 +++++++++-------------- modules/translation/translation.js | 5 ++-- modules/xmpp/moderator.js | 12 ++++----- modules/xmpp/recording.js | 20 +++++++------- modules/xmpp/strophe.emuc.js | 25 +++++++----------- modules/xmpp/strophe.jingle.js | 8 +++--- 9 files changed, 61 insertions(+), 93 deletions(-) diff --git a/modules/URLProcessor/URLProcessor.js b/modules/URLProcessor/URLProcessor.js index 478354cde..38819ba4c 100644 --- a/modules/URLProcessor/URLProcessor.js +++ b/modules/URLProcessor/URLProcessor.js @@ -1,3 +1,4 @@ +/* global $, $iq, config */ var params = {}; function getConfigParamsFromUrl() { if(!location.hash) diff --git a/modules/statistics/LocalStatsCollector.js b/modules/statistics/LocalStatsCollector.js index 04cf6db39..b4a762856 100644 --- a/modules/statistics/LocalStatsCollector.js +++ b/modules/statistics/LocalStatsCollector.js @@ -1,3 +1,4 @@ +/* global config */ /** * Provides statistics for the local stream. */ @@ -33,7 +34,7 @@ function timeDomainDataToAudioLevel(samples) { } return parseFloat(((maxVolume - 127) / 128).toFixed(3)); -}; +} /** * Animates audio level change @@ -41,20 +42,16 @@ function timeDomainDataToAudioLevel(samples) { * @param lastLevel the last audio level * @returns {Number} the audio level to be set */ -function animateLevel(newLevel, lastLevel) -{ +function animateLevel(newLevel, lastLevel) { var value = 0; var diff = lastLevel - newLevel; - if(diff > 0.2) - { + if(diff > 0.2) { value = lastLevel - 0.2; } - else if(diff < -0.4) - { + else if(diff < -0.4) { value = lastLevel + 0.4; } - else - { + else { value = newLevel; } @@ -85,8 +82,8 @@ function LocalStatsCollector(stream, interval, statisticsService, eventEmitter) * Starts the collecting the statistics. */ LocalStatsCollector.prototype.start = function () { - if (config.disableAudioLevels || !window.AudioContext - || RTCBrowserType.isTemasysPluginUsed()) + if (config.disableAudioLevels || !window.AudioContext || + RTCBrowserType.isTemasysPluginUsed()) return; var context = new AudioContext(); @@ -116,7 +113,6 @@ LocalStatsCollector.prototype.start = function () { }, this.intervalMilis ); - }; /** diff --git a/modules/statistics/RTPStatsCollector.js b/modules/statistics/RTPStatsCollector.js index 556d7d2d0..e2b7988a5 100644 --- a/modules/statistics/RTPStatsCollector.js +++ b/modules/statistics/RTPStatsCollector.js @@ -49,8 +49,6 @@ PeerStats.bandwidth = {}; */ PeerStats.bitrate = {}; - - /** * The packet loss rate * @type {{}} @@ -235,7 +233,7 @@ StatsCollector.prototype.errorCallback = function (error) StatsCollector.prototype.start = function () { var self = this; - if(!config.disableAudioLevels) { + if (!config.disableAudioLevels) { this.audioLevelsIntervalId = setInterval( function () { // Interval updates @@ -675,41 +673,34 @@ StatsCollector.prototype.processStatsReport = function () { /** * Stats processing logic. */ -StatsCollector.prototype.processAudioLevelReport = function () -{ - if (!this.baselineAudioLevelsReport) - { +StatsCollector.prototype.processAudioLevelReport = function () { + if (!this.baselineAudioLevelsReport) { return; } - for (var idx in this.currentAudioLevelsReport) - { + for (var idx in this.currentAudioLevelsReport) { var now = this.currentAudioLevelsReport[idx]; - if (now.type != 'ssrc') - { + if (now.type != 'ssrc') { continue; } var before = this.baselineAudioLevelsReport[idx]; - if (!before) - { + if (!before) { console.warn(getStatValue(now, 'ssrc') + ' not enough data'); continue; } var ssrc = getStatValue(now, 'ssrc'); var jid = APP.xmpp.getJidFromSSRC(ssrc); - if (!jid) - { + if (!jid) { if((Date.now() - now.timestamp) < 3000) console.warn("No jid for ssrc: " + ssrc); continue; } var jidStats = this.jid2stats[jid]; - if (!jidStats) - { + if (!jidStats) { jidStats = new PeerStats(); this.jid2stats[jid] = jidStats; } @@ -728,8 +719,7 @@ StatsCollector.prototype.processAudioLevelReport = function () return; } - if (audioLevel) - { + if (audioLevel) { // TODO: can't find specs about what this value really is, // but it seems to vary between 0 and around 32k. audioLevel = audioLevel / 32767; @@ -737,8 +727,5 @@ StatsCollector.prototype.processAudioLevelReport = function () if(jid != APP.xmpp.myJid()) this.eventEmitter.emit("statistics.audioLevel", jid, audioLevel); } - } - - }; diff --git a/modules/statistics/statistics.js b/modules/statistics/statistics.js index d7944a5a6..2952616de 100644 --- a/modules/statistics/statistics.js +++ b/modules/statistics/statistics.js @@ -1,3 +1,4 @@ +/* global require, APP */ /** * Created by hristo on 8/4/14. */ @@ -15,19 +16,15 @@ var localStats = null; var rtpStats = null; -function stopLocal() -{ - if(localStats) - { +function stopLocal() { + if (localStats) { localStats.stop(); localStats = null; } } -function stopRemote() -{ - if(rtpStats) - { +function stopRemote() { + if (rtpStats) { rtpStats.stop(); eventEmitter.emit("statistics.stop"); rtpStats = null; @@ -35,20 +32,18 @@ function stopRemote() } function startRemoteStats (peerconnection) { - if(rtpStats) - { + if (rtpStats) { rtpStats.stop(); - rtpStats = null; } rtpStats = new RTPStats(peerconnection, 200, 2000, eventEmitter); rtpStats.start(); } -function onStreamCreated(stream) -{ - if(stream.getOriginalStream().getAudioTracks().length === 0) +function onStreamCreated(stream) { + if(stream.getOriginalStream().getAudioTracks().length === 0) { return; + } localStats = new LocalStats(stream.getOriginalStream(), 200, statistics, eventEmitter); @@ -64,9 +59,7 @@ function onDisposeConference(onUnload) { } } - -var statistics = -{ +var statistics = { /** * Indicates that this audio level is for local jid. * @type {string} @@ -129,18 +122,17 @@ var statistics = }); APP.xmpp.addListener(XMPPEvents.PEERCONNECTION_READY, function (session) { CallStats.init(session); - }) + }); APP.RTC.addListener(RTCEvents.AUDIO_MUTE, function (mute) { CallStats.sendMuteEvent(mute, "audio"); }); APP.xmpp.addListener(XMPPEvents.CONFERENCE_SETUP_FAILED, function () { CallStats.sendSetupFailedEvent(); - }) + }); APP.RTC.addListener(RTCEvents.VIDEO_MUTE, function (mute) { CallStats.sendMuteEvent(mute, "video"); }); } - }; diff --git a/modules/translation/translation.js b/modules/translation/translation.js index a1bafc38d..29691aecc 100644 --- a/modules/translation/translation.js +++ b/modules/translation/translation.js @@ -1,3 +1,4 @@ +/* global $, require, config, interfaceConfig */ var i18n = require("i18next-client"); var languages = require("../../service/translation/languages"); var Settings = require("../settings/Settings"); @@ -23,7 +24,6 @@ var defaultOptions = { fallbackOnNull: true, fallbackOnEmpty: true, useDataAttrOptions: true, - defaultValueFromContent: false, app: interfaceConfig.APP_NAME, getAsync: false, defaultValueFromContent: false, @@ -63,8 +63,7 @@ var defaultOptions = { // localStorageExpirationTime: 86400000 // in ms, default 1 week }; -function initCompleted(t) -{ +function initCompleted(t) { $("[data-i18n]").i18n(); } diff --git a/modules/xmpp/moderator.js b/modules/xmpp/moderator.js index 2d38298c5..931d40c53 100644 --- a/modules/xmpp/moderator.js +++ b/modules/xmpp/moderator.js @@ -1,4 +1,4 @@ -/* global $, $iq, APP, config, connection, messageHandler, +/* global $, $iq, APP, config, messageHandler, roomName, sessionTerminated, Strophe, Util */ var XMPPEvents = require("../../service/xmpp/XMPPEvents"); var Settings = require("../settings/Settings"); @@ -69,8 +69,8 @@ var Moderator = { function listener(event) { if (event.data && event.data.sessionId) { if (event.origin !== window.location.origin) { - console.warn( - "Ignoring sessionId from different origin: " + event.origin); + console.warn("Ignoring sessionId from different origin: " + + event.origin); return; } localStorage.setItem('sessionId', event.data.sessionId); @@ -219,8 +219,7 @@ var Moderator = { console.info("Authentication enabled: " + authenticationEnabled); - externalAuthEnabled - = $(resultIq).find( + externalAuthEnabled = $(resultIq).find( '>conference>property' + '[name=\'externalAuth\'][value=\'true\']').length > 0; @@ -333,7 +332,8 @@ var Moderator = { // Do not show in case of session invalid // which means just a retry if (!invalidSession) { - eventEmitter.emit(XMPPEvents.FOCUS_DISCONNECTED, focusComponent, retrySec); + eventEmitter.emit(XMPPEvents.FOCUS_DISCONNECTED, + focusComponent, retrySec); } // Reset response timeout getNextTimeout(true); diff --git a/modules/xmpp/recording.js b/modules/xmpp/recording.js index 250ef6def..a542e59c3 100644 --- a/modules/xmpp/recording.js +++ b/modules/xmpp/recording.js @@ -1,4 +1,4 @@ -/* global $, $iq, config, connection, focusMucJid, messageHandler, Moderator, +/* global $, $iq, config, connection, focusMucJid, messageHandler, Toolbar, Util */ var Moderator = require("./moderator"); @@ -23,14 +23,6 @@ function setRecordingToken(token) { recordingToken = token; } -function setRecording(state, token, callback, connection) { - if (useJirecon){ - setRecordingJirecon(state, token, callback, connection); - } else { - setRecordingColibri(state, token, callback, connection); - } -} - function setRecordingJirecon(state, token, callback, connection) { if (state == recordingEnabled){ return; @@ -93,6 +85,14 @@ function setRecordingColibri(state, token, callback, connection) { ); } +function setRecording(state, token, callback, connection) { + if (useJirecon){ + setRecordingJirecon(state, token, callback, connection); + } else { + setRecordingColibri(state, token, callback, connection); + } +} + var Recording = { toggleRecording: function (tokenEmptyCallback, startingCallback, startedCallback, connection) { @@ -150,6 +150,6 @@ var Recording = { ); } -} +}; module.exports = Recording; \ No newline at end of file diff --git a/modules/xmpp/strophe.emuc.js b/modules/xmpp/strophe.emuc.js index db77adae2..8c70051ce 100644 --- a/modules/xmpp/strophe.emuc.js +++ b/modules/xmpp/strophe.emuc.js @@ -5,8 +5,6 @@ var XMPPEvents = require("../../service/xmpp/XMPPEvents"); var Moderator = require("./moderator"); -var bridgeIsDown = false; - module.exports = function(XMPP, eventEmitter) { Strophe.addConnectionPlugin('emuc', { connection: null, @@ -20,18 +18,17 @@ module.exports = function(XMPP, eventEmitter) { isOwner: false, role: null, focusMucJid: null, + bridgeIsDown: false, init: function (conn) { this.connection = conn; }, initPresenceMap: function (myroomjid) { this.presMap['to'] = myroomjid; this.presMap['xns'] = 'http://jabber.org/protocol/muc'; - if (APP.RTC.localAudio && APP.RTC.localAudio.isMuted()) - { + if (APP.RTC.localAudio && APP.RTC.localAudio.isMuted()) { this.addAudioInfoToPresence(true); } - if (APP.RTC.localVideo && APP.RTC.localVideo.isMuted()) - { + if (APP.RTC.localVideo && APP.RTC.localVideo.isMuted()) { this.addVideoInfoToPresence(true); } }, @@ -591,27 +588,25 @@ module.exports = function(XMPP, eventEmitter) { Moderator.onMucMemberLeft(jid); }, - parsePresence: function (from, memeber, pres) { - if($(pres).find(">bridgeIsDown").length > 0 && !bridgeIsDown) { - bridgeIsDown = true; + parsePresence: function (from, member, pres) { + if($(pres).find(">bridgeIsDown").length > 0 && !this.bridgeIsDown) { + this.bridgeIsDown = true; eventEmitter.emit(XMPPEvents.BRIDGE_DOWN); } - if(memeber.isFocus) + if(member.isFocus) return; var displayName = !config.displayJids - ? memeber.displayName : Strophe.getResourceFromJid(from); + ? member.displayName : Strophe.getResourceFromJid(from); - if (displayName && displayName.length > 0) - { + if (displayName && displayName.length > 0) { eventEmitter.emit(XMPPEvents.DISPLAY_NAME_CHANGED, from, displayName); } - var id = $(pres).find('>userID').text(); var email = $(pres).find('>email'); - if(email.length > 0) { + if (email.length > 0) { id = email.text(); } diff --git a/modules/xmpp/strophe.jingle.js b/modules/xmpp/strophe.jingle.js index 7a8455537..4cf3fb042 100644 --- a/modules/xmpp/strophe.jingle.js +++ b/modules/xmpp/strophe.jingle.js @@ -5,8 +5,7 @@ var XMPPEvents = require("../../service/xmpp/XMPPEvents"); var RTCBrowserType = require("../RTC/RTCBrowserType"); -module.exports = function(XMPP, eventEmitter) -{ +module.exports = function(XMPP, eventEmitter) { function CallIncomingJingle(sid, connection) { var sess = connection.jingle.sessions[sid]; @@ -21,7 +20,7 @@ module.exports = function(XMPP, eventEmitter) sess.sendAnswer(); sess.accept(); - }; + } Strophe.addConnectionPlugin('jingle', { connection: null, @@ -115,8 +114,7 @@ module.exports = function(XMPP, eventEmitter) switch (action) { case 'session-initiate': var startMuted = $(iq).find('jingle>startmuted'); - if (startMuted && startMuted.length > 0) - { + if (startMuted && startMuted.length > 0) { var audioMuted = startMuted.attr("audio"); var videoMuted = startMuted.attr("video"); eventEmitter.emit(XMPPEvents.START_MUTED_FROM_FOCUS,