]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7127 #comment follow jshint advices
authorSeven Du <dujinfang@gmail.com>
Sat, 3 Jan 2015 01:23:36 +0000 (09:23 +0800)
committerSeven Du <dujinfang@gmail.com>
Sat, 3 Jan 2015 01:24:59 +0000 (09:24 +0800)
html5/verto/js/src/jquery.FSRTC.js
html5/verto/js/src/jquery.jsonrpcclient.js
html5/verto/js/src/jquery.verto.js

index 4635106069dad02839dd9d7bf50f818b31d708bd..9e973f2f24cf3d8b36587946d82d75665c25ba0d 100644 (file)
         var iceServers = null;
 
         if (options.iceServers) {
-            var tmp = options.iceServers;;
+            var tmp = options.iceServers;
 
             if (typeof(tmp) === "boolean") {
                 tmp = null;
             }
 
-            if (tmp && typeof(tmp) !== "array") {
+            if (!(tmp && typeof(tmp) == "object" && tmp.constructor === Array)) {
                 console.warn("iceServers must be an array, reverting to default ice servers");
                 tmp = null;
             }
index 51244e167254081622c3d07bd107a3104a78b179..e6000f084f25370a21221fc5067504c8057c7e47 100644 (file)
         }
 
         return true;
-    }
+    };
 
     $.JsonRpcClient.prototype.closeSocket = function() {
         if (self.socketReady()) {
-            this._ws_socket.onclose = function (w) {console.log("Closing Socket")}
+            this._ws_socket.onclose = function (w) {console.log("Closing Socket");};
             this._ws_socket.close();
         }
-    }
+    };
 
     $.JsonRpcClient.prototype.loginData = function(params) {
         self.options.login = params.login;
         self.options.passwd = params.passwd;
-    }
+    };
 
     $.JsonRpcClient.prototype.connectSocket = function(onmessage_cb) {
         var self = this;
 
                     self.ws_cnt++;
 
-                    if (self.ws_sleep < 3000 && (self.ws_cnt % 10) == 0) {
+                    if (self.ws_sleep < 3000 && (self.ws_cnt % 10) === 0) {
                         self.ws_sleep += 1000;
                     }
-                }
+                };
 
                 // Set up sending of message for when the socket is open.
                 self._ws_socket.onopen = function() {
 
                     var req;
                     // Send the requests.
-                    while (req = $.JsonRpcClient.q.pop()) {
+                    while ((req = $.JsonRpcClient.q.pop())) {
                         self._ws_socket.send(req);
                     }
-                }
+                };
             }
         }
 
         return self._ws_socket ? true : false;
-    }
+    };
 
     $.JsonRpcClient.prototype._getSocket = function(onmessage_cb) {
         // If there is no ws url set, we don't have a socket.
 
             /// @todo Make using the jsonrcp 2.0 check optional, to use this on JSON-RPC 1 backends.
 
-            if (typeof response === 'object'
-                && 'jsonrpc' in response
-                && response.jsonrpc === '2.0') {
+            if (typeof response === 'object' &&
+                'jsonrpc' in response &&
+                response.jsonrpc === '2.0') {
 
                 /// @todo Handle bad response (without id).
 
                         self.authing = true;
 
                         this.call("login", { login: self.options.login, passwd: self.options.passwd},
-                            this._ws_callbacks[response.id].request_obj.method == "login"
-                            ?
+                            this._ws_callbacks[response.id].request_obj.method == "login" ?
                             function(e) {
                                 self.authing = false;
                                 console.log("logged in");
         // Collect all request data and sort handlers by request id.
         var batch_request = [];
         var handlers = {};
+        var i = 0;
+        var call;
+        var success_cb;
+        var error_cb;
 
         // If we have a WebSocket, just send the requests individually like normal calls.
         var socket = self.jsonrpcclient.options.getSocket(self.jsonrpcclient.wsOnMessage);
         if (socket !== null) {
-            for (var i = 0; i < this._requests.length; i++) {
-                var call = this._requests[i];
-                var success_cb = ('success_cb' in call) ? call.success_cb : undefined;
-                var error_cb   = ('error_cb'   in call) ? call.error_cb   : undefined;
+            for (i = 0; i < this._requests.length; i++) {
+                call = this._requests[i];
+                success_cb = ('success_cb' in call) ? call.success_cb : undefined;
+                error_cb   = ('error_cb'   in call) ? call.error_cb   : undefined;
                 self.jsonrpcclient._wsCall(socket, call.request, success_cb, error_cb);
             }
 
             return;
         }
 
-        for (var i = 0; i < this._requests.length; i++) {
-            var call = this._requests[i];
+        for (i = 0; i < this._requests.length; i++) {
+            call = this._requests[i];
             batch_request.push(call.request);
 
             // If the request has an id, it should handle returns (otherwise it's a notify).
             }
         }
 
-        var success_cb = function(data) { self._batchCb(data, handlers, self.all_done_cb); };
+        success_cb = function(data) { self._batchCb(data, handlers, self.all_done_cb); };
 
         // No WebSocket, and no HTTP backend?  This won't work.
         if (self.jsonrpcclient.options.ajaxUrl === null) {
index 4beedc6548cc683e8270c0bec7a0558ae6475e2b..0a55dac2e7765277e8c7026ffff1877bf41c00ff 100644 (file)
 
     $.verto.confMan = function(verto, params) {
         var confMan = this;
-        conf
+
         confMan.params = $.extend({
             tableID: null,
             statusID: null,
             "<button class='ctlbtn' id='" + play_id + "'>Play</button>" +
             "<button class='ctlbtn' id='" + stop_id + "'>Stop</button>" +
             "<button class='ctlbtn' id='" + recording_id + "'>Record</button>" +
-            "<button class='ctlbtn' id='" + rec_stop_id + "'>Record Stop</button>"
-
-            + "<br><br></div>";
+            "<button class='ctlbtn' id='" + rec_stop_id + "'>Record Stop</button>" +
+            "<br><br></div>";
 
             jq.html(html);
 
 
             if (confMan.params.mainModID) {
                 genMainMod($(confMan.params.mainModID));
-                $(confMan.params.displayID).html("Moderator Controls Ready<br><br>")
+                $(confMan.params.displayID).html("Moderator Controls Ready<br><br>");
             } else {
                 $(confMan.params.mainModID).html("");
             }
                             clearTimeout(confMan.lastTimeout);
                             confMan.lastTimeout = 0;
                         }
-                        confMan.lastTimeout = setTimeout(function() { $(confMan.params.displayID).html(confMan.destroyed ? "" : "Moderator Controls Ready<br><br>")}, 4000);
+                        confMan.lastTimeout = setTimeout(function() { $(confMan.params.displayID).html(confMan.destroyed ? "" : "Moderator Controls Ready<br><br>");}, 4000);
                     }
                 }
             });
             "fnRowCallback": row_callback
 
         });
-    }
+    };
 
     $.verto.confMan.prototype.modCommand = function(cmd, id, value) {
         var confMan = this;
             "value": value
             }
         });
-    }
+    };
 
     $.verto.confMan.prototype.destroy = function() {
         var confMan = this;
         if (confMan.params.mainModID) {
             $(confMan.params.mainModID).html("");
         }
-    }
+    };
 
     $.verto.dialog = function(direction, verto, params) {
         var dialog = this;