summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/js/settings-admin.js
blob: 8e9c8c223061c88beac470f9b10b9fa190e60305 (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
/**
 * Copyright (c) 2013, Sam Tuke <samtuke@owncloud.com>, Robin Appelman 
 * <icewind1991@gmail.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 filetype blacklist change
	$('#encryption_blacklist').multiSelect({
		oncheck:blackListChange,
		onuncheck:blackListChange,
		createText:'...'
	});
	
	// Trigger ajax on recoveryAdmin status change
	$( 'input:radio[name="adminEnableRecovery"]' ).change( 
		function() {
			
			var recoveryStatus = $( this ).val();
			var recoveryPassword = $( '#recoveryPassword' ).val();
			
			if ( '' == recoveryPassword ) {
				
				// FIXME: add proper OC notification
				alert( 'You  must set a recovery account password first' );
				
			} else {
			
				$.post( 
					OC.filePath( 'files_encryption', 'ajax', 'adminrecovery.php' )
					, { adminEnableRecovery: recoveryStatus, recoveryPassword: recoveryPassword }
					,  function( data ) {
						alert( data );
					}
				);
			
			}
		}
	);
	
	function blackListChange(){
		var blackList=$( '#encryption_blacklist' ).val().join( ',' );
		OC.AppConfig.setValue( 'files_encryption', 'type_blacklist', blackList );
	}
})