diff options
| author | timb <timb@mb.local> | 2010-04-09 19:16:50 -0700 |
|---|---|---|
| committer | timb <timb@mb.local> | 2010-04-09 19:16:50 -0700 |
| commit | 99c8ae25e4bc2b095f956fdc7a90f66c55014e02 (patch) | |
| tree | fc4a099b2679e4afc3700fe6683f528c2af062a8 /static/js | |
| parent | 362e6c8760711626da079611aa457aa00ce4b5b7 (diff) | |
| parent | 956291711de6afb17137160a67ac710be0ace1e1 (diff) | |
Merge branch 'master' of ssh://dump.fm/pichat/repo
Diffstat (limited to 'static/js')
| -rwxr-xr-x | static/js/register.js | 91 |
1 files changed, 5 insertions, 86 deletions
diff --git a/static/js/register.js b/static/js/register.js index 31d32e5..30e221f 100755 --- a/static/js/register.js +++ b/static/js/register.js @@ -1,94 +1,24 @@ -function validateNick(n) { - if (n.length <= 2) { - return "BAD_NICK_LENGTH"; - } -} - - -function submitRegistration() { - var nick = $('#nickInput').val(); - var email = $('#emailInput').val(); - var password = $('#passwordInput').val() || "";function validateNick(n) { - if (n.length <= 2) { - return "BAD_NICK_LENGTH"; - } -} - - function submitRegistration() { var nick = $('#nickInput').val(); var email = $('#emailInput').val(); var password = $('#passwordInput').val() || ""; - + var password2 = $('#passwordInput2').val() || ""; if (nick.length < 3 || nick.length > 12) { alert("Nicks must be between 3 and 12 characters long."); return; - } else if (password.length < 5) { - alert("Password must be at least 5 characters long."); - return; } - - - var hash = hex_sha1(nick + '$' + password + '$dumpfm'); - var onSuccess = function() { - if (typeof pageTracker !== 'undefined') { - pageTracker._trackEvent('User', 'Register', nick); - } - location.href = "/"; - }; - - var onError = function(resp) { - var respText = resp.responseText ? resp.responseText.trim() : false; - if (respText == 'NICK_TAKEN') { - alert("That nick is already taken! Please choose another."); - } else if (respText == 'NICK_INVALID_CHARS') { - alert("Nicks can only contain letters and numbers."); - } else { - alert("Unable to register!"); - } - }; - - $.ajax({ - type: 'POST', - timeout: 5000, - url: 'submit-registration', - data: {'nick': nick, 'email': email, 'hash': hash }, - cache: false, - dataType: 'json', - success: onSuccess, - error: onError - - }); -} - -function initRegister() { - $('#submit').click(submitRegistration); -} - -function handleMsgError(resp) { - var respText = resp.responseText ? resp.responseText.trim() : false; - if (respText == 'UNKNOWN_USER') { - alert("Can't send message! Please login."); - } else if (respText) { - alert("Cannot send message! (" + respText + ")"); - } else { - alert("Cannot send message!"); + if (password != password2) { + alert("Passwords must match!"); + return; } -} - - if (nick.length < 3 || nick.length > 12) { - alert("Nicks must be between 3 and 12 characters long."); - return; - } else if (password.length < 5) { + if (password.length < 5) { alert("Password must be at least 5 characters long."); return; } - - var hash = hex_sha1(nick + '$' + password + '$dumpfm'); var onSuccess = function() { if (typeof pageTracker !== 'undefined') { @@ -123,15 +53,4 @@ function handleMsgError(resp) { function initRegister() { $('#submit').click(submitRegistration); -} - -function handleMsgError(resp) { - var respText = resp.responseText ? resp.responseText.trim() : false; - if (respText == 'UNKNOWN_USER') { - alert("Can't send message! Please login."); - } else if (respText) { - alert("Cannot send message! (" + respText + ")"); - } else { - alert("Cannot send message!"); - } }
\ No newline at end of file |
