settings-personal.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * Copyright (c) 2013, Sam Tuke <samtuke@owncloud.com>
  3. * This file is licensed under the Affero General Public License version 3 or later.
  4. * See the COPYING-README file.
  5. */
  6. function updatePrivateKeyPasswd() {
  7. var oldPrivateKeyPassword = $('input:password[id="oldPrivateKeyPassword"]').val();
  8. var newPrivateKeyPassword = $('input:password[id="newPrivateKeyPassword"]').val();
  9. OC.msg.startSaving('#encryption .msg');
  10. $.post(
  11. OC.generateUrl('/apps/encryption/ajax/updatePrivateKeyPassword')
  12. , { oldPassword: oldPrivateKeyPassword, newPassword: newPrivateKeyPassword }
  13. , function( data ) {
  14. if (data.status === "error") {
  15. OC.msg.finishedSaving('#encryption .msg', data);
  16. } else {
  17. OC.msg.finishedSaving('#encryption .msg', data);
  18. }
  19. }
  20. );
  21. }
  22. $(document).ready(function(){
  23. // Trigger ajax on recoveryAdmin status change
  24. $( 'input:radio[name="userEnableRecovery"]' ).change(
  25. function() {
  26. var recoveryStatus = $( this ).val();
  27. OC.msg.startAction('#userEnableRecovery .msg', 'Updating recovery keys. This can take some time...');
  28. $.post(
  29. OC.generateUrl('/apps/encryption/ajax/userSetRecovery')
  30. , { userEnableRecovery: recoveryStatus }
  31. , function( data ) {
  32. OC.msg.finishedAction('#userEnableRecovery .msg', data);
  33. }
  34. );
  35. // Ensure page is not reloaded on form submit
  36. return false;
  37. }
  38. );
  39. // update private key password
  40. $('input:password[name="changePrivateKeyPassword"]').keyup(function(event) {
  41. var oldPrivateKeyPassword = $('input:password[id="oldPrivateKeyPassword"]').val();
  42. var newPrivateKeyPassword = $('input:password[id="newPrivateKeyPassword"]').val();
  43. if (newPrivateKeyPassword !== '' && oldPrivateKeyPassword !== '' ) {
  44. $('button:button[name="submitChangePrivateKeyPassword"]').removeAttr("disabled");
  45. if(event.which === 13) {
  46. updatePrivateKeyPasswd();
  47. }
  48. } else {
  49. $('button:button[name="submitChangePrivateKeyPassword"]').attr("disabled", "true");
  50. }
  51. });
  52. $('button:button[name="submitChangePrivateKeyPassword"]').click(function() {
  53. updatePrivateKeyPasswd();
  54. });
  55. });