xmpp.chapril.org-conversejs/main.js

51 lines
2.1 KiB
JavaScript
Raw Normal View History

2012-10-23 20:48:23 +02:00
require(["jquery", "converse"], function($) {
$(function() {
$('#login_dialog').dialog({
autoOpen: true,
draggable: false,
modal: true,
title: 'Connect to XMPP',
buttons: {
"Connect": function () {
$(document).trigger('connect', {
2013-03-06 10:40:15 +01:00
jid: $('#jid').val(),
password: $('#password').val(),
bosh_service_url: $('#bosh_service_url').val()
});
$('#password').val('');
$(this).dialog('close');
}
}
});
2013-03-06 10:40:15 +01:00
$(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');
}
});
});
2012-10-23 20:48:23 +02:00
});
});