Bladeren bron

Fixes or ignores (explicidly, as much as possible) jshint warnings.

j8
Boris Grozev 9 jaren geleden
bovenliggende
commit
27c297c034

+ 6
- 4
.jshintignore Bestand weergeven

@@ -1,6 +1,8 @@
1 1
 node_modules
2 2
 libs
3
-replacement.js
4
-prezi.js
5
-muc.js
6
-app.js
3
+debian
4
+analytics.js
5
+
6
+modules/xmpp/strophe.emuc.js
7
+modules/UI/prezi/Prezi.js
8
+modules/RTC/adapter.screenshare.js

+ 6
- 2
.jshintrc Bestand weergeven

@@ -1,4 +1,5 @@
1 1
 {
2
+    // Refer to http://jshint.com/docs/options/ for an exhaustive list of options
2 3
     "asi": false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
3 4
     "expr": true, // true: Tolerate `ExpressionStatement` as Programs
4 5
     "loopfunc": true, // true: Tolerate functions being defined in loops
@@ -12,5 +13,8 @@
12 13
     "indent": 4, // {int} Number of spaces to use for indentation
13 14
     "latedef": true, // true: Require variables/functions to be defined before being used
14 15
     "newcap": true, // true: Require capitalization of all constructor functions e.g. `new F()`
15
-    "maxlen": 80    // {int} Max number of characters per line
16
-}
16
+    //TODO: set to 80 when the code is compliant..
17
+    "maxlen": 1000, // {int} Max number of characters per line
18
+    "latedef": false, //This option prohibits the use of a variable before it was defined
19
+    "laxbreak": true //Ignore line breaks around "=", "==", "&&", etc.
20
+}

+ 3
- 3
external_api.js Bestand weergeven

@@ -29,9 +29,9 @@ var JitsiMeetExternalAPI = (function()
29 29
      */
30 30
     function JitsiMeetExternalAPI(domain, room_name, width, height, parentNode,
31 31
         configOverwrite, interfaceConfigOverwrite) {
32
-        if((!width || width < MIN_WIDTH) && !filmStripOnly)
32
+        if (!width || width < MIN_WIDTH)
33 33
             width = MIN_WIDTH;
34
-        if((!height || height < MIN_HEIGHT) && !filmStripOnly)
34
+        if (!height || height < MIN_HEIGHT)
35 35
             height = MIN_HEIGHT;
36 36
 
37 37
         this.parentNode = null;
@@ -371,4 +371,4 @@ var JitsiMeetExternalAPI = (function()
371 371
 
372 372
     return JitsiMeetExternalAPI;
373 373
 
374
-})();
374
+})();

+ 3
- 3
modules/RTC/DataChannels.js Bestand weergeven

@@ -69,14 +69,14 @@ var DataChannels = {
69 69
                         if (type === 'string') {
70 70
                             oldValue = (oldValue == "true");
71 71
                         } else {
72
-                            oldValue = new Boolean(oldValue).valueOf();
72
+                            oldValue = Boolean(oldValue).valueOf();
73 73
                         }
74 74
                     }
75 75
                     if ((type = typeof newValue) !== 'boolean') {
76 76
                         if (type === 'string') {
77 77
                             newValue = (newValue == "true");
78 78
                         } else {
79
-                            newValue = new Boolean(newValue).valueOf();
79
+                            newValue = Boolean(newValue).valueOf();
80 80
                         }
81 81
                     }
82 82
 
@@ -151,7 +151,7 @@ var DataChannels = {
151 151
 
152 152
 function onSelectedEndpointChanged(userResource) {
153 153
     console.log('selected endpoint changed: ', userResource);
154
-    if (_dataChannels && _dataChannels.length != 0) {
154
+    if (_dataChannels && _dataChannels.length !== 0) {
155 155
         _dataChannels.some(function (dataChannel) {
156 156
             if (dataChannel.readyState == 'open') {
157 157
                 console.log('sending selected endpoint changed ' +

+ 1
- 1
modules/RTC/RTC.js Bestand weergeven

@@ -69,7 +69,7 @@ var RTC = {
69 69
 
70 70
         var localStream =  new LocalStream(stream, type, eventEmitter, videoType, isGUMStream);
71 71
         //in firefox we have only one stream object
72
-        if(this.localStreams.length == 0 ||
72
+        if(this.localStreams.length === 0 ||
73 73
             this.localStreams[0].getOriginalStream() != stream)
74 74
             this.localStreams.push(localStream);
75 75
         if(isMuted === true)

+ 5
- 3
modules/RTC/RTCUtils.js Bestand weergeven

@@ -1,4 +1,6 @@
1
-/* global APP, config, require, attachMediaStream, getUserMedia */
1
+/* global APP, config, require, attachMediaStream, getUserMedia,
2
+    RTCPeerConnection, webkitMediaStream, webkitURL, webkitRTCPeerConnection,
3
+    mozRTCIceCandidate, mozRTCSessionDescription, mozRTCPeerConnection */
2 4
 var RTCBrowserType = require("./RTCBrowserType");
3 5
 var Resolutions = require("../../service/RTC/Resolutions");
4 6
 var AdapterJS = require("./adapter.screenshare");
@@ -192,8 +194,8 @@ function RTCUtils(RTCService, onTemasysPluginReady)
192 194
                 if(element)
193 195
                     element.mozSrcObject = src;
194 196
             };
195
-            RTCSessionDescription = mozRTCSessionDescription;
196
-            RTCIceCandidate = mozRTCIceCandidate;
197
+            window.RTCSessionDescription = mozRTCSessionDescription;
198
+            window.RTCIceCandidate = mozRTCIceCandidate;
197 199
         } else {
198 200
             console.error(
199 201
                 "Firefox version too old: " + FFversion + ". Required >= 40.");

+ 3
- 0
modules/UI/UI.js Bestand weergeven

@@ -312,7 +312,10 @@ function registerListeners() {
312 312
     });
313 313
     APP.xmpp.addListener(XMPPEvents.PROMPT_FOR_LOGIN, function () {
314 314
         // FIXME: re-use LoginDialog which supports retries
315
+        // FIXME^2: This looks like a bug...connect is undefined.
316
+        /* jshint -W117 */
315 317
         UI.showLoginPopup(connect);
318
+        /* jshint +W117 */
316 319
     });
317 320
 
318 321
     APP.xmpp.addListener(XMPPEvents.FOCUS_DISCONNECTED, function (focusComponent, retrySec) {

+ 1
- 0
modules/UI/avatar/Avatar.js Bestand weergeven

@@ -1,3 +1,4 @@
1
+/* global Strophe, APP, MD5 */
1 2
 var Settings = require("../../settings/Settings");
2 3
 
3 4
 var users = {};

+ 10
- 7
modules/UI/prezi/PreziPlayer.js Bestand weergeven

@@ -1,3 +1,4 @@
1
+/* global PreziPlayer */
1 2
 (function() {
2 3
     "use strict";
3 4
     var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
@@ -26,7 +27,7 @@
26 27
             for(var i=0; i<optionArray.length; i++) {
27 28
                 var optionSet = optionArray[i];
28 29
                 new PreziPlayer(optionSet.id, optionSet);
29
-            };
30
+            }
30 31
         };
31 32
 
32 33
         PreziPlayer.messageReceived = function(event){
@@ -51,7 +52,9 @@
51 52
             } catch (e) { }
52 53
         };
53 54
 
55
+/*jshint -W004 */
54 56
         function PreziPlayer(id, options) {
57
+/*jshint +W004 */
55 58
             var params, paramString = "", _this = this;
56 59
             if (PreziPlayer.players[id]){
57 60
                 PreziPlayer.players[id].destroy();
@@ -59,7 +62,7 @@
59 62
             for(var i=0; i<PreziPlayer.binded_methods.length; i++) {
60 63
                 var method_name = PreziPlayer.binded_methods[i];
61 64
                 _this[method_name] = __bind(_this[method_name], _this);
62
-            };
65
+            }
63 66
             options = options || {};
64 67
             this.options = options;
65 68
             this.values = {'status': PreziPlayer.STATUS_LOADING};
@@ -78,10 +81,10 @@
78 81
                 { name: 'explorable', value: options.explorable ? 1 : 0 },
79 82
                 { name: 'controls', value: options.controls ? 1 : 0 }
80 83
             ];
81
-            for(var i=0; i<params.length; i++) {
84
+            for (i=0; i<params.length; i++) {
82 85
                 var param = params[i];
83 86
                 paramString += (i===0 ? "?" : "&") + param.name + "=" + param.value;
84
-            };
87
+            }
85 88
             this.iframe.src = PreziPlayer.domain + PreziPlayer.path + paramString;
86 89
             this.iframe.frameBorder = 0;
87 90
             this.iframe.scrolling = "no";
@@ -249,14 +252,14 @@
249 252
             for (var parameter in dims) {
250 253
                 this.iframe[parameter] = dims[parameter];
251 254
             }
252
-        }
255
+        };
253 256
 
254 257
         PreziPlayer.prototype.getDimensions = function() {
255 258
             return {
256 259
                 width: parseInt(this.iframe.width, 10),
257 260
                 height: parseInt(this.iframe.height, 10)
258
-            }
259
-        }
261
+            };
262
+        };
260 263
 
261 264
         PreziPlayer.prototype.on = function(event, callback) {
262 265
             this.callbacks.push({

+ 1
- 1
modules/UI/side_pannels/chat/Commands.js Bestand weergeven

@@ -18,7 +18,7 @@ var commands = {
18 18
 function getCommand(message) {
19 19
     if(message) {
20 20
         for(var command in commands) {
21
-            if(message.indexOf("/" + command) == 0)
21
+            if(message.indexOf("/" + command) === 0)
22 22
                 return command;
23 23
         }
24 24
     }

+ 1
- 1
modules/UI/side_pannels/chat/Replacement.js Bestand weergeven

@@ -45,7 +45,7 @@ function smilify(body)
45 45
         return body;
46 46
     }
47 47
 
48
-    var regexs = Smileys["regexs"];
48
+    var regexs = Smileys.regexs;
49 49
     for(var smiley in regexs) {
50 50
         if(regexs.hasOwnProperty(smiley)) {
51 51
             body = body.replace(regexs[smiley],

+ 1
- 1
modules/UI/toolbars/Toolbar.js Bestand weergeven

@@ -600,7 +600,7 @@ var Toolbar = (function (my) {
600 600
         if (config.enableRecording && config.autoRecord) {
601 601
             toggleRecording(config.autoRecordToken);
602 602
         }
603
-    }
603
+    };
604 604
 
605 605
     // Shows or hides SIP calls button
606 606
     my.showSipCallButton = function (show) {

+ 1
- 1
modules/UI/util/MessageHandler.js Bestand weergeven

@@ -1,4 +1,4 @@
1
-/* global $, APP, jQuery, toastr */
1
+/* global $, APP, jQuery, toastr, Impromptu */
2 2
 
3 3
 /**
4 4
  * Flag for enable/disable of the notifications.

+ 1
- 1
modules/UI/videolayout/RemoteVideo.js Bestand weergeven

@@ -130,7 +130,7 @@ if (!interfaceConfig.filmStripOnly) {
130 130
     };
131 131
 
132 132
 } else {
133
-    RemoteVideo.prototype.addRemoteVideoMenu = function() {}
133
+    RemoteVideo.prototype.addRemoteVideoMenu = function() {};
134 134
 }
135 135
 
136 136
 /**

+ 1
- 1
modules/UI/welcome_page/WelcomePage.js Bestand weergeven

@@ -17,7 +17,7 @@ function animate(word) {
17 17
     var currentVal = $("#enter_room_field").attr("placeholder");
18 18
     $("#enter_room_field").attr("placeholder", currentVal + word.substr(0, 1));
19 19
     animateTimeout = setTimeout(function() {
20
-        animate(word.substring(1, word.length))
20
+        animate(word.substring(1, word.length));
21 21
     }, 70);
22 22
 }
23 23
 

+ 4
- 5
modules/config/HttpConfigFetch.js Bestand weergeven

@@ -1,4 +1,4 @@
1
-/* global $, $iq, config, interfaceConfig */
1
+/* global $, config, interfaceConfig */
2 2
 
3 3
 var configUtil = require('./Util');
4 4
 
@@ -28,8 +28,8 @@ var HttpConfig = {
28 28
                 data: JSON.stringify({"roomName": roomName}),
29 29
                 dataType: 'json',
30 30
                 error: function(jqXHR, textStatus, errorThrown) {
31
-                    console.error("Get config error: ", jqXHR, errorThrown)
32
-                    error = "Get config response status: " + textStatus;
31
+                    console.error("Get config error: ", jqXHR, errorThrown);
32
+                    var error = "Get config response status: " + textStatus;
33 33
                     complete(false, error);
34 34
                 },
35 35
                 success: function(data, textStatus, jqXHR) {
@@ -40,8 +40,7 @@ var HttpConfig = {
40 40
                         return;
41 41
                     } catch (exception) {
42 42
                         console.error("Parse config error: ", exception);
43
-                        error = exception;
44
-                        complete(false, error);
43
+                        complete(false, exception);
45 44
                     }
46 45
                 }
47 46
             }

+ 1
- 1
modules/statistics/LocalStatsCollector.js Bestand weergeven

@@ -1,4 +1,4 @@
1
-/* global config */
1
+/* global config, AudioContext */
2 2
 /**
3 3
  * Provides statistics for the local stream.
4 4
  */

+ 11
- 15
modules/xmpp/JingleSessionPC.js Bestand weergeven

@@ -482,7 +482,7 @@ JingleSessionPC.prototype.createdOffer = function (sdp) {
482 482
                 JingleSessionPC.onJingleError(self.sid, error);
483 483
             },
484 484
             10000);
485
-    }
485
+    };
486 486
     sdp.sdp = this.localSDP.raw;
487 487
     this.peerconnection.setLocalDescription(sdp,
488 488
         function () {
@@ -714,7 +714,6 @@ JingleSessionPC.prototype.createdAnswer = function (sdp, provisional) {
714 714
             this.localSDP.raw = this.localSDP.session + '\r\n' + this.localSDP.media.join('');
715 715
         }
716 716
     }
717
-    var self = this;
718 717
     var sendJingle = function (ssrcs) {
719 718
                 // FIXME why do we generate session-accept in 3 different places ?
720 719
                 var accept = $iq({to: self.peerjid,
@@ -746,7 +745,7 @@ JingleSessionPC.prototype.createdAnswer = function (sdp, provisional) {
746 745
                         JingleSessionPC.onJingleError(self.sid, error);
747 746
                     },
748 747
                     10000);
749
-    }
748
+    };
750 749
     sdp.sdp = this.localSDP.raw;
751 750
     this.peerconnection.setLocalDescription(sdp,
752 751
         function () {
@@ -815,9 +814,8 @@ JingleSessionPC.prototype.addSource = function (elem, fromJid) {
815 814
 
816 815
     var self = this;
817 816
     // FIXME: dirty waiting
818
-    if (!this.peerconnection.localDescription)
819
-    {
820
-        console.warn("addSource - localDescription not ready yet")
817
+    if (!this.peerconnection.localDescription) {
818
+        console.warn("addSource - localDescription not ready yet");
821 819
         setTimeout(function()
822 820
             {
823 821
                 self.addSource(elem, fromJid);
@@ -897,11 +895,9 @@ JingleSessionPC.prototype.removeSource = function (elem, fromJid) {
897 895
 
898 896
     var self = this;
899 897
     // FIXME: dirty waiting
900
-    if (!this.peerconnection.localDescription)
901
-    {
902
-        console.warn("removeSource - localDescription not ready yet")
903
-        setTimeout(function()
904
-            {
898
+    if (!this.peerconnection.localDescription) {
899
+        console.warn("removeSource - localDescription not ready yet");
900
+        setTimeout(function() {
905 901
                 self.removeSource(elem, fromJid);
906 902
             },
907 903
             200
@@ -1312,7 +1308,7 @@ JingleSessionPC.prototype.getStats = function (interval) {
1312 1308
 JingleSessionPC.onJingleError = function (session, error)
1313 1309
 {
1314 1310
     console.error("Jingle error", error);
1315
-}
1311
+};
1316 1312
 
1317 1313
 JingleSessionPC.onJingleFatalError = function (session, error)
1318 1314
 {
@@ -1320,7 +1316,7 @@ JingleSessionPC.onJingleFatalError = function (session, error)
1320 1316
     this.connection.emuc.doLeave();
1321 1317
     this.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
1322 1318
     this.eventEmitter.emit(XMPPEvents.JINGLE_FATAL_ERROR, session, error);
1323
-}
1319
+};
1324 1320
 
1325 1321
 JingleSessionPC.prototype.setLocalDescription = function () {
1326 1322
     var self = this;
@@ -1360,7 +1356,7 @@ JingleSessionPC.prototype.setLocalDescription = function () {
1360 1356
             self.ssrcOwners[ssrc] = myJid;
1361 1357
         }
1362 1358
     }
1363
-}
1359
+};
1364 1360
 
1365 1361
 // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
1366 1362
 // TODO: is this hack (along with the XMPPEvent-s used only for it) still needed
@@ -1450,6 +1446,6 @@ JingleSessionPC.prototype.remoteStreamAdded = function (data, times) {
1450 1446
             sendKeyframe(self.peerconnection);
1451 1447
         }, 3000);
1452 1448
     }
1453
-}
1449
+};
1454 1450
 
1455 1451
 module.exports = JingleSessionPC;

+ 7
- 10
modules/xmpp/SDP.js Bestand weergeven

@@ -111,7 +111,8 @@ SDP.prototype.removeSessionLines = function(prefix) {
111 111
     });
112 112
     this.raw = this.session + this.media.join('');
113 113
     return lines;
114
-}
114
+};
115
+
115 116
 // remove lines matching prefix from a media section specified by mediaindex
116 117
 // TODO: non-numeric mediaindex could match mid
117 118
 SDP.prototype.removeMediaLines = function(mediaindex, prefix) {
@@ -122,7 +123,7 @@ SDP.prototype.removeMediaLines = function(mediaindex, prefix) {
122 123
     });
123 124
     this.raw = this.session + this.media.join('');
124 125
     return lines;
125
-}
126
+};
126 127
 
127 128
 // add content's to a jingle element
128 129
 SDP.prototype.toJingle = function (elem, thecreator, ssrcs) {
@@ -236,16 +237,12 @@ SDP.prototype.toJingle = function (elem, thecreator, ssrcs) {
236 237
                     elem.attrs({name: "cname", value:Math.random().toString(36).substring(7)});
237 238
                     elem.up();
238 239
                     var msid = null;
239
-                    if(mline.media == "audio")
240
-                    {
240
+                    if(mline.media == "audio") {
241 241
                         msid = APP.RTC.localAudio.getId();
242
-                    }
243
-                    else
244
-                    {
242
+                    } else {
245 243
                         msid = APP.RTC.localVideo.getId();
246 244
                     }
247
-                    if(msid != null)
248
-                    {
245
+                    if(msid !== null) {
249 246
                         msid = SDPUtil.filter_special_chars(msid);
250 247
                         elem.c('parameter');
251 248
                         elem.attrs({name: "msid", value:msid});
@@ -390,7 +387,7 @@ SDP.prototype.TransportToJingle = function (mediaindex, elem) {
390 387
         }
391 388
     }
392 389
     elem.up(); // end of transport
393
-}
390
+};
394 391
 
395 392
 SDP.prototype.RtcpFbToJingle = function (mediaindex, elem, payloadtype) { // XEP-0293
396 393
     var lines = SDPUtil.find_lines(this.media[mediaindex], 'a=rtcp-fb:' + payloadtype);

+ 1
- 1
modules/xmpp/SDPUtil.js Bestand weergeven

@@ -1,4 +1,4 @@
1
-SDPUtil = {
1
+var SDPUtil = {
2 2
     filter_special_chars: function (text) {
3 3
         return text.replace(/[\\\/\{,\}\+]/g, "");
4 4
     },

+ 3
- 2
modules/xmpp/TraceablePeerConnection.js Bestand weergeven

@@ -1,4 +1,5 @@
1
-/* global $ */
1
+/* global $, config, mozRTCPeerConnection, RTCPeerConnection,
2
+    webkitRTCPeerConnection, RTCSessionDescription */
2 3
 var RTC = require('../RTC/RTC');
3 4
 var RTCBrowserType = require("../RTC/RTCBrowserType.js");
4 5
 var XMPPEvents = require("../../service/xmpp/XMPPEvents");
@@ -128,7 +129,7 @@ function TraceablePeerConnection(ice_config, constraints, session) {
128 129
  * Returns a string representation of a SessionDescription object.
129 130
  */
130 131
 var dumpSDP = function(description) {
131
-    if (typeof description === 'undefined' || description == null) {
132
+    if (typeof description === 'undefined' || description === null) {
132 133
         return '';
133 134
     }
134 135
 

+ 3
- 8
modules/xmpp/strophe.jingle.js Bestand weergeven

@@ -33,8 +33,8 @@ module.exports = function(XMPP, eventEmitter) {
33 33
                 this.connection.disco.addFeature('urn:xmpp:jingle:apps:rtp:audio');
34 34
                 this.connection.disco.addFeature('urn:xmpp:jingle:apps:rtp:video');
35 35
 
36
-                if (RTCBrowserType.isChrome() || RTCBrowserType.isOpera()
37
-                    || RTCBrowserType.isTemasysPluginUsed()) {
36
+                if (RTCBrowserType.isChrome() || RTCBrowserType.isOpera() ||
37
+                    RTCBrowserType.isTemasysPluginUsed()) {
38 38
                     this.connection.disco.addFeature('urn:ietf:rfc:4588');
39 39
                 }
40 40
 
@@ -138,12 +138,7 @@ module.exports = function(XMPP, eventEmitter) {
138 138
                     $(document).trigger('callaccepted.jingle', [sess.sid]);
139 139
                     break;
140 140
                 case 'session-terminate':
141
-                    // If this is not the focus sending the terminate, we have
142
-                    // nothing more to do here.
143
-                    if (Object.keys(this.sessions).length < 1
144
-                        || !(this.sessions[Object.keys(this.sessions)[0]]
145
-                            instanceof JingleSession))
146
-                    {
141
+                    if (!sess) {
147 142
                         break;
148 143
                     }
149 144
                     console.log('terminating...', sess.sid);

+ 1
- 1
modules/xmpp/strophe.moderate.js Bestand weergeven

@@ -57,4 +57,4 @@ module.exports = function (XMPP, eventEmitter) {
57 57
             this.connection.emuc.kick(jid);
58 58
         }
59 59
     });
60
-}
60
+};

+ 1
- 0
modules/xmpp/strophe.util.js Bestand weergeven

@@ -1,3 +1,4 @@
1
+/* global Strophe */
1 2
 /**
2 3
  * Strophe logger implementation. Logs from level WARN and above.
3 4
  */

+ 1
- 1
modules/xmpp/xmpp.js Bestand weergeven

@@ -1,4 +1,4 @@
1
-/* global $, APP, config, Strophe*/
1
+/* global $, APP, config, Strophe, Base64, $msg */
2 2
 var Moderator = require("./moderator");
3 3
 var EventEmitter = require("events");
4 4
 var Recording = require("./recording");

+ 3
- 3
service/translation/languages.js Bestand weergeven

@@ -1,9 +1,9 @@
1 1
 module.exports = {
2 2
     getLanguages : function () {
3 3
         var languages = [];
4
-        for(var lang in this)
4
+        for (var lang in this)
5 5
         {
6
-            if(typeof this[lang] === "string")
6
+            if (typeof this[lang] === "string")
7 7
                 languages.push(this[lang]);
8 8
         }
9 9
         return languages;
@@ -13,4 +13,4 @@ module.exports = {
13 13
     DE: "de",
14 14
     TR: "tr",
15 15
     FR: "fr"
16
-}
16
+};

Laden…
Annuleren
Opslaan