Blame view

sources/apps/files_encryption/js/settings-personal.js 2.82 KB
03e52840d   Kload   Init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  /**
   * Copyright (c) 2013, Sam Tuke <samtuke@owncloud.com>
   * This file is licensed under the Affero General Public License version 3 or later.
   * 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.filePath( 'files_encryption', 'ajax', 'updatePrivateKeyPassword.php' )
  		, { oldPassword: oldPrivateKeyPassword, newPassword: newPrivateKeyPassword }
  		,  function( data ) {
  			if (data.status === "error") {
  				OC.msg.finishedSaving('#encryption .msg', data);
  			} else {
  				OC.msg.finishedSaving('#encryption .msg', data);
  			}
  		}
  	);
  }
  
  $(document).ready(function(){
  
  	// Trigger ajax on recoveryAdmin status change
6d9380f96   Cédric Dupont   Update sources OC...
27
  	$( 'input:radio[name="userEnableRecovery"]' ).change(
03e52840d   Kload   Init
28
29
30
31
32
33
34
35
  		function() {
  			
  			// Hide feedback messages in case they're already visible
  			$('#recoveryEnabledSuccess').hide();
  			$('#recoveryEnabledError').hide();
  			
  			var recoveryStatus = $( this ).val();
  			
6d9380f96   Cédric Dupont   Update sources OC...
36
  			$.post(
03e52840d   Kload   Init
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  				OC.filePath( 'files_encryption', 'ajax', 'userrecovery.php' )
  				, { userEnableRecovery: recoveryStatus }
  				,  function( data ) {
  					if ( data.status == "success" ) {
  						$('#recoveryEnabledSuccess').show();
  					} else {
  						$('#recoveryEnabledError').show();
  					}
  				}
  			);
  			// Ensure page is not reloaded on form submit
  			return false;
  		}
  	);
  	
6d9380f96   Cédric Dupont   Update sources OC...
52
  	$("#encryptAll").click(
03e52840d   Kload   Init
53
54
55
56
57
58
59
60
  		function(){
  			
  			// Hide feedback messages in case they're already visible
  			$('#encryptAllSuccess').hide();
  			$('#encryptAllError').hide();
  			
  			var userPassword = $( '#userPassword' ).val();
  			var encryptAll = $( '#encryptAll' ).val();
6d9380f96   Cédric Dupont   Update sources OC...
61
  			$.post(
03e52840d   Kload   Init
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
  				OC.filePath( 'files_encryption', 'ajax', 'encryptall.php' )
  				, { encryptAll: encryptAll, userPassword: userPassword }
  				,  function( data ) {
  					if ( data.status == "success" ) {
  						$('#encryptAllSuccess').show();
  					} else {
  						$('#encryptAllError').show();
  					}
  				}
  			);
  			// Ensure page is not reloaded on form submit
  			return false;
  		}
  		
  	);
  
  	// update private key password
  
  	$('input:password[name="changePrivateKeyPassword"]').keyup(function(event) {
  		var oldPrivateKeyPassword = $('input:password[id="oldPrivateKeyPassword"]').val();
  		var newPrivateKeyPassword = $('input:password[id="newPrivateKeyPassword"]').val();
  		if (newPrivateKeyPassword !== '' && oldPrivateKeyPassword !== '' ) {
  			$('button:button[name="submitChangePrivateKeyPassword"]').removeAttr("disabled");
  			if(event.which === 13) {
  				updatePrivateKeyPasswd();
  			}
  		} else {
  			$('button:button[name="submitChangePrivateKeyPassword"]').attr("disabled", "true");
  		}
  	});
  
  	$('button:button[name="submitChangePrivateKeyPassword"]').click(function() {
  		updatePrivateKeyPasswd();
  	});
31b7f2792   Kload   Upgrade to ownclo...
96
  });