]> git.mxchange.org Git - friendica-addons.git/blob - jappixmini/jappix/js/xmpplinks.js
jappixmini: include jappix source
[friendica-addons.git] / jappixmini / jappix / js / xmpplinks.js
1 /*
2
3 Jappix - An open social platform
4 These are the XMPP links handling JS scripts for Jappix
5
6 -------------------------------------------------
7
8 License: AGPL
9 Author: Vanaryon
10 Last revision: 08/05/11
11
12 */
13
14 // Does an action with the provided XMPP link
15 function xmppLink(link) {
16         /* REF: http://xmpp.org/registrar/querytypes.html */
17         
18         // Remove the "xmpp:" string
19         link = explodeThis(':', link, 1);
20         
21         // The XMPP URI has no "?"
22         if(link.indexOf('?') == -1)
23                 checkChatCreate(link, 'chat');
24         
25         // Parse the URI
26         else {
27                 var xid = explodeThis('?', link, 0);
28                 var action = explodeThis('?', link, 1);
29                 
30                 switch(action) {
31                         // Groupchat
32                         case 'join':
33                                 checkChatCreate(xid, 'groupchat');
34                                 
35                                 break;
36                         
37                         // Profile
38                         case 'vcard':
39                                 openUserInfos(xid);
40                                 
41                                 break;
42                         
43                         // Subscription
44                         case 'subscribe':
45                                 addThisContact(xid);
46                                 
47                                 break;
48                         
49                         // Unsubscription
50                         case 'unsubscribe':
51                                 sendRoster(xid, 'remove');
52                                 
53                                 break;
54                         
55                         // Private chat
56                         default:
57                                 checkChatCreate(xid, 'chat');
58                                 
59                                 break;
60                 }
61         }
62         
63         return false;
64 }
65
66 // Gets the links vars (get parameters in URL)
67 var LINK_VARS = (function() {
68         var vars = [], hash;
69         var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
70         
71         for(var i = 0; i < hashes.length; i++) {
72                 var hash = hashes[i].split('=');
73                 vars.push(hash[0]);
74                 vars[hash[0]] = decodeURIComponent(hash[1]);
75         }
76         
77         return vars;
78 })();