Commit 07664ed3 authored by JC Brand's avatar JC Brand

Also inform if no rooms were found

parent 5b2af5b0
......@@ -524,11 +524,11 @@
return this._connection.send(presence.tree());
},
listRooms: function(server, handle_cb) {
listRooms: function(server, callback, errback) {
/* List all chat room available on a server.
* Parameters:
* (String) server - name of chat server.
* (String) handle_cb - Function to call for room list return.
* (String) callback - Function to call for room list return.
*/
var iq;
iq = $iq({
......@@ -538,7 +538,7 @@
}).c("query", {
xmlns: Strophe.NS.DISCO_ITEMS
});
return this._connection.sendIQ(iq, handle_cb);
return this._connection.sendIQ(iq, callback, errback);
},
test_append_nick: function(room, nick) {
return room + (nick !== null ? "/" + (Strophe.escapeNode(nick)) : "");
......
......@@ -431,7 +431,6 @@ form.search-xmpp-contact input {
#available-chatrooms dt,
#converse-roster dt {
font-weight: normal;
display: none;
font-size: 13px;
color: #666;
border: none;
......@@ -439,6 +438,10 @@ form.search-xmpp-contact input {
text-shadow: 0 1px 0 rgba(250, 250, 250, 1);
}
#converse-roster dt {
display: none;
}
dd.available-chatroom,
#converse-roster dd {
font-weight: bold;
......
......@@ -717,26 +717,31 @@
},
updateRoomsList: function (domain) {
converse.connection.muc.listRooms(this.muc_domain, $.proxy(function (iq) {
var name, jid, i,
rooms = $(iq).find('query').find('item'),
rooms_length = rooms.length,
$available_chatrooms = this.$el.find('#available-chatrooms'),
fragment = document.createDocumentFragment();
$available_chatrooms.html('<dt>Rooms on '+this.muc_domain+'</dt>');
if (rooms.length) {
$available_chatrooms.find('dt').show();
} else {
$available_chatrooms.find('dt').hide();
}
for (i=0; i<rooms_length; i++) {
name = Strophe.unescapeNode($(rooms[i]).attr('name')||$(rooms[i]).attr('jid'));
jid = $(rooms[i]).attr('jid');
fragment.appendChild($(this.room_template({'name':name, 'jid':jid}))[0]);
}
$available_chatrooms.append(fragment);
return true;
}, this));
converse.connection.muc.listRooms(
this.muc_domain,
$.proxy(function (iq) { // Success
var name, jid, i,
rooms = $(iq).find('query').find('item'),
rooms_length = rooms.length,
$available_chatrooms = this.$el.find('#available-chatrooms'),
fragment = document.createDocumentFragment();
if (rooms.length) {
$available_chatrooms.html('<dt>Rooms on '+this.muc_domain+'</dt>');
for (i=0; i<rooms_length; i++) {
name = Strophe.unescapeNode($(rooms[i]).attr('name')||$(rooms[i]).attr('jid'));
jid = $(rooms[i]).attr('jid');
fragment.appendChild($(this.room_template({'name':name, 'jid':jid}))[0]);
}
$available_chatrooms.append(fragment);
} else {
$available_chatrooms.html('<dt>No rooms on '+this.muc_domain+'</dt>');
}
return true;
}, this),
$.proxy(function (iq) { // Failure
var $available_chatrooms = this.$el.find('#available-chatrooms');
$available_chatrooms.html('<dt>No rooms on '+this.muc_domain+'</dt>');
}, this));
},
showRooms: function (ev) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment