12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- $(function () {
- if (window.my_user_id >= 0)
- document.location.href = '/';
- $('#username_error').hide();
- $('#username_taken_error').hide();
- $('#password_error').hide();
- $('#captcha_error').hide();
- $('#signup_button').click(function () {
- api_unchecked('signup', {
- username: $('#username').val(),
- password: $('#password').val(),
- 'h-captcha-response': grecaptcha.getResponse()
- }, function (data) {
- if (data.error !== undefined) {
- switch (data.error) {
- case 'captcha check failed':
- show_hide('#captcha_error');
- break;
- case 'illegal username':
- show_hide('#username_error');
-
- delayed(function () {
- $('#username').toggleClass('is-danger');
- });
- break;
- case 'this username is already taken':
- show_hide('#username_taken_error');
-
- delayed(function () {
- $('#username').toggleClass('is-danger');
- });
- break;
- case 'illegal password':
- show_hide('#password_error');
-
- delayed(function () {
- $('#password').toggleClass('is-danger');
- });
- break;
- default:
- popup('danger', 'Error: ' + data.error);
- break;
- }
- $('#password').val('');
- grecaptcha.reset();
- return;
- }
- popup('primary', 'Successfully signed up!');
- setTimeout(function () {
- document.location.href = '/login';
- }, 1500);
- });
- });
- });
|