You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

password.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * Password plugin script
  3. *
  4. * @licstart The following is the entire license notice for the
  5. * JavaScript code in this file.
  6. *
  7. * Copyright (c) 2012-2014, The Roundcube Dev Team
  8. *
  9. * The JavaScript code in this page is free software: you can redistribute it
  10. * and/or modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation, either version 3 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * @licend The above is the entire license notice
  15. * for the JavaScript code in this file.
  16. */
  17. window.rcmail && rcmail.addEventListener('init', function(evt) {
  18. if (rcmail.env.password_disabled) {
  19. $('#password-form input').prop('disabled', true);
  20. // reload page after ca. 3 minutes
  21. rcmail.reload(3 * 60 * 1000 - 2000);
  22. return;
  23. }
  24. // register command handler
  25. rcmail.register_command('plugin.password-save', function() {
  26. var input_curpasswd = rcube_find_object('_curpasswd'),
  27. input_newpasswd = rcube_find_object('_newpasswd'),
  28. input_confpasswd = rcube_find_object('_confpasswd');
  29. if (input_curpasswd && input_curpasswd.value == '') {
  30. alert(rcmail.get_label('nocurpassword', 'password'));
  31. input_curpasswd.focus();
  32. }
  33. else if (input_newpasswd && input_newpasswd.value == '') {
  34. alert(rcmail.get_label('nopassword', 'password'));
  35. input_newpasswd.focus();
  36. }
  37. else if (input_confpasswd && input_confpasswd.value == '') {
  38. alert(rcmail.get_label('nopassword', 'password'));
  39. input_confpasswd.focus();
  40. }
  41. else if (input_newpasswd && input_confpasswd && input_newpasswd.value != input_confpasswd.value) {
  42. alert(rcmail.get_label('passwordinconsistency', 'password'));
  43. input_newpasswd.focus();
  44. }
  45. else {
  46. rcmail.gui_objects.passform.submit();
  47. }
  48. }, true);
  49. $('input:not(:hidden):first').focus();
  50. });