diff options
| author | Zaran <zaran.krleza@gmail.com> | 2011-05-31 23:09:30 +0200 |
|---|---|---|
| committer | Zaran <zaran.krleza@gmail.com> | 2011-05-31 23:09:30 +0200 |
| commit | cdc4ec8d31b826222d970fb37e3e101cd4f86a77 (patch) | |
| tree | 7a083fb140cd72255daff1706646c64116389747 /webclient/lib | |
| parent | 4b24326c5d8860002483a75da8f6ee5e305a3b80 (diff) | |
| download | alias-cdc4ec8d31b826222d970fb37e3e101cd4f86a77.tar.gz | |
Add a function to request an object to the object component
(this wasn't tested cause we need some changes server side)
Get the root object of a contact when clicking on it in the roster.
Make the 'start chat' link in the tooltips actually work.
Diffstat (limited to 'webclient/lib')
| -rw-r--r-- | webclient/lib/alias.js | 55 |
1 files changed, 39 insertions, 16 deletions
diff --git a/webclient/lib/alias.js b/webclient/lib/alias.js index 78fc4f4..f582587 100644 --- a/webclient/lib/alias.js +++ b/webclient/lib/alias.js @@ -138,22 +138,40 @@ var Alias = { }, /** - * Get the home node of a contact - * @param contact jquery object + * Get the home node of a user + * @param {String} owner The owner's JID */ - getHome: function(contact) { - var name = Base64.encode(Alias.getID(contact)) + '@' + server_component; - var iq = $iq({type : 'get', to : name}).c('query', {xmlns : 'alias:query', type:'content'}); - Alias.connection.sendIQ(iq, Alias.onHome); + getHome: function(owner) { + var objectName = MD5.hexdigest(owner); + Alias.getObject(objectName, owner); }, - + + /** + * Get the content of an object + * @param {String} object The hash identifying the requested object + * @param {String} owner The owner's JID + */ + getObject: function(object, owner) { + var name = Base64.encode(owner) + '@' + server_component; + var iq = $iq({type : 'get', to : name}).c('query', { + xmlns : 'alias:iq:object', + type : 'get', + node : object + }); + Alias.connection.sendIQ(iq, Alias.onObject); + }, + /** - * Called when receiving home node, display in the main div - * @param iq XML object + * Decrypt and display a received object + * @param {XMLElement} iq The received iq stanza from the component */ - onHome: function(iq) { - var content = $(iq).find('content').text(); - $('#main').html(content); + onObject: function(iq) { + var query = $(iq).find('query'); + var encryptedKey = query.find('key').text(); + var key = this.rsa.decrypt(encryptedKey); + var encryptedContent = query.find('content').text(); + var content = sjcl.decrypt(key, encryptedContent); + $('#profile').html(content); }, /** @@ -192,7 +210,9 @@ var Alias = { // init tooltip contact.tipTip({ - content: "<ul><li>Jid: " + jid + "</li><li><a>Start Chat</a></li></ul>", + content: "<ul><li>Jid: " + jid + + '</li><li><a href="'+ jid + +'" class="chat-link">Start Chat</a></li></ul>', defaultPosition: "right", keepAlive: true }); @@ -433,13 +453,16 @@ $(document).ready(function(){ $('.roster-contact').live('click', function(){ var jid = Alias.getID($(this)); - var name = Alias.getName($(this)); + Alias.getHome(jid); + }); + + $('.chat-link').live('click', function(event) { + event.preventDefault(); + var jid = $(this).attr('href'); var id = Alias.jid_to_id(jid); - if ( !$('#tabs').tabs('exist','#chat-' + id) ) { Alias.addChatTab(jid); } - $('#tabs').tabs('select', '#chat-' + id ); $('#chat-' + id + ' input').focus(); }); |
