edit_user.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. applyRandomString = function (min_length = 16) {
  2. $('input[name=v_password]').val(randomString2(min_length));
  3. App.Actions.WEB.update_password_meter();
  4. };
  5. App.Actions.WEB.update_password_meter = function () {
  6. var password = $('input[name="v_password"]').val();
  7. var min_small = new RegExp(/^(?=.*[a-z]).+$/);
  8. var min_cap = new RegExp(/^(?=.*[A-Z]).+$/);
  9. var min_num = new RegExp(/^(?=.*\d).+$/);
  10. var min_length = 8;
  11. var score = 0;
  12. if (password.length >= min_length) {
  13. score = score + 1;
  14. }
  15. if (min_small.test(password)) {
  16. score = score + 1;
  17. }
  18. if (min_cap.test(password)) {
  19. score = score + 1;
  20. }
  21. if (min_num.test(password)) {
  22. score = score + 1;
  23. }
  24. $('.password-meter').val(score);
  25. };
  26. App.Listeners.WEB.keypress_v_password = function () {
  27. var ref = $('input[name="v_password"]');
  28. ref.bind('keypress input', function (evt) {
  29. clearTimeout(window.frp_usr_tmt);
  30. window.frp_usr_tmt = setTimeout(function () {
  31. var elm = $(evt.target);
  32. App.Actions.WEB.update_password_meter(elm, $(elm).val());
  33. }, 100);
  34. });
  35. };
  36. App.Listeners.WEB.keypress_v_password();
  37. $(document).ready(function () {
  38. $('.js-add-ns-button').click(function () {
  39. var n = $('input[name^=v_ns]').length;
  40. if (n < 8) {
  41. var t = $($('input[name=v_ns1]').parents('div')[0]).clone(true, true);
  42. t.find('input').attr({ value: '', name: 'v_ns' + (n + 1) });
  43. t.find('span').show();
  44. $('.js-add-ns').before(t);
  45. }
  46. if (n == 7) {
  47. $('.js-add-ns').addClass('u-hidden');
  48. }
  49. });
  50. $('.js-remove-ns').click(function () {
  51. $(this).parents('div')[0].remove();
  52. $('input[name^=v_ns]').each(function (i, ns) {
  53. $(ns).attr({ name: 'v_ns' + (i + 1) });
  54. i < 2 ? $(ns).parent().find('span').hide() : $(ns).parent().find('span').show();
  55. });
  56. $('.js-add-ns').removeClass('u-hidden');
  57. });
  58. $('input[name^=v_ns]').each(function (i, ns) {
  59. i < 2 ? $(ns).parent().find('span').hide() : $(ns).parent().find('span').show();
  60. });
  61. });