summaryrefslogtreecommitdiffstats
path: root/core/js/config.js
blob: 52d1c3aee2537b5f7c2395503c9c99ef930759fd (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
/**
 * 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.
 */

OC.AppConfig={
	url:OC.filePath('core','ajax','appconfig.php'),
	getCall:function(action,data,callback){
		data.action=action;
		$.getJSON(OC.AppConfig.url,data,function(result){
			if(result.status==='success'){
				if(callback){
					callback(result.data);
				}
			}
		});
	},
	postCall:function(action,data,callback){
		data.action=action;
		$.post(OC.AppConfig.url,data,function(result){
			if(result.status==='success'){
				if(callback){
					callback(result.data);
				}
			}
		},'json');
	},
	getValue:function(app,key,defaultValue,callback){
		if(typeof defaultValue=='function'){
			callback=defaultValue;
			defaultValue=null;
		}
		OC.AppConfig.getCall('getValue',{app:app,key:key,defaultValue:defaultValue},callback);
	},
	setValue:function(app,key,value){
		OC.AppConfig.postCall('setValue',{app:app,key:key,value:value});
	},
	getApps:function(callback){
		OC.AppConfig.getCall('getApps',{},callback);
	},
	getKeys:function(app,callback){
		OC.AppConfig.getCall('getKeys',{app:app},callback);
	},
	hasKey:function(app,key,callback){
		OC.AppConfig.getCall('hasKey',{app:app,key:key},callback);
	},
	deleteKey:function(app,key){
		OC.AppConfig.postCall('deleteKey',{app:app,key:key});
	},
	deleteApp:function(app){
		OC.AppConfig.postCall('deleteApp',{app:app});
	}
};
//TODO OC.Preferences