edit_user.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. function randomString() {
  2. var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
  3. var string_length = 10;
  4. var randomstring = '';
  5. for (var i = 0; i < string_length; i++) {
  6. var rnum = Math.floor(Math.random() * chars.length);
  7. randomstring += chars.substr(rnum, 1);
  8. }
  9. document.v_edit_user.v_password.value = randomstring;
  10. }
  11. $(document).ready(function(){
  12. $('.add-ns-button').click(function(){
  13. var n = $('input[name^=v_ns]').length;
  14. if(n < 8){
  15. var t = $($('input[name=v_ns1]').parents('tr')[0]).clone(true, true);
  16. t.find('input').attr({value:'', name:'v_ns'+(n+1)});
  17. t.find('span').show();
  18. $('tr.add-ns').before(t);
  19. }
  20. if( n == 7 ) {
  21. $('.add-ns').hide();
  22. }
  23. });
  24. $('.remove-ns').click(function(){
  25. $(this).parents('tr')[0].remove();
  26. $('input[name^=v_ns]').each(function(i, ns){
  27. $(ns).attr({name: 'v_ns'+(i+1)});
  28. i < 2 ? $(ns).parent().find('span').hide() : $(ns).parent().find('span').show();
  29. });
  30. $('.add-ns').show();
  31. });
  32. $('input[name^=v_ns]').each(function(i, ns){
  33. i < 2 ? $(ns).parent().find('span').hide() : $(ns).parent().find('span').show();
  34. });
  35. });