2012-02-23 01:20:46 +04:00
|
|
|
/**
|
2013-05-01 21:18:31 +04:00
|
|
|
* Copyright (c) 2013, Sam Tuke <samtuke@owncloud.com>, Robin Appelman
|
|
|
|
* <icewind1991@gmail.com>
|
2012-02-23 01:20:46 +04:00
|
|
|
* This file is licensed under the Affero General Public License version 3 or later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
2013-05-15 18:12:20 +04:00
|
|
|
OC.msg={
|
|
|
|
startSaving:function(selector){
|
|
|
|
$(selector)
|
|
|
|
.html( t('settings', 'Saving...') )
|
|
|
|
.removeClass('success')
|
|
|
|
.removeClass('error')
|
|
|
|
.stop(true, true)
|
|
|
|
.show();
|
|
|
|
},
|
|
|
|
finishedSaving:function(selector, data){
|
|
|
|
if( data.status === "success" ){
|
|
|
|
$(selector).html( data.data.message )
|
|
|
|
.addClass('success')
|
|
|
|
.stop(true, true)
|
|
|
|
.delay(3000)
|
|
|
|
.fadeOut(900);
|
|
|
|
}else{
|
|
|
|
$(selector).html( data.data.message ).addClass('error');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2012-02-23 01:20:46 +04:00
|
|
|
|
|
|
|
$(document).ready(function(){
|
2013-03-30 00:11:29 +04:00
|
|
|
// Trigger ajax on recoveryAdmin status change
|
2013-05-15 13:42:22 +04:00
|
|
|
var enabledStatus = $('#adminEnableRecovery').val();
|
|
|
|
|
|
|
|
$('input:password[name="recoveryPassword"]').keyup(function(event) {
|
|
|
|
var recoveryPassword = $( '#recoveryPassword' ).val();
|
|
|
|
var checkedButton = $('input:radio[name="adminEnableRecovery"]:checked').val();
|
|
|
|
var uncheckedValue = (1+parseInt(checkedButton)) % 2;
|
|
|
|
if (recoveryPassword != '' ) {
|
|
|
|
$('input:radio[name="adminEnableRecovery"][value="'+uncheckedValue.toString()+'"]').removeAttr("disabled");
|
|
|
|
} else {
|
|
|
|
$('input:radio[name="adminEnableRecovery"][value="'+uncheckedValue.toString()+'"]').attr("disabled", "true");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-03-30 00:11:29 +04:00
|
|
|
$( 'input:radio[name="adminEnableRecovery"]' ).change(
|
|
|
|
function() {
|
2013-05-01 21:18:31 +04:00
|
|
|
var recoveryStatus = $( this ).val();
|
2013-05-15 16:02:13 +04:00
|
|
|
var oldStatus = (1+parseInt(recoveryStatus)) % 2;
|
2013-05-04 18:14:38 +04:00
|
|
|
var recoveryPassword = $( '#recoveryPassword' ).val();
|
2013-05-15 13:42:22 +04:00
|
|
|
$.post(
|
|
|
|
OC.filePath( 'files_encryption', 'ajax', 'adminrecovery.php' )
|
|
|
|
, { adminEnableRecovery: recoveryStatus, recoveryPassword: recoveryPassword }
|
2013-05-22 20:01:18 +04:00
|
|
|
, function( result ) {
|
|
|
|
if (result.status === "error") {
|
|
|
|
OC.Notification.show(t('admin', result.data.message));
|
2013-05-15 16:02:13 +04:00
|
|
|
$('input:radio[name="adminEnableRecovery"][value="'+oldStatus.toString()+'"]').attr("checked", "true");
|
2013-05-15 18:12:20 +04:00
|
|
|
} else {
|
2013-05-22 20:01:18 +04:00
|
|
|
OC.Notification.hide();
|
|
|
|
if (recoveryStatus === "0") {
|
2013-05-15 18:12:20 +04:00
|
|
|
$('button:button[name="submitChangeRecoveryKey"]').attr("disabled", "true");
|
|
|
|
$('input:password[name="changeRecoveryPassword"]').attr("disabled", "true");
|
|
|
|
$('input:password[name="changeRecoveryPassword"]').val("");
|
|
|
|
} else {
|
|
|
|
$('input:password[name="changeRecoveryPassword"]').removeAttr("disabled");
|
|
|
|
}
|
2013-05-15 16:02:13 +04:00
|
|
|
}
|
2013-05-15 13:42:22 +04:00
|
|
|
}
|
|
|
|
);
|
2013-03-30 00:11:29 +04:00
|
|
|
}
|
|
|
|
);
|
2013-05-15 18:12:20 +04:00
|
|
|
|
2013-05-16 16:53:04 +04:00
|
|
|
// change recovery password
|
2013-05-15 18:12:20 +04:00
|
|
|
|
|
|
|
$('input:password[name="changeRecoveryPassword"]').keyup(function(event) {
|
|
|
|
var oldRecoveryPassword = $('input:password[id="oldRecoveryPassword"]').val();
|
|
|
|
var newRecoveryPassword = $('input:password[id="newRecoveryPassword"]').val();
|
|
|
|
if (newRecoveryPassword != '' && oldRecoveryPassword != '' ) {
|
|
|
|
$('button:button[name="submitChangeRecoveryKey"]').removeAttr("disabled");
|
|
|
|
} else {
|
|
|
|
$('button:button[name="submitChangeRecoveryKey"]').attr("disabled", "true");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$('button:button[name="submitChangeRecoveryKey"]').click(function() {
|
|
|
|
var oldRecoveryPassword = $('input:password[id="oldRecoveryPassword"]').val();
|
|
|
|
var newRecoveryPassword = $('input:password[id="newRecoveryPassword"]').val();
|
|
|
|
OC.msg.startSaving('#encryption .msg');
|
|
|
|
$.post(
|
|
|
|
OC.filePath( 'files_encryption', 'ajax', 'changeRecoveryPassword.php' )
|
|
|
|
, { oldPassword: oldRecoveryPassword, newPassword: newRecoveryPassword }
|
|
|
|
, function( data ) {
|
|
|
|
if (data.status == "error") {
|
|
|
|
OC.msg.finishedSaving('#encryption .msg', data);
|
|
|
|
} else {
|
|
|
|
OC.msg.finishedSaving('#encryption .msg', data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2013-03-30 00:11:29 +04:00
|
|
|
|
2013-05-24 01:56:31 +04:00
|
|
|
});
|