config.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * Copyright (c) 2011, Robin Appelman <icewind1991@gmail.com>
  3. * This file is licensed under the Affero General Public License version 3 or later.
  4. * See the COPYING-README file.
  5. */
  6. OC.AppConfig={
  7. url:OC.filePath('core','ajax','appconfig.php'),
  8. getCall:function(action,data,callback){
  9. data.action=action;
  10. $.getJSON(OC.AppConfig.url,data,function(result){
  11. if(result.status='success'){
  12. if(callback){
  13. callback(result.data);
  14. }
  15. }
  16. });
  17. },
  18. postCall:function(action,data,callback){
  19. data.action=action;
  20. $.post(OC.AppConfig.url,data,function(result){
  21. if(result.status='success'){
  22. if(callback){
  23. callback(result.data);
  24. }
  25. }
  26. },'json');
  27. },
  28. getValue:function(app,key,defaultValue,callback){
  29. if(typeof defaultValue=='function'){
  30. callback=defaultValue;
  31. defaultValue=null;
  32. }
  33. OC.AppConfig.getCall('getValue',{app:app,key:key,defaultValue:defaultValue},callback);
  34. },
  35. setValue:function(app,key,value){
  36. OC.AppConfig.postCall('setValue',{app:app,key:key,value:value});
  37. },
  38. getApps:function(callback){
  39. OC.AppConfig.getCall('getApps',{},callback);
  40. },
  41. getKeys:function(app,callback){
  42. OC.AppConfig.getCall('getKeys',{app:app},callback);
  43. },
  44. hasKey:function(app,key,callback){
  45. OC.AppConfig.getCall('hasKey',{app:app,key:key},callback);
  46. },
  47. deleteKey:function(app,key){
  48. OC.AppConfig.postCall('deleteKey',{app:app,key:key});
  49. },
  50. deleteApp:function(app){
  51. OC.AppConfig.postCall('deleteApp',{app:app});
  52. },
  53. };
  54. //TODO OC.Preferences