3 Jappix - An open social platform
4 These are the anonymous mode JS script for Jappix
6 -------------------------------------------------
9 Authors: Vanaryon, LinkMauve
10 Last revision: 02/10/11
14 // Connected to an anonymous session
15 function anonymousConnected(con) {
16 logThis('Jappix (anonymous) is now connected.', 3);
20 CURRENT_SESSION = true;
29 // Send our first presence
32 // Set last activity stamp
33 LAST_ACTIVITY = getTimeStamp();
35 // Create the new groupchat
36 checkChatCreate(generateXID(ANONYMOUS_ROOM, 'groupchat'), 'groupchat');
38 // Remove some nasty elements for the anonymous mode
39 $('.tools-mucadmin, .tools-add').remove();
44 // Send again our presence
51 // Remove the waiting icon
55 // Disconnected from an anonymous session
56 function anonymousDisconnected() {
57 logThis('Jappix (anonymous) is now disconnected.', 3);
60 // Logins to a anonymous account
61 function anonymousLogin(server) {
63 // We define the http binding parameters
67 oArgs.httpbase = HOST_BOSH_MAIN;
69 oArgs.httpbase = HOST_BOSH;
71 // We create the new http-binding connection
72 con = new JSJaCHttpBindingConnection(oArgs);
74 // And we handle everything that happen
75 con.registerHandler('message', handleMessage);
76 con.registerHandler('presence', handlePresence);
77 con.registerHandler('iq', handleIQ);
78 con.registerHandler('onconnect', anonymousConnected);
79 con.registerHandler('onerror', handleError);
80 con.registerHandler('ondisconnect', anonymousDisconnected);
82 // We set the anonymous connection parameters
84 oArgs.domain = server;
85 oArgs.authtype = 'saslanon';
86 oArgs.resource = JAPPIX_RESOURCE + ' Anonymous (' + (new Date()).getTime() + ')';
88 oArgs.xmllang = XML_LANG;
93 // Change the page title
99 logThis('Error while anonymous loggin in: ' + e, 1);
102 anonymousDisconnected();
104 // Open an unknown error
114 function launchAnonymous() {
115 logThis('Anonymous mode detected, connecting...', 3);
117 // We add the login wait div
122 ANONYMOUS_ROOM = LINK_VARS['r'];
124 ANONYMOUS_NICK = LINK_VARS['n'];
126 // Fire the login action
127 anonymousLogin(HOST_ANONYMOUS);
130 // Launch this plugin!
131 $(document).ready(launchAnonymous);