Skip to content
Snippets Groups Projects
Commit 9ddc9429 authored by Lloyd Hilaiel's avatar Lloyd Hilaiel
Browse files

implement live email checking as you type

parent 90f66c89
No related branches found
No related tags found
No related merge requests found
......@@ -9,8 +9,7 @@ exports.have_email = function(req, resp) {
console.log("have_email for " + email + ": " + haveit);
// 200 means we have the email, 404 means no
resp.writeHead(haveit ? 200 : 404, {"Content-Type": "application/json"});
resp.writeHead(200, {"Content-Type": "application/json"});
resp.write(JSON.stringify(haveit));
resp.end();
};
\ No newline at end of file
......@@ -70,10 +70,6 @@
<form id="identities" name="identities">
</form>
</div>
<div id="logo"><img src="mozilla.png"></div>
</div>
<div id="create_dialog" class="dialog">
zxcvzxcvHI MOM
</div>
<div id="bottom-bar">
<button id="back">Go Back</button>
......
......@@ -125,6 +125,7 @@
// check the email address
var email = $("#create_dialog input:eq(0)").val();
$("#create_dialog div.note:eq(0)").empty();
if (typeof email === 'string' && email.length) {
var valid = checkedEmails[email];
if (typeof valid === 'boolean') {
......@@ -139,19 +140,23 @@
if (emailCheckState !== 'querying') {
if (emailCheckState) window.clearTimeout(emailCheckState);
emailCheckState = setTimeout(function() {
// XXX: this is where we should actually bounce off the server and enter the 'querying' state
// for now, we just call it valid
checkedEmails[nextEmailToCheck] = true;
emailCheckState = undefined;
checkInput();
}, 500);
emailCheckState = 'querying';
var checkingNow = nextEmailToCheck;
// bounce off the server and enter the 'querying' state
$.get('/wsapi/have_email?email=' + encodeURIComponent(checkingNow), null,
function(data, textStatus, jqXHR) {
checkedEmails[checkingNow] = !JSON.parse(data);
emailCheckState = undefined;
checkInput();
});
}, 700);
} else {
$("#create_dialog div.note:eq(0)").html($('<span class="warning"/>').text("Checking address"));
}
nextEmailToCheck = email;
$("#submit").addClass("disabled");
$("#create_dialog div.note:eq(0)").html($('<span class="warning"/>').text("Checking address"));
}
} else {
$("#create_dialog div.note:eq(0)").empty();
$("#submit").addClass("disabled");
}
......@@ -228,7 +233,4 @@
});
}
});
$(".sitename").text("somesite.com");
runSignInDialog();
})();
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment