]> git.babelmonkeys.de Git - socialXMPP.git/commitdiff
Show tune in vCard
authorFlorian Zeitz <florob@babelmonkeys.de>
Thu, 30 Jul 2009 20:25:41 +0000 (22:25 +0200)
committerFlorian Zeitz <florob@babelmonkeys.de>
Thu, 30 Jul 2009 20:25:41 +0000 (22:25 +0200)
* Tune is now displayed in vCard not under the roster entry

scripts/basic.js
scripts/classes.js

index d9a14ce02e77def6b8279eaf528a55c73f01ff80..8c7b5e69acb4da46f4ba6c870b815e27350630a3 100644 (file)
@@ -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('<li id="tune"><span class="vCardName">Tune: </span>Listening to '+
+                       roster[jid2id(jid)].tune.title + ' by ' + roster[jid2id(jid)].tune.artist +
+                       ' from ' + roster[jid2id(jid)].tune.source + '</li>')
+    }
+
     $('#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('<br /><span class="tune">Listening to '+ tune.title + ' by ' + tune.artist + ' from ' + tune.source + '</span>');
+           if (roster[jid2id(from)].visible == true) {
+               if ( $('#tune').length > 0) {
+                   $('#tune').empty();
+                   $('#tune').append('<span class="vCardName">Tune: </span>');
+                   $('#tune').append(Strophe.xmlTextNode('Listening to '+ tune.title +
+                               ' by ' + tune.artist + ' from ' + tune.source));
+               } else {
+                   $('#vCard ul').append('<li id="tune"><span class="vCardName">Tune: </span>Listening to '+ tune.title +
+                               ' by ' + tune.artist + ' from ' + tune.source + '</li>')
+               }
            }
        } else {
-           if ( $('#'+jid2id(from)+' .tune').length > 0 ) {
-               $('#'+jid2id(from)+' .tune').empty();
-           }
+           $('#tune').remove();
        }
        roster[jid2id(from)].tune = tune;
     }
index 62d962f760f1ce37ad3c040a760e754cfef6ba11..8832d68cc9d90e795717420d89be115b7d9ae95b 100644 (file)
@@ -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();
 };