Commit 27dec86c authored by JC Brand's avatar JC Brand

Clear connect form fields so that it cannot be resubmitted

parent d937d32d
...@@ -659,7 +659,7 @@ ...@@ -659,7 +659,7 @@
ev.preventDefault(); ev.preventDefault();
var $input = $(ev.target).find('input'); var $input = $(ev.target).find('input');
var jid = $input.val(); var jid = $input.val();
if (jid.indexOf("@") < 0) { if (! jid) {
// this is not a valid JID // this is not a valid JID
$input.addClass('error'); $input.addClass('error');
return; return;
...@@ -1876,11 +1876,33 @@ ...@@ -1876,11 +1876,33 @@
authenticate: function (ev) { authenticate: function (ev) {
ev.preventDefault(); ev.preventDefault();
var $form = $(ev.target), var $form = $(ev.target),
bosh_service_url = $form.find('input#bosh_service_url').val(), $bsu_input = $form.find('input#bosh_service_url'),
jid = $form.find('input#jid').val(), bosh_service_url = $bsu_input.val(),
password = $form.find('input#password').val(), $jid_input = $form.find('input#jid'),
jid = $jid_input.val(),
$pw_input = $form.find('input#password'),
password = $pw_input.val(),
connection = new Strophe.Connection(bosh_service_url); connection = new Strophe.Connection(bosh_service_url);
var errors = false;
if (! jid) {
errors = true;
$jid_input.addClass('error');
}
if (! password) {
errors = true;
$pw_input.addClass('error');
}
if (! bosh_service_url) {
errors = true;
$bsu_input.addClass('error');
}
if (errors) { return; }
// Clear the form's fields, so that it can't be submitted twice
$bsu_input.val('');
$jid_input.val('');
$pw_input.val('');
connection.connect(jid, password, $.proxy(function (status) { connection.connect(jid, password, $.proxy(function (status) {
if (status === Strophe.Status.CONNECTED) { if (status === Strophe.Status.CONNECTED) {
console.log('Connected'); console.log('Connected');
...@@ -1955,8 +1977,9 @@ ...@@ -1955,8 +1977,9 @@
} }
converse.onConnected = function (connection) { converse.onConnected = function (connection) {
this.animate = true; // Use animations
this.connection = connection; this.connection = connection;
this.animate = true; // Use animations
this.connection.xmlInput = function (body) { console.log(body); }; this.connection.xmlInput = function (body) { console.log(body); };
this.connection.xmlOutput = function (body) { console.log(body); }; this.connection.xmlOutput = function (body) { console.log(body); };
this.bare_jid = Strophe.getBareJidFromJid(this.connection.jid); this.bare_jid = Strophe.getBareJidFromJid(this.connection.jid);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment