]> cgit.babelmonkeys.de Git - socialXMPP.git/blobdiff - scripts/basic.js
Fix effects
[socialXMPP.git] / scripts / basic.js
index 62c00c1470500f5ab58382c7686edbe60ffd968c..4b306950714a66569ba9b888097a2b0ed55d4f51 100644 (file)
@@ -61,13 +61,22 @@ 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");
+        $('#vCard_container').slideUp("normal", function() {
+               $('#box-overlay').hide();
+       });
+       roster[jid2id(jid)].visible = false;
       });
 
     $('#box-overlay').show();
     $('#vCard_container').slideDown("normal");
+    roster[jid2id(jid)].visible = true;
 }
 
 function _cbVCard(e) {
@@ -136,13 +145,12 @@ function getVCard(jid) {
 
 function getOwnInfo() {
     var id = connection.getUniqueId('vCardGet');
-    var vCardiq = $iq({'to': Strophe.getBareJidFromJid(connection.jid),
-               'id': id,
-               'type': 'get'}
+    var vCardiq = $iq({'id': id, 'type': 'get'}
        ).c('vCard', {'xmlns':NS_VCARD});
     connection.addHandler(_cbOwnVCard, null, 'iq', 'result', id);
     connection.send(vCardiq.tree());
 }
+
 function addFriend(jid, nick) {
     roster[jid2id(jid)] = new Buddy(nick, jid);
     $('#friends').append('<div class="friend" id="'+jid2id(jid)+'"><img src="imgs/none.png" /><br /><a class="nick">'+nick+'</a></div>');
@@ -193,7 +201,11 @@ function _cbDisco(e) {
     var id = e.getAttribute('id');
     var jid = e.getAttribute('from');
 
-    var response = $iq({id: id, type: 'result', to: jid});
+    if (jid) {
+       var response = $iq({id: id, type: 'result', to: jid});
+    } else {
+       var response = $iq({id: id, type: 'result'});
+    }
     var query = response.c('query', {xmlns: Strophe.NS.DISCO_INFO})
     query.c('identity', {category: 'client', type: 'web', name: appName}).up();
     for (var i = 0; i < features.length; i++) {
@@ -282,16 +294,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;
     }