Fixed JSLint warnings

This commit is contained in:
JC Brand 2012-12-11 15:21:56 +02:00
parent dbf20052c3
commit aad263868a

View File

@ -12,7 +12,7 @@
// AMD/global registrations // AMD/global registrations
(function (root, factory) { (function (root, factory) {
if (console===undefined || console.log===undefined) { if (typeof console === undefined || typeof console.log === undefined) {
console = { log: function () {}, error: function () {} }; console = { log: function () {}, error: function () {} };
} }
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
@ -68,47 +68,51 @@
}).c("x", { }).c("x", {
xmlns: Strophe.NS.MUC xmlns: Strophe.NS.MUC
}); });
if (password != null) { if (password !== null) {
msg.cnode(Strophe.xmlElement("password", [], password)); msg.cnode(Strophe.xmlElement("password", [], password));
} }
if (this._muc_handler == null) { if (this._muc_handler === null) {
this._muc_handler = this._connection.addHandler(function(stanza) { this._muc_handler = this._connection.addHandler(function(stanza) {
var from, handler, handlers, id, roomname, x, xmlns, xquery, _i, _len; var from, handler, handlers, id, roomname, x, xmlns, xquery, _i, _len;
from = stanza.getAttribute('from'); from = stanza.getAttribute('from');
roomname = from.split("/")[0]; roomname = from.split("/")[0];
if (!_this.rooms[roomname]) return true; if (!_this.rooms[roomname]) { return true; }
room = _this.rooms[roomname]; room = _this.rooms[roomname];
handlers = {}; handlers = {};
if (stanza.nodeName === "message") { if (stanza.nodeName === "message") {
handlers = room._message_handlers; handlers = room._message_handlers;
} else if (stanza.nodeName === "presence") { } else if (stanza.nodeName === "presence") {
xquery = stanza.getElementsByTagName("x"); xquery = stanza.getElementsByTagName("x");
if (xquery.length > 0) { if (xquery.length > 0) {
for (_i = 0, _len = xquery.length; _i < _len; _i++) { for (_i = 0, _len = xquery.length; _i < _len; _i++) {
x = xquery[_i]; x = xquery[_i];
xmlns = x.getAttribute("xmlns"); xmlns = x.getAttribute("xmlns");
if (xmlns && xmlns.match(Strophe.NS.MUC)) { if (xmlns && xmlns.match(Strophe.NS.MUC)) {
handlers = room._presence_handlers; handlers = room._presence_handlers;
break; break;
}
}
} }
} }
for (id in handlers) {
handler = handlers[id];
if (!handler(stanza, room)) { delete handlers[id]; }
} }
} return true;
for (id in handlers) {
handler = handlers[id];
if (!handler(stanza, room)) delete handlers[id];
}
return true;
}); });
} }
if ((_base = this.rooms)[room] == null) { if ((_base = this.rooms)[room] === null) {
_base[room] = new XmppRoom(this, room, nick, password); _base[room] = new XmppRoom(this, room, nick, password);
} }
if (pres_handler_cb) { if (pres_handler_cb) {
this.rooms[room].addHandler('presence', pres_handler_cb); this.rooms[room].addHandler('presence', pres_handler_cb);
} }
if (msg_handler_cb) this.rooms[room].addHandler('message', msg_handler_cb); if (msg_handler_cb) {
if (roster_cb) this.rooms[room].addHandler('roster', roster_cb); this.rooms[room].addHandler('message', msg_handler_cb);
}
if (roster_cb) {
this.rooms[room].addHandler('roster', roster_cb);
}
return this._connection.send(msg); return this._connection.send(msg);
}, },
@ -137,8 +141,10 @@
from: this._connection.jid, from: this._connection.jid,
to: room_nick to: room_nick
}); });
if (exit_msg != null) presence.c("status", exit_msg); if (exit_msg !== null) {
if (handler_cb != null) { presence.c("status", exit_msg);
}
if (handler_cb !== null) {
this._connection.addHandler(handler_cb, null, "presence", null, presenceid); this._connection.addHandler(handler_cb, null, "presence", null, presenceid);
} }
this._connection.send(presence); this._connection.send(presence);
@ -158,7 +164,7 @@
*/ */
var msg, msgid, parent, room_nick; var msg, msgid, parent, room_nick;
room_nick = this.test_append_nick(room, nick); room_nick = this.test_append_nick(room, nick);
type = type || (nick != null ? "chat" : "groupchat"); type = type || (nick !== null ? "chat" : "groupchat");
msgid = this._connection.getUniqueId(); msgid = this._connection.getUniqueId();
msg = $msg({ msg = $msg({
to: room_nick, to: room_nick,
@ -169,18 +175,15 @@
xmlns: Strophe.NS.CLIENT xmlns: Strophe.NS.CLIENT
}).t(message); }).t(message);
msg.up(); msg.up();
if (html_message != null) { if (html_message !== null) {
msg.c("html", { msg.c("html", {xmlns: Strophe.NS.XHTML_IM}).c("body", {xmlns: Strophe.NS.XHTML}).h(html_message);
xmlns: Strophe.NS.XHTML_IM
}).c("body", {
xmlns: Strophe.NS.XHTML
}).h(html_message);
if (msg.node.childNodes.length === 0) { if (msg.node.childNodes.length === 0) {
parent = msg.node.parentNode; parent = msg.node.parentNode;
msg.up().up(); msg.up().up();
msg.node.removeChild(parent); msg.node.removeChild(parent);
} else { } else {
msg.up().up(); msg.up().up();
} }
} }
msg.c("x", { msg.c("x", {
@ -222,7 +225,9 @@
}).c('invite', { }).c('invite', {
to: receiver to: receiver
}); });
if (reason != null) invitation.c('reason', reason); if (reason !== null) {
invitation.c('reason', reason);
}
this._connection.send(invitation); this._connection.send(invitation);
return msgid; return msgid;
}, },
@ -244,8 +249,8 @@
xmlns: 'jabber:x:conference', xmlns: 'jabber:x:conference',
jid: room jid: room
}; };
if (reason != null) attrs.reason = reason; if (reason !== null) { attrs.reason = reason; }
if (password != null) attrs.password = password; if (password !== null) { attrs.password = password; }
invitation = $msg({ invitation = $msg({
from: this._connection.jid, from: this._connection.jid,
to: receiver, to: receiver,
@ -293,7 +298,7 @@
}); });
stanza = config.tree(); stanza = config.tree();
id = this._connection.sendIQ(stanza); id = this._connection.sendIQ(stanza);
if (handler_cb != null) { if (handler_cb !== null) {
this._connection.addHandler(function(stanza) { handler_cb(stanza); this._connection.addHandler(function(stanza) { handler_cb(stanza);
return false; return false;
}, Strophe.NS.MUC_OWNER, "iq", null, id); }, Strophe.NS.MUC_OWNER, "iq", null, id);
@ -405,7 +410,7 @@
}).c("query", { }).c("query", {
xmlns: Strophe.NS.MUC_ADMIN xmlns: Strophe.NS.MUC_ADMIN
}).cnode(item.node); }).cnode(item.node);
if (reason != null) iq.c("reason", reason); if (reason !== null) { iq.c("reason", reason); }
return this._connection.sendIQ(iq.tree(), handler_cb, error_cb); return this._connection.sendIQ(iq.tree(), handler_cb, error_cb);
}, },
@ -515,8 +520,8 @@
from: this._connection.jid, from: this._connection.jid,
to: room_nick to: room_nick
}); });
if (show != null) presence.c('show', show).up(); if (show !== null) { presence.c('show', show).up(); }
if (status != null) presence.c('status', status); if (status !== null) { presence.c('status', status); }
return this._connection.send(presence.tree()); return this._connection.send(presence.tree());
}, },
@ -537,7 +542,7 @@
return this._connection.sendIQ(iq, handle_cb); return this._connection.sendIQ(iq, handle_cb);
}, },
test_append_nick: function(room, nick) { test_append_nick: function(room, nick) {
return room + (nick != null ? "/" + (Strophe.escapeNode(nick)) : ""); return room + (nick !== null ? "/" + (Strophe.escapeNode(nick)) : "");
} }
}); });
@ -555,7 +560,7 @@
this.password = password; this.password = password;
this._roomRosterHandler = __bind(this._roomRosterHandler, this); this._roomRosterHandler = __bind(this._roomRosterHandler, this);
this._addOccupant = __bind(this._addOccupant, this); this._addOccupant = __bind(this._addOccupant, this);
if (client.muc) this.client = client.muc; if (client.muc) { this.client = client.muc; }
this.name = Strophe.getBareJidFromJid(name); this.name = Strophe.getBareJidFromJid(name);
this.client.rooms[this.name] = this; this.client.rooms[this.name] = this;
this.addHandler('presence', this._roomRosterHandler); this.addHandler('presence', this._roomRosterHandler);
@ -753,7 +758,7 @@
_ref = this._roster_handlers; _ref = this._roster_handlers;
for (id in _ref) { for (id in _ref) {
handler = _ref[id]; handler = _ref[id];
if (!handler(this.roster, this)) delete this._roster_handlers[id]; if (!handler(this.roster, this)) { delete this._roster_handlers[id]; }
} }
return true; return true;
}; };
@ -825,33 +830,34 @@
child = query[_i]; child = query[_i];
attrs = child.attributes; attrs = child.attributes;
switch (child.nodeName) { switch (child.nodeName) {
case "identity": case "identity":
identity = {}; identity = {};
for (_j = 0, _len2 = attrs.length; _j < _len2; _j++) { for (_j = 0, _len2 = attrs.length; _j < _len2; _j++) {
attr = attrs[_j]; attr = attrs[_j];
identity[attr.name] = attr.textContent; identity[attr.name] = attr.textContent;
} }
this.identities.push(identity); this.identities.push(identity);
break; break;
case "feature": case "feature":
this.features.push(attrs["var"].textContent); this.features.push(attrs["var"].textContent);
break; break;
case "x": case "x":
attrs = child.childNodes[0].attributes; attrs = child.childNodes[0].attributes;
if ((!attrs["var"].textContent === 'FORM_TYPE') || (!attrs.type.textContent === 'hidden')) { if ((!attrs["var"].textContent === 'FORM_TYPE') || (!attrs.type.textContent === 'hidden')) {
break; break;
} }
_ref = child.childNodes; _ref = child.childNodes;
for (_k = 0, _len3 = _ref.length; _k < _len3; _k++) { for (_k = 0, _len3 = _ref.length; _k < _len3; _k++) {
field = _ref[_k]; field = _ref[_k];
if (!(!field.attributes.type)) continue; if (!(!field.attributes.type)) continue;
attrs = field.attributes;
this.x.push({ attrs = field.attributes;
"var": attrs["var"].textContent, this.x.push({
label: attrs.label.textContent || "", "var": attrs["var"].textContent,
value: field.firstChild.textContent || "" label: attrs.label.textContent || "",
}); value: field.firstChild.textContent || ""
} });
}
} }
} }
return { return {
@ -862,7 +868,6 @@
}; };
return RoomConfig; return RoomConfig;
})(); })();
Occupant = (function() { Occupant = (function() {