';
// Create the popup
createPopup('rosterx', html);
// Associate the events
launchRosterX();
// Parse the data
parseRosterX(data);
logThis('Roster Item Exchange popup opened.');
}
// Closes the rosterx tools
function closeRosterX() {
// Destroy the popup
destroyPopup('rosterx');
return false;
}
// Parses a rosterx query
function parseRosterX(data) {
// Main selector
var x = $(data).find('x[xmlns="' + NS_ROSTERX + '"]:first');
// Parse data
x.find('item').each(function() {
// Generate group XML
var group = '';
$(this).find('group').each(function() {
group += '' + $(this).text().htmlEnc() + '';
});
if(group)
group = '' + group + '';
// Display it!
displayRosterX($(this).attr('jid'), $(this).attr('name'), group, $(this).attr('action'));
});
// Click to check/uncheck
$('#rosterx .oneresult').click(function(evt) {
// No need to apply when click on input
if($(evt.target).is('input[type="checkbox"]'))
return;
// Input selector
var checkbox = $(this).find('input[type="checkbox"]');
// Check or uncheck?
if(checkbox.filter(':checked').size())
checkbox.removeAttr('checked');
else
checkbox.attr('checked', true);
});
}
// Displays a rosterx item
function displayRosterX(xid, nick, group, action) {
// End if no XID
if(!xid)
return false;
// Set up a default action if no one
if(!action || (action != 'modify') || (action != 'delete'))
action = 'add';
// Override "undefined" for nickname
if(!nick)
nick = '';
// Display it
$('#rosterx .results').append(
'