diff --git a/external_api.js b/external_api.js index 866f4d33d..d49d31a60 100644 --- a/external_api.js +++ b/external_api.js @@ -25,16 +25,15 @@ var JitsiMeetExternalAPI = (function() * @param parent_node the node that will contain the iframe * @constructor */ - function JitsiMeetExternalAPI(domain, room_name, width, height, parent_node) - { + function JitsiMeetExternalAPI(domain, room_name, width, height, parentNode) { if(!width || width < MIN_WIDTH) width = MIN_WIDTH; if(!height || height < MIN_HEIGHT) height = MIN_HEIGHT; this.parentNode = null; - if(parent_node) { - this.parentNode = parent_node; + if (parentNode) { + this.parentNode = parentNode; } else { var scriptTag = document.scripts[document.scripts.length - 1]; this.parentNode = scriptTag.parentNode; @@ -78,15 +77,12 @@ var JitsiMeetExternalAPI = (function() * Sends the passed object to Jitsi Meet * @param object the object to be sent */ - JitsiMeetExternalAPI.prototype.sendMessage = function(object) - { - if(this.frameLoaded) - { + JitsiMeetExternalAPI.prototype.sendMessage = function(object) { + if (this.frameLoaded) { this.frame.contentWindow.postMessage( JSON.stringify(object), this.frame.src); } - else - { + else { this.initialCommands.push(object); } @@ -105,10 +101,9 @@ var JitsiMeetExternalAPI = (function() * @param arguments array of arguments */ JitsiMeetExternalAPI.prototype.executeCommand = function(name, - argumentsList) - { + argumentsList) { var argumentsArray = argumentsList; - if(!argumentsArray) + if (!argumentsArray) argumentsArray = []; var object = {type: "command", action: "execute"}; object[name] = argumentsArray; @@ -133,8 +128,8 @@ var JitsiMeetExternalAPI = (function() }; /** - * Adds event listeners to Meet Jitsi. The object key should be the name of the - * event and value - the listener. + * Adds event listeners to Meet Jitsi. The object key should be the name of + * the event and value - the listener. * Currently we support the following * events: * incomingMessage - receives event notifications about incoming @@ -168,8 +163,7 @@ var JitsiMeetExternalAPI = (function() * @param object */ JitsiMeetExternalAPI.prototype.addEventListeners - = function (object) - { + = function (object) { var message = {type: "event", action: "add", events: []}; for(var i in object) @@ -215,8 +209,7 @@ var JitsiMeetExternalAPI = (function() * @param listener the listener */ JitsiMeetExternalAPI.prototype.addEventListener - = function (event, listener) - { + = function (event, listener) { var message = {type: "event", action: "add", events: [event]}; this.eventHandlers[event] = listener; @@ -228,8 +221,7 @@ var JitsiMeetExternalAPI = (function() * @param event the name of the event. */ JitsiMeetExternalAPI.prototype.removeEventListener - = function (event) - { + = function (event) { if(!this.eventHandlers[event]) { console.error("The event " + event + " is not registered."); @@ -245,8 +237,7 @@ var JitsiMeetExternalAPI = (function() * @param events array with the names of the events. */ JitsiMeetExternalAPI.prototype.removeEventListeners - = function (events) - { + = function (events) { var eventsArray = []; for(var i = 0; i < events.length; i++) { @@ -272,8 +263,7 @@ var JitsiMeetExternalAPI = (function() * Processes message events sent from Jitsi Meet * @param event the event */ - JitsiMeetExternalAPI.prototype.processMessage = function(event) - { + JitsiMeetExternalAPI.prototype.processMessage = function(event) { var message; try { message = JSON.parse(event.data); @@ -283,18 +273,15 @@ var JitsiMeetExternalAPI = (function() console.error("Message without type is received."); return; } - switch (message.type) - { + switch (message.type) { case "system": - if(message.loaded) - { + if(message.loaded) { this.onFrameLoaded(); } break; case "event": if(message.action != "result" || - !message.event || !this.eventHandlers[message.event]) - { + !message.event || !this.eventHandlers[message.event]) { console.warn("The received event cannot be parsed."); return; } @@ -304,8 +291,6 @@ var JitsiMeetExternalAPI = (function() console.error("Unknown message type."); return; } - - }; /** @@ -314,8 +299,7 @@ var JitsiMeetExternalAPI = (function() */ JitsiMeetExternalAPI.prototype.onFrameLoaded = function () { this.frameLoaded = true; - for (var i = 0; i < this.initialCommands.length; i++) - { + for (var i = 0; i < this.initialCommands.length; i++) { this.sendMessage(this.initialCommands[i]); } this.initialCommands = null; @@ -329,13 +313,11 @@ var JitsiMeetExternalAPI = (function() this.eventListener = function (event) { self.processMessage(event); }; - if (window.addEventListener) - { + if (window.addEventListener) { window.addEventListener('message', this.eventListener, false); } - else - { + else { window.attachEvent('onmessage', this.eventListener); } }; @@ -344,13 +326,11 @@ var JitsiMeetExternalAPI = (function() * Removes the listeners and removes the Jitsi Meet frame. */ JitsiMeetExternalAPI.prototype.dispose = function () { - if (window.removeEventListener) - { + if (window.removeEventListener) { window.removeEventListener('message', this.eventListener, false); } - else - { + else { window.detachEvent('onmessage', this.eventListener); } diff --git a/modules/API/API.js b/modules/API/API.js index 21d728c30..3bc3c1fa9 100644 --- a/modules/API/API.js +++ b/modules/API/API.js @@ -1,3 +1,4 @@ +/* global APP */ /** * Implements API class that communicates with external api class * and provides interface to access Jitsi Meet features by external @@ -12,14 +13,15 @@ var XMPPEvents = require("../../service/xmpp/XMPPEvents"); * displayName: inputDisplayNameHandler, * muteAudio: toggleAudio, * muteVideo: toggleVideo, - * filmStrip: toggleFilmStrip + * toggleFilmStrip: toggleFilmStrip, + * toggleChat: toggleChat, + * toggleContactList: toggleContactList * }} */ var commands = {}; function initCommands() { - commands = - { + commands = { displayName: APP.UI.inputDisplayNameHandler, muteAudio: APP.UI.toggleAudio, muteVideo: APP.UI.toggleVideo, @@ -41,8 +43,7 @@ function initCommands() { * participantLeft: boolean * }} */ -var events = -{ +var events = { incomingMessage: false, outgoingMessage:false, displayNameChange: false, @@ -53,18 +54,15 @@ var events = var displayName = {}; /** - * Processes commands from external applicaiton. + * Processes commands from external application. * @param message the object with the command */ -function processCommand(message) -{ - if(message.action != "execute") - { +function processCommand(message) { + if (message.action != "execute") { console.error("Unknown action of the message"); return; } - for(var key in message) - { + for (var key in message) { if(commands[key]) commands[key].apply(null, message[key]); } @@ -75,31 +73,26 @@ function processCommand(message) * @param event the event */ function processEvent(event) { - if(!event.action) - { + if (!event.action) { console.error("Event with no action is received."); return; } var i = 0; - switch(event.action) - { + switch(event.action) { case "add": - for(; i < event.events.length; i++) - { + for (; i < event.events.length; i++) { events[event.events[i]] = true; } break; case "remove": - for(; i < event.events.length; i++) - { + for (; i < event.events.length; i++) { events[event.events[i]] = false; } break; default: console.error("Unknown action for event."); } - } /** @@ -114,8 +107,7 @@ function sendMessage(object) { * Processes a message event from the external application * @param event the message event */ -function processMessage(event) -{ +function processMessage(event) { var message; try { message = JSON.parse(event.data); @@ -123,8 +115,7 @@ function processMessage(event) if(!message.type) return; - switch (message.type) - { + switch (message.type) { case "command": processCommand(message); break; @@ -135,7 +126,6 @@ function processMessage(event) console.error("Unknown type of the message"); return; } - } function setupListeners() { @@ -151,7 +141,7 @@ function setupListeners() { API.triggerEvent("participantLeft", {jid: jid}); }); APP.xmpp.addListener(XMPPEvents.DISPLAY_NAME_CHANGED, function (jid, newDisplayName) { - name = displayName[jid]; + var name = displayName[jid]; if(!name || name != newDisplayName) { API.triggerEvent("displayNameChange", {jid: jid, displayname: newDisplayName}); displayName[jid] = newDisplayName; @@ -169,7 +159,7 @@ var API = { */ isEnabled: function () { var hash = location.hash; - if(hash && hash.indexOf("external") > -1 && window.postMessage) + if (hash && hash.indexOf("external") > -1 && window.postMessage) return true; return false; }, @@ -181,13 +171,11 @@ var API = { */ init: function () { initCommands(); - if (window.addEventListener) - { + if (window.addEventListener) { window.addEventListener('message', processMessage, false); } - else - { + else { window.attachEvent('onmessage', processMessage); } sendMessage({type: "system", loaded: true}); @@ -218,19 +206,14 @@ var API = { * Removes the listeners. */ dispose: function () { - if(window.removeEventListener) - { + if(window.removeEventListener) { window.removeEventListener("message", processMessage, false); } - else - { + else { window.detachEvent('onmessage', processMessage); } - } - - }; module.exports = API; \ No newline at end of file diff --git a/modules/UI/UI.js b/modules/UI/UI.js index fe0b138c8..c5767fd96 100644 --- a/modules/UI/UI.js +++ b/modules/UI/UI.js @@ -786,10 +786,13 @@ UI.getRoomName = function () { }; UI.setInitialMuteFromFocus = function (muteAudio, muteVideo) { - if(muteAudio || muteVideo) notifyForInitialMute(); - if(muteAudio) UI.setAudioMuted(true); - if(muteVideo) UI.setVideoMute(true); -} + if (muteAudio || muteVideo) + notifyForInitialMute(); + if (muteAudio) + UI.setAudioMuted(true); + if (muteVideo) + UI.setVideoMute(true); +}; /** * Mutes/unmutes the local video. diff --git a/modules/connectionquality/connectionquality.js b/modules/connectionquality/connectionquality.js index 1d99d3f38..960649eae 100644 --- a/modules/connectionquality/connectionquality.js +++ b/modules/connectionquality/connectionquality.js @@ -1,3 +1,4 @@ +/* global APP, require */ var EventEmitter = require("events"); var eventEmitter = new EventEmitter(); var CQEvents = require("../../service/connectionquality/CQEvents"); @@ -53,7 +54,7 @@ function convertToMUCStats(stats) { } /** - * Converts statitistics to format used by VideoLayout + * Converts statistics to format used by VideoLayout * @param stats * @returns {{bitrate: {download: *, upload: *}, packetLoss: {total: *, download: *, upload: *}}} */ @@ -71,7 +72,6 @@ function parseMUCStats(stats) { }; } - var ConnectionQuality = { init: function () { APP.xmpp.addListener(XMPPEvents.REMOTE_STATS, this.updateRemoteStats); diff --git a/modules/keyboardshortcut/keyboardshortcut.js b/modules/keyboardshortcut/keyboardshortcut.js index b423921cd..513893f90 100644 --- a/modules/keyboardshortcut/keyboardshortcut.js +++ b/modules/keyboardshortcut/keyboardshortcut.js @@ -1,3 +1,4 @@ +/* global APP, $ */ //maps keycode to character, id of popover for given function and function var shortcuts = {}; function initShortcutHandlers() { diff --git a/modules/members/MemberList.js b/modules/members/MemberList.js index 73cdab538..95bb0d29c 100644 --- a/modules/members/MemberList.js +++ b/modules/members/MemberList.js @@ -1,4 +1,4 @@ -/* global APP */ +/* global APP, require, $ */ /** * This module is meant to (eventually) contain and manage all information @@ -87,7 +87,7 @@ function updateDtmf(jid, newValue) { * Checks each member's 'supportsDtmf' field and updates * 'atLastOneSupportsDtmf'. */ -function updateAtLeastOneDtmf(){ +function updateAtLeastOneDtmf() { var newAtLeastOneDtmf = false; for (var key in members) { if (typeof members[key].supportsDtmf !== 'undefined' @@ -108,11 +108,10 @@ function updateAtLeastOneDtmf(){ * Exported interface. */ var Members = { - start: function(){ + start: function() { registerListeners(); }, - addListener: function(type, listener) - { + addListener: function(type, listener) { eventEmitter.on(type, listener); }, removeListener: function (type, listener) { diff --git a/modules/settings/Settings.js b/modules/settings/Settings.js index 520411fba..4dd05d543 100644 --- a/modules/settings/Settings.js +++ b/modules/settings/Settings.js @@ -35,15 +35,13 @@ if (supportsLocalStorage()) { userId = generateUniqueId(); } -var Settings = -{ +var Settings = { setDisplayName: function (newDisplayName) { displayName = newDisplayName; window.localStorage.displayname = displayName; return displayName; }, - setEmail: function (newEmail) - { + setEmail: function (newEmail) { email = newEmail; window.localStorage.email = newEmail; return email; diff --git a/modules/statistics/CallStats.js b/modules/statistics/CallStats.js index 7692c2345..b80ab3e0c 100644 --- a/modules/statistics/CallStats.js +++ b/modules/statistics/CallStats.js @@ -1,3 +1,4 @@ +/* global config, $, APP, Strophe, callstats */ var callStats = null; function initCallback (err, msg) { @@ -38,37 +39,37 @@ var CallStats = { this.pcCallback.bind(this)); }, pcCallback: function (err, msg) { - if(!callStats) + if (!callStats) return; console.log("Monitoring status: "+ err + " msg: " + msg); callStats.sendFabricEvent(this.peerconnection, callStats.fabricEvent.fabricSetup, this.confID); }, sendMuteEvent: function (mute, type) { - if(!callStats) + if (!callStats) return; var event = null; - if(type === "video") - { + if (type === "video") { event = (mute? callStats.fabricEvent.videoPause : callStats.fabricEvent.videoResume); } - else - { + else { event = (mute? callStats.fabricEvent.audioMute : callStats.fabricEvent.audioUnmute); } callStats.sendFabricEvent(this.peerconnection, event, this.confID); }, sendTerminateEvent: function () { - if(!callStats) + if(!callStats) { return; + } callStats.sendFabricEvent(this.peerconnection, callStats.fabricEvent.fabricTerminated, this.confID); }, sendSetupFailedEvent: function () { - if(!callStats) + if(!callStats) { return; + } callStats.sendFabricEvent(this.peerconnection, callStats.fabricEvent.fabricSetupFailed, this.confID); }