diff options
author | Clark Tomlinson <fallen013@gmail.com> | 2015-04-22 10:41:47 -0400 |
---|---|---|
committer | Clark Tomlinson <fallen013@gmail.com> | 2015-04-22 11:07:56 -0400 |
commit | e3ec1a8bb8b913bd176b76bd59f8c0c209aff5cb (patch) | |
tree | 80fe9cc29b5090aa7aac6584dbcdfeb72353f502 /apps/encryption/js/settings-admin.js | |
parent | 1747117edfd337d50075e3612ca56cac18b96f5a (diff) | |
download | nextcloud-server-e3ec1a8bb8b913bd176b76bd59f8c0c209aff5cb.tar.gz nextcloud-server-e3ec1a8bb8b913bd176b76bd59f8c0c209aff5cb.zip |
remove status's and adjust js
Diffstat (limited to 'apps/encryption/js/settings-admin.js')
-rw-r--r-- | apps/encryption/js/settings-admin.js | 65 |
1 files changed, 36 insertions, 29 deletions
diff --git a/apps/encryption/js/settings-admin.js b/apps/encryption/js/settings-admin.js index bb539f6a4e2..fdc53c52152 100644 --- a/apps/encryption/js/settings-admin.js +++ b/apps/encryption/js/settings-admin.js @@ -7,52 +7,59 @@ * See the COPYING-README file. */ -$(document).ready(function(){ +$(document).ready(function () { - $( 'input:radio[name="adminEnableRecovery"]' ).change( - function() { - var recoveryStatus = $( this ).val(); - var oldStatus = (1+parseInt(recoveryStatus, 10)) % 2; - var recoveryPassword = $( '#encryptionRecoveryPassword' ).val(); - var confirmPassword = $( '#repeatEncryptionRecoveryPassword' ).val(); + $('input:radio[name="adminEnableRecovery"]').change( + function () { + var recoveryStatus = $(this).val(); + var oldStatus = (1 + parseInt(recoveryStatus)) % 2; + var recoveryPassword = $('#encryptionRecoveryPassword').val(); + var confirmPassword = $('#repeatEncryptionRecoveryPassword').val(); OC.msg.startSaving('#encryptionSetRecoveryKey .msg'); $.post( OC.generateUrl('/apps/encryption/ajax/adminRecovery'), - { adminEnableRecovery: recoveryStatus, + { + adminEnableRecovery: recoveryStatus, recoveryPassword: recoveryPassword, - confirmPassword: confirmPassword }, - function( result ) { - OC.msg.finishedSaving('#encryptionSetRecoveryKey .msg', result); - if (result.status === "error") { - $('input:radio[name="adminEnableRecovery"][value="'+oldStatus.toString()+'"]') - .attr("checked", "true"); + confirmPassword: confirmPassword + } + ).done(function (data) { + OC.msg.finishedSuccess('#encryptionSetRecoveryKey .msg', data.data.message); + + if (recoveryStatus === "0") { + $('p[name="changeRecoveryPasswordBlock"]').addClass("hidden"); } else { - if (recoveryStatus === "0") { - $('p[name="changeRecoveryPasswordBlock"]').addClass("hidden"); - } else { - $('input:password[name="changeRecoveryPassword"]').val(""); - $('p[name="changeRecoveryPasswordBlock"]').removeClass("hidden"); - } + $('input:password[name="changeRecoveryPassword"]').val(""); + $('p[name="changeRecoveryPasswordBlock"]').removeClass("hidden"); } - } - ); + }) + .fail(function (jqXHR) { + $('input:radio[name="adminEnableRecovery"][value="' + oldStatus.toString() + '"]').attr("checked", "true"); + OC.msg.finishedError('#encryptionSetRecoveryKey .msg', JSON.parse(jqXHR.responseText).data.message); + }); } ); // change recovery password - $('button:button[name="submitChangeRecoveryKey"]').click(function() { + $('button:button[name="submitChangeRecoveryKey"]').click(function () { var oldRecoveryPassword = $('#oldEncryptionRecoveryPassword').val(); var newRecoveryPassword = $('#newEncryptionRecoveryPassword').val(); var confirmNewPassword = $('#repeatedNewEncryptionRecoveryPassword').val(); OC.msg.startSaving('#encryptionChangeRecoveryKey .msg'); $.post( - OC.generateUrl('/apps/encryption/ajax/changeRecoveryPassword'), - { oldPassword: oldRecoveryPassword, newPassword: newRecoveryPassword, confirmPassword: confirmNewPassword }, - function( data ) { - OC.msg.finishedSaving('#encryptionChangeRecoveryKey .msg', data); - } - ); + OC.generateUrl('/apps/encryption/ajax/changeRecoveryPassword'), + { + oldPassword: oldRecoveryPassword, + newPassword: newRecoveryPassword, + confirmPassword: confirmNewPassword + } + ).done(function (data) { + OC.msg.finishedSuccess('#encryptionChangeRecoveryKey .msg', data.data.message); + }) + .fail(function (jqXHR) { + OC.msg.finishedError('#encryptionChangeRecoveryKey .msg', JSON.parse(jqXHR.responseText).data.message); + }); }); }); |