2012-08-02 08:39:30 +00:00
/ * *
* Copyright ( c ) 2012 , Bjoern Schiessle < schiessle @ owncloud . com >
* This file is licensed under the Affero General Public License version 3 or later .
* See the COPYING - README file .
* /
$ ( document ) . ready ( function ( ) {
$ ( 'input[name=encryption_mode]' ) . change ( function ( ) {
2012-08-09 10:19:51 +00:00
var prevmode = document . getElementById ( 'prev_encryption_mode' ) . value
2012-08-02 08:39:30 +00:00
var client = $ ( 'input[value="client"]:checked' ) . val ( )
, server = $ ( 'input[value="server"]:checked' ) . val ( )
, user = $ ( 'input[value="user"]:checked' ) . val ( )
, none = $ ( 'input[value="none"]:checked' ) . val ( )
2012-08-09 10:19:51 +00:00
if ( client ) {
$ . post ( OC . filePath ( 'files_encryption' , 'ajax' , 'mode.php' ) , { mode : 'client' } ) ;
if ( prevmode == 'server' ) {
OC . dialogs . info ( t ( 'encryption' , 'Please go to your owncloud client and change your encryption password to complete the conversion' ) , t ( 'encryption' , 'switched to client side encryption' ) ) ;
}
} else if ( server ) {
if ( prevmode == 'client' ) {
2012-08-09 11:47:27 +00:00
OC . dialogs . form ( [ { text : 'login password' , name : 'newpasswd' , type : 'password' } , { text : 'Encryption password used on the client' , name : 'oldpasswd' , type : 'password' } ] , t ( 'encryption' , 'Change encryption password to login password' ) , function ( data ) {
2012-08-09 10:19:51 +00:00
$ . post ( OC . filePath ( 'files_encryption' , 'ajax' , 'mode.php' ) , { mode : 'server' , newpasswd : data [ 0 ] . value , oldpasswd : data [ 1 ] . value } , function ( result ) {
if ( result . status != 'success' ) {
document . getElementById ( prevmode + '_encryption' ) . checked = true ;
2012-08-09 11:47:27 +00:00
OC . dialogs . alert ( t ( 'encryption' , 'Please check your passwords and try again' ) , t ( 'encryption' , 'Could not change encryption password to login password' ) )
2012-08-09 10:19:51 +00:00
}
} ) ;
} ) ;
} else {
$ . post ( OC . filePath ( 'files_encryption' , 'ajax' , 'mode.php' ) , { mode : 'server' } ) ;
}
} else {
$ . post ( OC . filePath ( 'files_encryption' , 'ajax' , 'mode.php' ) , { mode : 'none' } ) ;
}
2012-08-02 08:39:30 +00:00
} )
} )