aboutsummaryrefslogtreecommitdiffstats
path: root/view/js
diff options
context:
space:
mode:
Diffstat (limited to 'view/js')
-rw-r--r--view/js/main.js2
-rw-r--r--view/js/mod_register.js120
2 files changed, 88 insertions, 34 deletions
diff --git a/view/js/main.js b/view/js/main.js
index 16dcd9cfe..6c418b213 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -959,7 +959,7 @@ function liveUpdate(notify_id) {
var orgHeight = $("#region_2").height();
}
- if(page_cache.data && bParam_page == page_cache.page && page_cache.time > (Date.now() - 180000)) {
+ if(page_cache.data && bParam_page == page_cache.page) {
page_load = false;
scroll_next = false;
updateConvItems(update_mode,page_cache.data);
diff --git a/view/js/mod_register.js b/view/js/mod_register.js
index 6607579a2..1fc5ad2fa 100644
--- a/view/js/mod_register.js
+++ b/view/js/mod_register.js
@@ -1,56 +1,110 @@
$(document).ready(function() {
- $("#id_email").blur(function() {
- var zreg_email = $("#id_email").val();
- $.get("register/email_check.json?f=&email=" + encodeURIComponent(zreg_email), function(data) {
- $("#help_email").html(data.message);
- zFormError("#help_email",data.error);
+
+ typeof(window.tao) == 'undefined' ? window.tao = {} : '';
+ tao.zar = { vsn: '2.0.0', form: {}, msg: {} };
+ tao.zar.patano = /^d[0-9]{5,10}$/;
+ tao.zar.patema = /^[a-z0-9.-]{1,64}@[a-z0-9.-]{2,32}\.[a-z]{2,12}$/;
+
+ $('.register_date').each( function () {
+ var date = new Date($(this).data('utc'));
+ $(this).html(date.toLocaleString(undefined, {weekday: 'short', hour: 'numeric', minute: 'numeric'}));
+ });
+
+ $('#zar014').click( function () {
+ $('#zar015').toggle();
+ });
+
+ $('#id_invite_code').blur(function() {
+ if($('#id_invite_code').val() === '')
+ return;
+
+ $('#invite-spinner').show();
+ var zreg_invite = $('#id_invite_code').val();
+ $.get('register/invite_check.json?f=&invite_code=' + encodeURIComponent(zreg_invite),function(data) {
+ if(!data.error) {
+ $('#register-form input, #register-form button').removeAttr('disabled');
+ // email is always mandatory if using invite code
+ $('#help_email').removeClass('text-muted').addClass('text-danger').html(aStr['email_required']);
+ }
+ $('#invite-spinner').hide();
});
});
- $("#id_password").blur(function() {
- if(($("#id_password").val()).length < 6 ) {
- $("#help_password").html(aStr.pwshort);
- zFormError("#help_password", true);
+
+ $('#id_email').change(function() {
+ tao.zar.form.email = $('#id_email').val();
+
+ if (tao.zar.patema.test(tao.zar.form.email) == false ) {
+ $('#help_email').removeClass('text-muted').addClass('text-danger').html(aStr['email_not_valid']);
+ } else {
+ $.get('register/email_check.json?f=&email=' + encodeURIComponent(tao.zar.form.email), function(data) {
+ $('#help_email').removeClass('text-muted').addClass('text-danger').html(data.message);
+ });
+ }
+ });
+
+ $('#id_password').change(function() {
+ if(($('#id_password').val()).length < 6 ) {
+ $('#help_password').removeClass('text-muted').addClass('text-danger').html(aStr.pwshort);
+ zFormError('#help_password', true);
}
else {
- $("#help_password").html("");
- zFormError("#help_password", false);
+ $('#help_password').html('');
+ zFormError('#help_password', false);
+ $('#id_password2').focus();
+ $('#id_password2').val().length > 0 ? $('#id_password2').trigger('change') : '';
}
});
- $("#id_password2").blur(function() {
- if($("#id_password").val() != $("#id_password2").val()) {
- $("#help_password2").html(aStr.pwnomatch);
- zFormError("#help_password2", true);
+
+ $('#id_password2').change(function() {
+ if($('#id_password').val() != $('#id_password2').val()) {
+ $('#help_password2').removeClass('text-muted').addClass('text-danger').html(aStr.pwnomatch);
+ zFormError('#help_password2', true);
+ $('#id_password').focus();
}
else {
- $("#help_password2").html("");
- zFormError("#help_password2", false);
+ $('#help_password2').html('');
+ zFormError('#help_password2', false);
}
});
- $("#id_name").blur(function() {
- $("#name-spinner").show();
- var zreg_name = $("#id_name").val();
- $.get("new_channel/autofill.json?f=&name=" + encodeURIComponent(zreg_name),function(data) {
- $("#id_nickname").val(data);
+ $('#id_name').blur(function() {
+ if($('#id_name').val() == '')
+ return;
+
+ $('#name-spinner').fadeIn();
+ var zreg_name = $('#id_name').val();
+ $.get('new_channel/autofill.json?f=&name=' + encodeURIComponent(zreg_name),function(data) {
+ $('#id_nickname').val(data);
if(data.error) {
- $("#help_name").html("");
- zFormError("#help_name",data.error);
+ $('#help_name').html('');
+ zFormError('#help_name',data.error);
}
- $("#name-spinner").hide();
+ $('#name-spinner').fadeOut();
});
});
- $("#id_nickname").blur(function() {
- $("#nick-spinner").show();
- var zreg_nick = $("#id_nickname").val();
- $.get("new_channel/checkaddr.json?f=&nick=" + encodeURIComponent(zreg_nick),function(data) {
- $("#id_nickname").val(data);
+ $('#id_nickname').blur(function() {
+ if($('#id_name').val() == '')
+ return;
+
+ $('#nick-spinner').fadeIn();
+ $('#nick-hub').fadeOut();
+ var zreg_nick = $('#id_nickname').val();
+ $.get('new_channel/checkaddr.json?f=&nick=' + encodeURIComponent(zreg_nick),function(data) {
+ $('#id_nickname').val(data);
if(data.error) {
- $("#help_nickname").html("");
- zFormError("#help_nickname",data.error);
+ $('#help_nickname').html('');
+ zFormError('#help_nickname',data.error);
}
- $("#nick-spinner").hide();
+ $('#nick-spinner').fadeOut();
+ $('#nick-hub').fadeIn();
});
});
+ $('#register-form').submit(function(e) {
+ if ($('.zform-error').length > 0) {
+ e.preventDefault();
+ return false;
+ }
+ });
});