From fd6408d23f1968d82912c028f5ae0187be20f4af Mon Sep 17 00:00:00 2001 From: Florian Zeitz Date: Thu, 30 Jul 2009 22:25:41 +0200 Subject: [PATCH] Show tune in vCard * Tune is now displayed in vCard not under the roster entry --- scripts/basic.js | 27 +++++++++++++++++++-------- scripts/classes.js | 1 + 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/scripts/basic.js b/scripts/basic.js index d9a14ce..8c7b5e6 100644 --- a/scripts/basic.js +++ b/scripts/basic.js @@ -61,13 +61,21 @@ function populateVCard(e, jid) { $('#EMAILWORK').append(Strophe.xmlTextNode($(this).find('USERID').text())); }); + if (!roster[jid2id(jid)].tune.isEmpty()) { + $('#vCard ul').append('
  • Tune: Listening to '+ + roster[jid2id(jid)].tune.title + ' by ' + roster[jid2id(jid)].tune.artist + + ' from ' + roster[jid2id(jid)].tune.source + '
  • ') + } + $('#vCard').click(function () { $('#box-overlay').hide(); $('#vCard_container').slideUp("normal"); + roster[jid2id(jid)].visible = false; }); $('#box-overlay').show(); $('#vCard_container').slideDown("normal"); + roster[jid2id(jid)].visible = true; } function _cbVCard(e) { @@ -285,16 +293,19 @@ function _cbPEP(e) { 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('
    Listening to '+ tune.title + ' by ' + tune.artist + ' from ' + tune.source + ''); + if (roster[jid2id(from)].visible == true) { + if ( $('#tune').length > 0) { + $('#tune').empty(); + $('#tune').append('Tune: '); + $('#tune').append(Strophe.xmlTextNode('Listening to '+ tune.title + + ' by ' + tune.artist + ' from ' + tune.source)); + } else { + $('#vCard ul').append('
  • Tune: Listening to '+ tune.title + + ' by ' + tune.artist + ' from ' + tune.source + '
  • ') + } } } else { - if ( $('#'+jid2id(from)+' .tune').length > 0 ) { - $('#'+jid2id(from)+' .tune').empty(); - } + $('#tune').remove(); } roster[jid2id(from)].tune = tune; } diff --git a/scripts/classes.js b/scripts/classes.js index 62d962f..8832d68 100644 --- a/scripts/classes.js +++ b/scripts/classes.js @@ -17,6 +17,7 @@ Buddy = function(name, jid) { this.name = name; this.jid = jid; this.vCard = ''; + this.visible = false; // Whether the vCard is currently displayed this.tune = new Tune(); }; -- 2.39.5