summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/js/settings.js
blob: 60563bde859cd59683bbb7706fb4c0992b3523f9 (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
/**
 * Copyright (c) 2011, 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(){
	$('#encryption_blacklist').multiSelect({
		oncheck:blackListChange,
		onuncheck:blackListChange,
		createText:'...',
	});
	
	function blackListChange(){
		var blackList=$('#encryption_blacklist').val().join(',');
		OC.AppConfig.setValue('files_encryption','type_blacklist',blackList);
	}

	//TODO: Handle switch between client and server side encryption
	$('input[name=encryption_mode]').change(function(){
		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()
			 ,disable=false
		if (client) {
			OC.AppConfig.setValue('files_encryption','mode','client');
			disable = true;
		} else if (server) {
			OC.AppConfig.setValue('files_encryption','mode','server');
			disable = true;
		} else if (user) {
			OC.AppConfig.setValue('files_encryption','mode','user');
			disable = true;
		} else {
			OC.AppConfig.setValue('files_encryption','mode','none');
		}
		if (disable) {
			document.getElementById('server_encryption').disabled = true;
			document.getElementById('client_encryption').disabled = true;
			document.getElementById('user_encryption').disabled = true;
			document.getElementById('none_encryption').disabled = true;
		}
	})
})