config.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. /**
  7. * @namespace
  8. */
  9. OC.AppConfig={
  10. url:OC.filePath('core','ajax','appconfig.php'),
  11. getCall:function(action,data,callback){
  12. data.action=action;
  13. $.getJSON(OC.AppConfig.url,data,function(result){
  14. if(result.status==='success'){
  15. if(callback){
  16. callback(result.data);
  17. }
  18. }
  19. });
  20. },
  21. postCall:function(action,data,callback){
  22. data.action=action;
  23. $.post(OC.AppConfig.url,data,function(result){
  24. if(result.status==='success'){
  25. if(callback){
  26. callback(result.data);
  27. }
  28. }
  29. },'json');
  30. },
  31. getValue:function(app,key,defaultValue,callback){
  32. if(typeof defaultValue=='function'){
  33. callback=defaultValue;
  34. defaultValue=null;
  35. }
  36. OC.AppConfig.getCall('getValue',{app:app,key:key,defaultValue:defaultValue},callback);
  37. },
  38. setValue:function(app,key,value){
  39. OC.AppConfig.postCall('setValue',{app:app,key:key,value:value});
  40. },
  41. getApps:function(callback){
  42. OC.AppConfig.getCall('getApps',{},callback);
  43. },
  44. getKeys:function(app,callback){
  45. OC.AppConfig.getCall('getKeys',{app:app},callback);
  46. },
  47. hasKey:function(app,key,callback){
  48. OC.AppConfig.getCall('hasKey',{app:app,key:key},callback);
  49. },
  50. deleteKey:function(app,key){
  51. OC.AppConfig.postCall('deleteKey',{app:app,key:key});
  52. },
  53. deleteApp:function(app){
  54. OC.AppConfig.postCall('deleteApp',{app:app});
  55. }
  56. };
  57. //TODO OC.Preferences