From 67a56cc18960deba4c7f01b6c4bbc6f8029d1562 Mon Sep 17 00:00:00 2001 From: Jan Vincent Liwanag Date: Sun, 7 Sep 2014 23:23:23 +0800 Subject: [PATCH] Fix jshint errors * Put globals in .jshintrc * Remove indent, whitespace rules (Deprecated in jshint 2.5. Will be added later using JSCS) * Add explicit jshint settings: laxbreak, strict, quotmark, unsued. Should be reversed later. --- .jshintrc | 60 ++++++++++++++++++++++++++++++++++++++++--- analytics.js | 4 ++- audio_levels.js | 8 +++--- brand.js | 2 +- chat.js | 5 ++-- commands.js | 14 +++++----- contact_list.js | 8 +++--- data_channels.js | 4 +-- etherpad.js | 1 - local_sts.js | 6 ++--- roomname_generator.js | 6 ++--- toolbar.js | 10 ++++---- toolbar_toggler.js | 2 +- util.js | 2 +- videolayout.js | 28 ++++++++++---------- 15 files changed, 107 insertions(+), 53 deletions(-) diff --git a/.jshintrc b/.jshintrc index 006e4c0c3..8f618f19d 100644 --- a/.jshintrc +++ b/.jshintrc @@ -4,12 +4,66 @@ "loopfunc": true, "curly": false, "evil": true, - "white": true, "undef": true, "browser": true, "node": true, "trailing": true, - "indent": 4, "latedef": true, - "newcap": true + "newcap": true, + "globals": { + // Predefs + "$": false, + "$iq": false, + "Prezi": false, + + // Global Objects + "AudioLevels": true, + "CanvasUtil": true, + "Chat": true, + "CommandsProcessor": true, + "ContactList": true, + "RTC": true, + "Strophe": true, + "ToolbarToggler": true, + "Util": true, + "VideoLayout": true, + + // Global Vars + "bindDataChannelListener": true, + "buttonClick": true, + "config": true, + "connection": true, + "currentVideoHeight": true, + "currentVideoWidth": true, + "flipXLocalVideo": true, + "focusedVideoSrc": true, + "getCameraVideoPosition": true, + "getCameraVideoSize": true, + "getDesktopVideoPosition": true, + "getJidFromVideoSrc": true, + "getVideoPosition": true, + "getVideoSize": true, + "isVideoSrcDesktop": true, + "linkify": true, + "localVideoSrc": true, + "lockRoom": true, + "mediaStreams": true, + "mutedAudios": true, + "nickname": true, + "processReplacements": true, + "roomUrl": true, + "setSharedKey": true, + "sharedKey": true, + "showDesktopSharingButton": true, + "toggleAudio": true, + "videoSpan": true, + "videoSrcToSsrc": true, + "waitForRemoteVideo": true + }, + + // Reverse these later + "laxbreak": true, + "strict": false, + "quotmark": false, + "unused": false } diff --git a/analytics.js b/analytics.js index 07ea7184f..3ff689191 100644 --- a/analytics.js +++ b/analytics.js @@ -1,3 +1,4 @@ +/* jshint ignore:start */ /** * Google Analytics */ @@ -5,4 +6,5 @@ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-319188-14', 'jit.si'); - ga('send', 'pageview'); \ No newline at end of file + ga('send', 'pageview'); +/* jshint ignore:end */ \ No newline at end of file diff --git a/audio_levels.js b/audio_levels.js index 3a94fff22..59b97ed3e 100644 --- a/audio_levels.js +++ b/audio_levels.js @@ -97,7 +97,7 @@ var AudioLevels = (function(my) { thumbnailHeight) { audioLevelCanvas.width = thumbnailWidth + CANVAS_EXTRA; audioLevelCanvas.height = thumbnailHeight + CANVAS_EXTRA; - }; + } /** * Draws the audio level canvas into the cached canvas object. @@ -146,7 +146,7 @@ var AudioLevels = (function(my) { CANVAS_RADIUS, SHADOW_COLOR, shadowLevel); - }; + } /** * Returns the shadow/glow level for the given audio level. @@ -167,7 +167,7 @@ var AudioLevels = (function(my) { shadowLevel = Math.round(CANVAS_EXTRA/2*((audioLevel - 0.6) / 0.4)); } return shadowLevel; - }; + } /** * Returns the video span id corresponding to the given resourceJid or local @@ -183,7 +183,7 @@ var AudioLevels = (function(my) { videoSpanId = 'participant_' + resourceJid; return videoSpanId; - }; + } /** * Indicates that the remote video has been resized. diff --git a/brand.js b/brand.js index 7a81a7e41..f0caca42a 100644 --- a/brand.js +++ b/brand.js @@ -1,4 +1,4 @@ var brand = { appName: "Jitsi Meet" -} +}; diff --git a/chat.js b/chat.js index 8b6e7abd0..1492817d6 100644 --- a/chat.js +++ b/chat.js @@ -1,4 +1,3 @@ -/* global $, Util, connection, nickname:true, getVideoSize, getVideoPosition, showToolbar, processReplacements */ /** * Chat related user interface. */ @@ -126,7 +125,7 @@ var Chat = (function (my) { if(subject) subject = subject.trim(); $('#subject').html(linkify(Util.escapeHtml(subject))); - if(subject == "") + if(subject === "") { $("#subject").css({display: "none"}); } @@ -204,7 +203,7 @@ var Chat = (function (my) { duration: 500}); } else { - // Undock the toolbar when the chat is shown and if we're in a + // Undock the toolbar when the chat is shown and if we're in a // video mode. if (VideoLayout.isLargeVideoVisible()) ToolbarToggler.dockToolbar(false); diff --git a/commands.js b/commands.js index 110e8cf1c..8de41b4fd 100644 --- a/commands.js +++ b/commands.js @@ -21,12 +21,12 @@ var CommandsProcessor = (function() { for(var command in commands) { - if(message.indexOf("/" + command) == 0) + if(message.indexOf("/" + command) === 0) return command; } } return ""; - }; + } var command = getCommand(message); @@ -37,7 +37,7 @@ var CommandsProcessor = (function() this.getCommand = function() { return command; - } + }; var messageArgument = message.substr(command.length + 2); @@ -49,7 +49,7 @@ var CommandsProcessor = (function() this.getArgument = function() { return messageArgument; - } + }; } /** @@ -61,7 +61,7 @@ var CommandsProcessor = (function() if(this.getCommand()) return true; return false; - } + }; /** * Processes the command. @@ -73,7 +73,7 @@ var CommandsProcessor = (function() commands[this.getCommand()](this.getArgument()); - } + }; /** * Processes the data for topic command. @@ -83,7 +83,7 @@ var CommandsProcessor = (function() { var topic = Util.escapeHtml(commandArguments); connection.emuc.setSubject(topic); - } + }; /** * List with supported commands. The keys are the names of the commands and diff --git a/contact_list.js b/contact_list.js index 9bb330110..04e260e69 100644 --- a/contact_list.js +++ b/contact_list.js @@ -140,7 +140,7 @@ var ContactList = (function (my) { duration: 500}); } else { - // Undock the toolbar when the chat is shown and if we're in a + // Undock the toolbar when the chat is shown and if we're in a // video mode. if (VideoLayout.isLargeVideoVisible()) ToolbarToggler.dockToolbar(false); @@ -193,7 +193,7 @@ var ContactList = (function (my) { /** * Creates the avatar element. - * + * * @return the newly created avatar element */ function createAvatar() { @@ -201,7 +201,7 @@ var ContactList = (function (my) { avatar.className = "icon-avatar avatar"; return avatar; - }; + } /** * Creates the display name paragraph. @@ -213,7 +213,7 @@ var ContactList = (function (my) { p.innerHTML = displayName; return p; - }; + } /** * Indicates that the display name has changed. diff --git a/data_channels.js b/data_channels.js index 17cc334d4..01d74003d 100644 --- a/data_channels.js +++ b/data_channels.js @@ -1,5 +1,3 @@ -/* global connection, Strophe, updateLargeVideo, focusedVideoSrc*/ - // cache datachannels to avoid garbage collection // https://code.google.com/p/chromium/issues/detail?id=405545 var _dataChannels = []; @@ -95,7 +93,7 @@ function onDataChannel(event) { console.info("The Data Channel closed", dataChannel); var idx = _dataChannels.indexOf(dataChannel); - if (idx > -1) + if (idx > -1) _dataChannels = _dataChannels.splice(idx, 1); }; _dataChannels.push(dataChannel); diff --git a/etherpad.js b/etherpad.js index bb273e514..a235da960 100644 --- a/etherpad.js +++ b/etherpad.js @@ -1,4 +1,3 @@ -/* global $, config, Prezi, Util, connection, setLargeVideoVisible, dockToolbar */ var Etherpad = (function (my) { var etherpadName = null; var etherpadIFrame = null; diff --git a/local_sts.js b/local_sts.js index fbefa98c8..a261c36d1 100644 --- a/local_sts.js +++ b/local_sts.js @@ -39,7 +39,7 @@ var LocalStatsCollector = (function() { if (!window.AudioContext) return; - var context = new AudioContext(); + var context = new window.AudioContext(); var analyser = context.createAnalyser(); analyser.smoothingTimeConstant = WEBAUDIO_ANALIZER_SMOOTING_TIME; analyser.fftSize = WEBAUDIO_ANALIZER_FFT_SIZE; @@ -55,7 +55,7 @@ var LocalStatsCollector = (function() { function () { var array = new Uint8Array(analyser.frequencyBinCount); analyser.getByteTimeDomainData(array); - var audioLevel = TimeDomainDataToAudioLevel(array); + var audioLevel = timeDomainDataToAudioLevel(array); if(audioLevel != self.audioLevel) { self.audioLevel = animateLevel(audioLevel, self.audioLevel); self.updateCallback(LocalStatsCollectorProto.LOCAL_JID, self.audioLevel); @@ -81,7 +81,7 @@ var LocalStatsCollector = (function() { * @param array the time domain data array. * @returns {number} the audio level */ - var TimeDomainDataToAudioLevel = function (samples) { + var timeDomainDataToAudioLevel = function (samples) { var maxVolume = 0; diff --git a/roomname_generator.js b/roomname_generator.js index 45d35014b..2ba04f9db 100644 --- a/roomname_generator.js +++ b/roomname_generator.js @@ -135,9 +135,9 @@ var RoomNameGenerator = function(my) { number_of_words = NUMBER_OF_WORDS; var name = ""; for(var i = 0; itrue if the peer container exists, * false - otherwise */ @@ -335,7 +335,7 @@ var VideoLayout = (function (my) { // If the peerJid is null then this video span couldn't be directly // associated with a participant (this could happen in the case of prezi). - if (focus && peerJid != null) + if (focus && peerJid !== null) addRemoteVideoMenu(peerJid, container); remotes.appendChild(container); @@ -438,7 +438,7 @@ var VideoLayout = (function (my) { /** * Removes the remote stream element corresponding to the given stream and * parent container. - * + * * @param stream the stream * @param container */ @@ -491,7 +491,7 @@ var VideoLayout = (function (my) { peerContainer.show(); else if (peerContainer.is(':visible') && !isShow) peerContainer.hide(); - }; + } /** * Sets the display name for the given video span id. @@ -599,7 +599,7 @@ var VideoLayout = (function (my) { }); } } - }; + } /** * Shows/hides the display name on the remote video. @@ -609,7 +609,7 @@ var VideoLayout = (function (my) { my.showDisplayName = function(videoSpanId, isShow) { var nameSpan = $('#' + videoSpanId + '>span.displayname').get(0); if (isShow) { - if (nameSpan && nameSpan.innerHTML && nameSpan.innerHTML.length) + if (nameSpan && nameSpan.innerHTML && nameSpan.innerHTML.length) nameSpan.setAttribute("style", "display:inline-block;"); } else { @@ -656,8 +656,10 @@ var VideoLayout = (function (my) { * from the connection.jingle.sessions. */ my.showFocusIndicator = function() { + var indicatorSpan; + if (focus !== null) { - var indicatorSpan = $('#localVideoContainer .focusindicator'); + indicatorSpan = $('#localVideoContainer .focusindicator'); if (indicatorSpan.children().length === 0) { @@ -677,7 +679,7 @@ var VideoLayout = (function (my) { console.error("No focus container!"); return; } - var indicatorSpan = $('#' + focusId + ' .focusindicator'); + indicatorSpan = $('#' + focusId + ' .focusindicator'); if (!indicatorSpan || indicatorSpan.length === 0) { indicatorSpan = document.createElement('span'); @@ -959,7 +961,7 @@ var VideoLayout = (function (my) { /** * Creates the edit display name button. - * + * * @returns the edit button */ function createEditDisplayNameButton() { @@ -1035,7 +1037,7 @@ var VideoLayout = (function (my) { var i = containerElement.id.indexOf('participant_'); if (i >= 0) - return containerElement.id.substring(i + 12); + return containerElement.id.substring(i + 12); }; /** @@ -1081,7 +1083,7 @@ var VideoLayout = (function (my) { } muteLinkItem.onclick = function(){ - if ($(this).attr('disabled') != undefined) { + if ($(this).attr('disabled') !== undefined) { event.preventDefault(); } var isMute = !mutedAudios[jid];