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

Also inform if no rooms were found

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