diff --git a/apps/encryption/js/encryption.js b/apps/encryption/js/encryption.js index c02b4d74ae..7ed49f7731 100644 --- a/apps/encryption/js/encryption.js +++ b/apps/encryption/js/encryption.js @@ -5,25 +5,23 @@ * See the COPYING-README file. */ +if (!OC.Encryption) { + OC.Encryption = {}; +} + /** * @namespace * @memberOf OC */ -OC.Encryption= { - MIGRATION_OPEN: 0, - MIGRATION_COMPLETED: 1, - MIGRATION_IN_PROGRESS: -1, - - +OC.Encryption = { displayEncryptionWarning: function () { - if (!OC.Notification.isHidden()) { return; } $.get( - OC.generateUrl('/apps/encryption/ajax/getStatus') - , function( result ) { + OC.generateUrl('/apps/encryption/ajax/getStatus'), + function (result) { if (result.status === "success") { OC.Notification.show(result.data.message); } @@ -31,7 +29,6 @@ OC.Encryption= { ); } }; - $(document).ready(function() { // wait for other apps/extensions to register their event handlers and file actions // in the "ready" clause diff --git a/apps/encryption/js/settings-admin.js b/apps/encryption/js/settings-admin.js index 36765adf3e..bb539f6a4e 100644 --- a/apps/encryption/js/settings-admin.js +++ b/apps/encryption/js/settings-admin.js @@ -12,17 +12,20 @@ $(document).ready(function(){ $( 'input:radio[name="adminEnableRecovery"]' ).change( function() { var recoveryStatus = $( this ).val(); - var oldStatus = (1+parseInt(recoveryStatus)) % 2; + var oldStatus = (1+parseInt(recoveryStatus, 10)) % 2; var recoveryPassword = $( '#encryptionRecoveryPassword' ).val(); var confirmPassword = $( '#repeatEncryptionRecoveryPassword' ).val(); OC.msg.startSaving('#encryptionSetRecoveryKey .msg'); $.post( - OC.generateUrl('/apps/encryption/ajax/adminRecovery') - , { adminEnableRecovery: recoveryStatus, recoveryPassword: recoveryPassword, confirmPassword: confirmPassword } - , function( result ) { + OC.generateUrl('/apps/encryption/ajax/adminRecovery'), + { 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"); + $('input:radio[name="adminEnableRecovery"][value="'+oldStatus.toString()+'"]') + .attr("checked", "true"); } else { if (recoveryStatus === "0") { $('p[name="changeRecoveryPasswordBlock"]').addClass("hidden"); @@ -44,9 +47,9 @@ $(document).ready(function(){ 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.generateUrl('/apps/encryption/ajax/changeRecoveryPassword'), + { oldPassword: oldRecoveryPassword, newPassword: newRecoveryPassword, confirmPassword: confirmNewPassword }, + function( data ) { OC.msg.finishedSaving('#encryptionChangeRecoveryKey .msg', data); } ); diff --git a/apps/encryption/js/settings-personal.js b/apps/encryption/js/settings-personal.js index 68609877c0..e36f10a244 100644 --- a/apps/encryption/js/settings-personal.js +++ b/apps/encryption/js/settings-personal.js @@ -4,20 +4,26 @@ * See the COPYING-README file. */ -function updatePrivateKeyPasswd() { - var oldPrivateKeyPassword = $('input:password[id="oldPrivateKeyPassword"]').val(); - var newPrivateKeyPassword = $('input:password[id="newPrivateKeyPassword"]').val(); - OC.msg.startSaving('#encryption .msg'); - $.post( - OC.generateUrl('/apps/encryption/ajax/updatePrivateKeyPassword'), - { oldPassword: oldPrivateKeyPassword, newPassword: newPrivateKeyPassword } - ).success(function(response) { - OC.msg.finishedSuccess('#encryption .msg', response.message); - }).fail(function(response) { - OC.msg.finishedError('#encryption .msg', response.responseJSON.message); - }); +if (!OC.Encryption) { + OC.Encryption = {}; } +OC.Encryption = { + updatePrivateKeyPassword: function() { + var oldPrivateKeyPassword = $('input:password[id="oldPrivateKeyPassword"]').val(); + var newPrivateKeyPassword = $('input:password[id="newPrivateKeyPassword"]').val(); + OC.msg.startSaving('#encryption .msg'); + $.post( + OC.generateUrl('/apps/encryption/ajax/updatePrivateKeyPassword'), + {oldPassword: oldPrivateKeyPassword, newPassword: newPrivateKeyPassword} + ).success(function (response) { + OC.msg.finishedSuccess('#encryption .msg', response.message); + }).fail(function (response) { + OC.msg.finishedError('#encryption .msg', response.responseJSON.message); + }); + } +}; + $(document).ready(function(){ // Trigger ajax on recoveryAdmin status change @@ -26,9 +32,9 @@ $(document).ready(function(){ var recoveryStatus = $( this ).val(); OC.msg.startAction('#userEnableRecovery .msg', 'Updating recovery keys. This can take some time...'); $.post( - OC.generateUrl('/apps/encryption/ajax/userSetRecovery') - , { userEnableRecovery: recoveryStatus } - , function( data ) { + OC.generateUrl('/apps/encryption/ajax/userSetRecovery'), + { userEnableRecovery: recoveryStatus }, + function( data ) { OC.msg.finishedAction('#userEnableRecovery .msg', data); } ); @@ -45,7 +51,7 @@ $(document).ready(function(){ if (newPrivateKeyPassword !== '' && oldPrivateKeyPassword !== '' ) { $('button:button[name="submitChangePrivateKeyPassword"]').removeAttr("disabled"); if(event.which === 13) { - updatePrivateKeyPasswd(); + OC.Encryption.updatePrivateKeyPassword(); } } else { $('button:button[name="submitChangePrivateKeyPassword"]').attr("disabled", "true"); @@ -53,7 +59,7 @@ $(document).ready(function(){ }); $('button:button[name="submitChangePrivateKeyPassword"]').click(function() { - updatePrivateKeyPasswd(); + OC.Encryption.updatePrivateKeyPassword(); }); }); diff --git a/settings/js/personal.js b/settings/js/personal.js index 165b55bcda..f3fcf614bf 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -330,8 +330,9 @@ $(document).ready(function () { $('#sslCertificate tbody').append(row); }, - fail: function (e, data) { - OC.Notification.showTemporary(t('settings', 'An error occured. Please upload an ASCII-encoded PEM certificate.')); + fail: function () { + OC.Notification.showTemporary( + t('settings', 'An error occurred. Please upload an ASCII-encoded PEM certificate.')); } }); @@ -340,8 +341,9 @@ $(document).ready(function () { }); }); -OC.Encryption = { -}; +if (!OC.Encryption) { + OC.Encryption = {}; +} OC.Encryption.msg = { start: function (selector, msg) {