// Handle Tune
if (items.getAttribute('node') == NS_TUNE) {
var tune = new Tune();
- tune.artist = Strophe.getText(items.getElementsByTagName('artist')[0]);
- tune.length= Strophe.getText(items.getElementsByTagName('length')[0]);
- tune.rating= Strophe.getText(items.getElementsByTagName('rating')[0]);
- tune.source= Strophe.getText(items.getElementsByTagName('source')[0]);
- tune.title= Strophe.getText(items.getElementsByTagName('title')[0]);
- tune.track= Strophe.getText(items.getElementsByTagName('track')[0]);
- tune.uri= Strophe.getText(items.getElementsByTagName('uri')[0]);
- roster[jid2id(from)].tune = tune;
- if ( $('#'+jid2id(from)+' .tune').length > 0 ) {
- $('#'+jid2id(from)+' .tune').empty();
- $('#'+jid2id(from)+' .tune').append(Strophe.xmlTextNode('Listening to '+ tune.title + ' by ' + tune.artist + ' from ' + tune.source));
+ if (items.getElementsByTagName('tune')[0].childNodes.length > 0) {
+ tune.artist = Strophe.getText(items.getElementsByTagName('artist')[0]);
+ tune.length= Strophe.getText(items.getElementsByTagName('length')[0]);
+ tune.rating= Strophe.getText(items.getElementsByTagName('rating')[0]);
+ tune.source= Strophe.getText(items.getElementsByTagName('source')[0]);
+ tune.title= Strophe.getText(items.getElementsByTagName('title')[0]);
+ tune.track= Strophe.getText(items.getElementsByTagName('track')[0]);
+ tune.uri= Strophe.getText(items.getElementsByTagName('uri')[0]);
+ if ( $('#'+jid2id(from)+' .tune').length > 0 ) {
+ $('#'+jid2id(from)+' .tune').empty();
+ $('#'+jid2id(from)+' .tune').append(Strophe.xmlTextNode('Listening to '+ tune.title + ' by ' + tune.artist + ' from ' + tune.source));
+ } else {
+ $('#'+jid2id(from)).append('<br /><span class="tune">Listening to '+ tune.title + ' by ' + tune.artist + ' from ' + tune.source + '</span>');
+ }
} else {
- $('#'+jid2id(from)).append('<br /><span class="tune">Listening to '+ tune.title + ' by ' + tune.artist + ' from ' + tune.source + '</span>');
+ if ( $('#'+jid2id(from)+' .tune').length > 0 ) {
+ $('#'+jid2id(from)+' .tune').empty();
+ }
}
+ roster[jid2id(from)].tune = tune;
}
return true;
}