edit_user.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. randomString = function(min_length = 16) {
  2. $('input[name=v_password]').val(randomString2(min_length));
  3. App.Actions.WEB.update_v_password();
  4. }
  5. App.Actions.WEB.update_v_password = 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) { score = score + 1; }
  13. if(min_small.test(password)) { score = score + 1;}
  14. if(min_cap.test(password)) { score = score + 1;}
  15. if(min_num.test(password)) { score = score+ 1; }
  16. $('#meter').val(score);
  17. }
  18. App.Listeners.WEB.keypress_v_password = function() {
  19. var ref = $('input[name="v_password"]');
  20. ref.bind('keypress input', function(evt) {
  21. clearTimeout(window.frp_usr_tmt);
  22. window.frp_usr_tmt = setTimeout(function() {
  23. var elm = $(evt.target);
  24. App.Actions.WEB.update_v_password(elm, $(elm).val());
  25. }, 100);
  26. });
  27. }
  28. App.Listeners.WEB.keypress_v_password();
  29. $(document).ready(function(){
  30. $('.add-ns-button').click(function(){
  31. var n = $('input[name^=v_ns]').length;
  32. if(n < 8){
  33. var t = $($('input[name=v_ns1]').parents('tr')[0]).clone(true, true);
  34. t.find('input').attr({value:'', name:'v_ns'+(n+1)});
  35. t.find('span').show();
  36. $('tr.add-ns').before(t);
  37. }
  38. if( n == 7 ) {
  39. $('.add-ns').hide();
  40. }
  41. });
  42. $('.remove-ns').click(function(){
  43. $(this).parents('tr')[0].remove();
  44. $('input[name^=v_ns]').each(function(i, ns){
  45. $(ns).attr({name: 'v_ns'+(i+1)});
  46. i < 2 ? $(ns).parent().find('span').hide() : $(ns).parent().find('span').show();
  47. });
  48. $('.add-ns').show();
  49. });
  50. $('input[name^=v_ns]').each(function(i, ns){
  51. i < 2 ? $(ns).parent().find('span').hide() : $(ns).parent().find('span').show();
  52. });
  53. });