xmpp.chapril.org-conversejs/main.js
JC Brand c17ffdb98a Added functionality to connect to an XMPP server.
Can succesfully connect now, but still need to get rid of ajax calls to @@xmp-userinfo, and replace them with
VCards.
2012-11-20 13:23:03 +02:00

51 lines
2.1 KiB
JavaScript

require(["jquery", "converse"], function($) {
$(function() {
$('#login_dialog').dialog({
autoOpen: true,
draggable: false,
modal: true,
title: 'Connect to XMPP',
buttons: {
"Connect": function () {
$(document).trigger('connect', {
jid: $('#jid').val(),
password: $('#password').val(),
bosh_service_url: $('#bosh_service_url').val()
});
$('#password').val('');
$(this).dialog('close');
}
}
});
$(document).bind('connect', function (ev, data) {
var connection = new Strophe.Connection(data.bosh_service_url);
connection.connect(data.jid, data.password, function (status) {
if (status === Strophe.Status.CONNECTED) {
console.log('Connected');
$(document).trigger('jarnxmpp.connected', connection);
} else if (status === Strophe.Status.DISCONNECTED) {
console.log('Disconnected');
$(document).trigger('jarnxmpp.disconnected');
} else if (status === Strophe.Status.Error) {
console.log('Error');
} else if (status === Strophe.Status.CONNECTING) {
console.log('Connecting');
} else if (status === Strophe.Status.CONNFAIL) {
console.log('Connection Failed');
} else if (status === Strophe.Status.AUTHENTICATING) {
console.log('Authenticating');
} else if (status === Strophe.Status.AUTHFAIL) {
console.log('Authenticating Failed');
} else if (status === Strophe.Status.DISCONNECTING) {
console.log('Disconnecting');
} else if (status === Strophe.Status.ATTACHED) {
console.log('Attached');
}
});
});
});
});