settings-admin.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * Copyright (c) 2013
  3. * Sam Tuke <samtuke@owncloud.com>
  4. * Robin Appelman <icewind1991@gmail.com>
  5. * Bjoern Schiessle <schiessle@owncloud.com>
  6. * This file is licensed under the Affero General Public License version 3 or later.
  7. * See the COPYING-README file.
  8. */
  9. $(document).ready(function(){
  10. $( 'input:radio[name="adminEnableRecovery"]' ).change(
  11. function() {
  12. var recoveryStatus = $( this ).val();
  13. var oldStatus = (1+parseInt(recoveryStatus)) % 2;
  14. var recoveryPassword = $( '#encryptionRecoveryPassword' ).val();
  15. var confirmPassword = $( '#repeatEncryptionRecoveryPassword' ).val();
  16. OC.msg.startSaving('#encryptionSetRecoveryKey .msg');
  17. $.post(
  18. OC.generateUrl('/apps/encryption/ajax/adminRecovery')
  19. , { adminEnableRecovery: recoveryStatus, recoveryPassword: recoveryPassword, confirmPassword: confirmPassword }
  20. , function( result ) {
  21. OC.msg.finishedSaving('#encryptionSetRecoveryKey .msg', result);
  22. if (result.status === "error") {
  23. $('input:radio[name="adminEnableRecovery"][value="'+oldStatus.toString()+'"]').attr("checked", "true");
  24. } else {
  25. if (recoveryStatus === "0") {
  26. $('p[name="changeRecoveryPasswordBlock"]').addClass("hidden");
  27. } else {
  28. $('input:password[name="changeRecoveryPassword"]').val("");
  29. $('p[name="changeRecoveryPasswordBlock"]').removeClass("hidden");
  30. }
  31. }
  32. }
  33. );
  34. }
  35. );
  36. // change recovery password
  37. $('button:button[name="submitChangeRecoveryKey"]').click(function() {
  38. var oldRecoveryPassword = $('#oldEncryptionRecoveryPassword').val();
  39. var newRecoveryPassword = $('#newEncryptionRecoveryPassword').val();
  40. var confirmNewPassword = $('#repeatedNewEncryptionRecoveryPassword').val();
  41. OC.msg.startSaving('#encryptionChangeRecoveryKey .msg');
  42. $.post(
  43. OC.generateUrl('/apps/encryption/ajax/changeRecoveryPassword')
  44. , { oldPassword: oldRecoveryPassword, newPassword: newRecoveryPassword, confirmPassword: confirmNewPassword }
  45. , function( data ) {
  46. OC.msg.finishedSaving('#encryptionChangeRecoveryKey .msg', data);
  47. }
  48. );
  49. });
  50. });