settings-personal.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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.filePath( 'files_encryption', 'ajax', 'updatePrivateKeyPassword.php' )
  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. // Hide feedback messages in case they're already visible
  27. $('#recoveryEnabledSuccess').hide();
  28. $('#recoveryEnabledError').hide();
  29. var recoveryStatus = $( this ).val();
  30. $.post(
  31. OC.filePath( 'files_encryption', 'ajax', 'userrecovery.php' )
  32. , { userEnableRecovery: recoveryStatus }
  33. , function( data ) {
  34. if ( data.status == "success" ) {
  35. $('#recoveryEnabledSuccess').show();
  36. } else {
  37. $('#recoveryEnabledError').show();
  38. }
  39. }
  40. );
  41. // Ensure page is not reloaded on form submit
  42. return false;
  43. }
  44. );
  45. $("#encryptAll").click(
  46. function(){
  47. // Hide feedback messages in case they're already visible
  48. $('#encryptAllSuccess').hide();
  49. $('#encryptAllError').hide();
  50. var userPassword = $( '#userPassword' ).val();
  51. var encryptAll = $( '#encryptAll' ).val();
  52. $.post(
  53. OC.filePath( 'files_encryption', 'ajax', 'encryptall.php' )
  54. , { encryptAll: encryptAll, userPassword: userPassword }
  55. , function( data ) {
  56. if ( data.status == "success" ) {
  57. $('#encryptAllSuccess').show();
  58. } else {
  59. $('#encryptAllError').show();
  60. }
  61. }
  62. );
  63. // Ensure page is not reloaded on form submit
  64. return false;
  65. }
  66. );
  67. // update private key password
  68. $('input:password[name="changePrivateKeyPassword"]').keyup(function(event) {
  69. var oldPrivateKeyPassword = $('input:password[id="oldPrivateKeyPassword"]').val();
  70. var newPrivateKeyPassword = $('input:password[id="newPrivateKeyPassword"]').val();
  71. if (newPrivateKeyPassword !== '' && oldPrivateKeyPassword !== '' ) {
  72. $('button:button[name="submitChangePrivateKeyPassword"]').removeAttr("disabled");
  73. if(event.which === 13) {
  74. updatePrivateKeyPasswd();
  75. }
  76. } else {
  77. $('button:button[name="submitChangePrivateKeyPassword"]').attr("disabled", "true");
  78. }
  79. });
  80. $('button:button[name="submitChangePrivateKeyPassword"]').click(function() {
  81. updatePrivateKeyPasswd();
  82. });
  83. });