common.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * Switch account
  3. *
  4. * @param string $account
  5. * @param string $method
  6. * @access public
  7. * @return void
  8. */
  9. $(document).ready(function()
  10. {
  11. var verifyEncrypted = false;
  12. $('#verifyPassword').change(function(){verifyEncrypted = false})
  13. $('#verifyPassword').closest('form').find('#submit').click(function()
  14. {
  15. var password = $('input#verifyPassword').val().trim();
  16. var rand = $('input#verifyRand').val();
  17. if(!verifyEncrypted && password) $('input#verifyPassword').val(md5(md5(password) + rand));
  18. verifyEncrypted = true;
  19. });
  20. });
  21. function switchAccount(account, method)
  22. {
  23. if(method == 'dynamic')
  24. {
  25. link = createLink('user', method, 'account=' + account + '&period=' + period);
  26. }
  27. else if(method == 'todo')
  28. {
  29. link = createLink('user', method, 'account=' + account + '&type=' + type);
  30. }
  31. else
  32. {
  33. link = createLink('user', method, 'account=' + account);
  34. }
  35. location.href=link;
  36. }
  37. var mailsuffix = '';
  38. var account = [];
  39. function setDefaultEmail(num)
  40. {
  41. var mailValue = $('.email_' + num).val();
  42. if(mailValue.indexOf('@') <= 0) return;
  43. if(mailValue.indexOf('@') > 0) mailValue = mailValue.substr(mailValue.indexOf('@'));
  44. mailsuffix = mailValue;
  45. }
  46. function changeEmail(num)
  47. {
  48. var mailValue = $('.email_' + num).val();
  49. if(mailsuffix != '' && (mailValue == '' || mailValue == account[num] + mailsuffix)) $('.email_' + num).val($('.account_' + num).val() + mailsuffix);
  50. account[num] = $('.account_' + num).val();
  51. }
  52. function checkPassword(password)
  53. {
  54. $('#passwordStrength').html(password == '' ? '' : passwordStrengthList[computePasswordStrength(password)]);
  55. $('#passwordStrength').css('display', password == '' ? 'none' : 'table-cell');
  56. }