summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/js/settings-personal.js
blob: 3b9b00dc797046a00a42728412cee83623719064 (plain)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
 * 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.
 */

$(document).ready(function(){
	// Trigger ajax on recoveryAdmin status change
	$( 'input:radio[name="userEnableRecovery"]' ).change( 
		function() {
			
			// Hide feedback messages in case they're already visible
			$('#recoveryEnabledSuccess').hide();
			$('#recoveryEnabledError').hide();
			
			var recoveryStatus = $( this ).val();
			
			$.post( 
				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;
		}
	);
	
	$("#encryptAll").click( 
		function(){
			
			// Hide feedback messages in case they're already visible
			$('#encryptAllSuccess').hide();
			$('#encryptAllError').hide();
			
			var userPassword = $( '#userPassword' ).val();
			var encryptAll = $( '#encryptAll' ).val();

			$.post( 
				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;
		}
		
	);
})