FS-7127 #comment follow jshint advices

This commit is contained in:
Seven Du 2015-01-03 09:23:36 +08:00
parent 0db3b1e344
commit a80c739409
3 changed files with 34 additions and 32 deletions

View File

@ -431,13 +431,13 @@
var iceServers = null; var iceServers = null;
if (options.iceServers) { if (options.iceServers) {
var tmp = options.iceServers;; var tmp = options.iceServers;
if (typeof(tmp) === "boolean") { if (typeof(tmp) === "boolean") {
tmp = null; 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"); console.warn("iceServers must be an array, reverting to default ice servers");
tmp = null; tmp = null;
} }

View File

@ -247,19 +247,19 @@
} }
return true; return true;
} };
$.JsonRpcClient.prototype.closeSocket = function() { $.JsonRpcClient.prototype.closeSocket = function() {
if (self.socketReady()) { 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(); this._ws_socket.close();
} }
} };
$.JsonRpcClient.prototype.loginData = function(params) { $.JsonRpcClient.prototype.loginData = function(params) {
self.options.login = params.login; self.options.login = params.login;
self.options.passwd = params.passwd; self.options.passwd = params.passwd;
} };
$.JsonRpcClient.prototype.connectSocket = function(onmessage_cb) { $.JsonRpcClient.prototype.connectSocket = function(onmessage_cb) {
var self = this; var self = this;
@ -299,10 +299,10 @@
self.ws_cnt++; 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; self.ws_sleep += 1000;
} }
} };
// Set up sending of message for when the socket is open. // Set up sending of message for when the socket is open.
self._ws_socket.onopen = function() { self._ws_socket.onopen = function() {
@ -317,15 +317,15 @@
var req; var req;
// Send the requests. // Send the requests.
while (req = $.JsonRpcClient.q.pop()) { while ((req = $.JsonRpcClient.q.pop())) {
self._ws_socket.send(req); self._ws_socket.send(req);
} }
} };
} }
} }
return self._ws_socket ? true : false; return self._ws_socket ? true : false;
} };
$.JsonRpcClient.prototype._getSocket = function(onmessage_cb) { $.JsonRpcClient.prototype._getSocket = function(onmessage_cb) {
// If there is no ws url set, we don't have a socket. // If there is no ws url set, we don't have a socket.
@ -381,9 +381,9 @@
/// @todo Make using the jsonrcp 2.0 check optional, to use this on JSON-RPC 1 backends. /// @todo Make using the jsonrcp 2.0 check optional, to use this on JSON-RPC 1 backends.
if (typeof response === 'object' if (typeof response === 'object' &&
&& 'jsonrpc' in response 'jsonrpc' in response &&
&& response.jsonrpc === '2.0') { response.jsonrpc === '2.0') {
/// @todo Handle bad response (without id). /// @todo Handle bad response (without id).
@ -419,8 +419,7 @@
self.authing = true; self.authing = true;
this.call("login", { login: self.options.login, passwd: self.options.passwd}, 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) { function(e) {
self.authing = false; self.authing = false;
console.log("logged in"); console.log("logged in");
@ -575,14 +574,18 @@
// Collect all request data and sort handlers by request id. // Collect all request data and sort handlers by request id.
var batch_request = []; var batch_request = [];
var handlers = {}; 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. // If we have a WebSocket, just send the requests individually like normal calls.
var socket = self.jsonrpcclient.options.getSocket(self.jsonrpcclient.wsOnMessage); var socket = self.jsonrpcclient.options.getSocket(self.jsonrpcclient.wsOnMessage);
if (socket !== null) { if (socket !== null) {
for (var i = 0; i < this._requests.length; i++) { for (i = 0; i < this._requests.length; i++) {
var call = this._requests[i]; call = this._requests[i];
var success_cb = ('success_cb' in call) ? call.success_cb : undefined; success_cb = ('success_cb' in call) ? call.success_cb : undefined;
var error_cb = ('error_cb' in call) ? call.error_cb : undefined; error_cb = ('error_cb' in call) ? call.error_cb : undefined;
self.jsonrpcclient._wsCall(socket, call.request, success_cb, error_cb); self.jsonrpcclient._wsCall(socket, call.request, success_cb, error_cb);
} }
@ -590,8 +593,8 @@
return; return;
} }
for (var i = 0; i < this._requests.length; i++) { for (i = 0; i < this._requests.length; i++) {
var call = this._requests[i]; call = this._requests[i];
batch_request.push(call.request); batch_request.push(call.request);
// If the request has an id, it should handle returns (otherwise it's a notify). // If the request has an id, it should handle returns (otherwise it's a notify).
@ -603,7 +606,7 @@
} }
} }
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. // No WebSocket, and no HTTP backend? This won't work.
if (self.jsonrpcclient.options.ajaxUrl === null) { if (self.jsonrpcclient.options.ajaxUrl === null) {

View File

@ -1137,7 +1137,7 @@
$.verto.confMan = function(verto, params) { $.verto.confMan = function(verto, params) {
var confMan = this; var confMan = this;
conf
confMan.params = $.extend({ confMan.params = $.extend({
tableID: null, tableID: null,
statusID: null, statusID: null,
@ -1164,9 +1164,8 @@
"<button class='ctlbtn' id='" + play_id + "'>Play</button>" + "<button class='ctlbtn' id='" + play_id + "'>Play</button>" +
"<button class='ctlbtn' id='" + stop_id + "'>Stop</button>" + "<button class='ctlbtn' id='" + stop_id + "'>Stop</button>" +
"<button class='ctlbtn' id='" + recording_id + "'>Record</button>" + "<button class='ctlbtn' id='" + recording_id + "'>Record</button>" +
"<button class='ctlbtn' id='" + rec_stop_id + "'>Record Stop</button>" "<button class='ctlbtn' id='" + rec_stop_id + "'>Record Stop</button>" +
"<br><br></div>";
+ "<br><br></div>";
jq.html(html); jq.html(html);
@ -1260,7 +1259,7 @@
if (confMan.params.mainModID) { if (confMan.params.mainModID) {
genMainMod($(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 { } else {
$(confMan.params.mainModID).html(""); $(confMan.params.mainModID).html("");
} }
@ -1277,7 +1276,7 @@
clearTimeout(confMan.lastTimeout); clearTimeout(confMan.lastTimeout);
confMan.lastTimeout = 0; 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);
} }
} }
}); });
@ -1349,7 +1348,7 @@
"fnRowCallback": row_callback "fnRowCallback": row_callback
}); });
} };
$.verto.confMan.prototype.modCommand = function(cmd, id, value) { $.verto.confMan.prototype.modCommand = function(cmd, id, value) {
var confMan = this; var confMan = this;
@ -1363,7 +1362,7 @@
"value": value "value": value
} }
}); });
} };
$.verto.confMan.prototype.destroy = function() { $.verto.confMan.prototype.destroy = function() {
var confMan = this; var confMan = this;
@ -1381,7 +1380,7 @@
if (confMan.params.mainModID) { if (confMan.params.mainModID) {
$(confMan.params.mainModID).html(""); $(confMan.params.mainModID).html("");
} }
} };
$.verto.dialog = function(direction, verto, params) { $.verto.dialog = function(direction, verto, params) {
var dialog = this; var dialog = this;