diff options
| author | dumpfmprod <dumpfmprod@ubuntu.(none)> | 2010-03-26 18:23:03 -0400 |
|---|---|---|
| committer | dumpfmprod <dumpfmprod@ubuntu.(none)> | 2010-03-26 18:23:03 -0400 |
| commit | b18a8081bd5096a5bafdce252256b94f601f2f94 (patch) | |
| tree | db7697a4408b5394307515bb27bafbd1de49347f /static/js/register.js | |
| parent | 9d66e591710e593ea035e765b955367957afb6e3 (diff) | |
Added new static content
Diffstat (limited to 'static/js/register.js')
| -rwxr-xr-x | static/js/register.js | 74 |
1 files changed, 68 insertions, 6 deletions
diff --git a/static/js/register.js b/static/js/register.js index c87eadc..31d32e5 100755 --- a/static/js/register.js +++ b/static/js/register.js @@ -4,15 +4,22 @@ function validateNick(n) { } } -// HOPE NO HACKERS ARE READING THIS :o -var ValidCodes = ['WAXWANYE23', - 'HOTDUMPING5000','RHIZOME','VIP666','HEATNAP','anamanaguchi',]; + +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 code = $('#codeInput').val(); + if (nick.length < 3 || nick.length > 12) { alert("Nicks must be between 3 and 12 characters long."); @@ -22,11 +29,66 @@ function submitRegistration() { return; } - if ($.inArray(code.toUpperCase(), ValidCodes) == -1) { - alert("Bad registration code! Try again dude...." ); + + + 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 (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') { |
