Include jsxc deps and initialize the client on login
This commit is contained in:
parent
78100c6fb2
commit
50a7541d14
2 changed files with 44 additions and 0 deletions
43
app/assets/javascripts/jsxc.js
Normal file
43
app/assets/javascripts/jsxc.js
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
//= require diaspora_jsxc
|
||||
|
||||
// initialize jsxc xmpp client
|
||||
$(document).ready(function() {
|
||||
if (app.currentUser.authenticated()) {
|
||||
$.post('api/v1/tokens', null, function(data) {
|
||||
if (jsxc && data['token']) {
|
||||
var jid = app.currentUser.get('diaspora_id');
|
||||
jsxc.init({
|
||||
root: '/assets/diaspora_jsxc',
|
||||
checkFlash: false,
|
||||
logoutElement: $('.user-menu-item [data-method=delete]'),
|
||||
rosterAppend: 'body',
|
||||
otr: {
|
||||
debug: true,
|
||||
SEND_WHITESPACE_TAG: true,
|
||||
WHITESPACE_START_AKE: true
|
||||
},
|
||||
autoLang: true,
|
||||
priority: {
|
||||
online: 1,
|
||||
chat: 1
|
||||
},
|
||||
xmpp: {
|
||||
url: $('script#jsxc').data('endpoint'),
|
||||
username: jid.replace(/@.*?$/g, ''),
|
||||
domain: jid.replace(/^.*?@/g, ''),
|
||||
jid: jid,
|
||||
password: data['token'],
|
||||
resource: 'diaspora-jsxc',
|
||||
overwrite: true,
|
||||
onlogin: true
|
||||
}
|
||||
});
|
||||
// TODO unset debug on default (testing version)
|
||||
jsxc.storage.setItem('debug', true);
|
||||
jsxc.login();
|
||||
} else {
|
||||
console.error('No token found! Authenticated!?');
|
||||
}
|
||||
}, 'json');
|
||||
}
|
||||
});
|
||||
|
|
@ -11,4 +11,5 @@
|
|||
*= require vendor/autoSuggest
|
||||
*= require entypo-fonts
|
||||
*= require entypo
|
||||
*= require diaspora_jsxc
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue