add javascript bindings for OC_AppConfig
This commit is contained in:
parent
862f824d64
commit
8b93a9a237
3 changed files with 91 additions and 0 deletions
35
core/ajax/appconfig.php
Normal file
35
core/ajax/appconfig.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
require_once ("../../lib/base.php");
|
||||
OC_JSON::checkLoggedIn();
|
||||
$action=isset($_POST['action'])?$_POST['action']:$_GET['action'];
|
||||
$result=false;
|
||||
switch($action){
|
||||
case 'getValue':
|
||||
$result=OC_Appconfig::getValue($_GET['app'],$_GET['key'],$_GET['default']);
|
||||
break;
|
||||
case 'setValue':
|
||||
$result=OC_Appconfig::setValue($_POST['app'],$_POST['key'],$_POST['value']);
|
||||
break;
|
||||
case 'getApps':
|
||||
$result=OC_Appconfig::getApps();
|
||||
break;
|
||||
case 'getKeys':
|
||||
$result=OC_Appconfig::getKeys($_GET['app']);
|
||||
break;
|
||||
case 'hasKey':
|
||||
$result=OC_Appconfig::hasKey($_GET['app'],$_GET['key']);
|
||||
break;
|
||||
case 'deleteKey':
|
||||
$result=OC_Appconfig::deleteKey($_POST['app'],$_POST['key']);
|
||||
break;
|
||||
case 'deleteApp':
|
||||
$result=OC_Appconfig::deleteApp($_POST['app']);
|
||||
break;
|
||||
}
|
||||
OC_JSON::success(array('data'=>$result));
|
55
core/js/config.js
Normal file
55
core/js/config.js
Normal file
|
@ -0,0 +1,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,default: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
|
|
@ -236,6 +236,7 @@ class OC{
|
|||
OC_Util::addScript( "jquery-tipsy" );
|
||||
OC_Util::addScript( "js" );
|
||||
OC_Util::addScript( "eventsource" );
|
||||
OC_Util::addScript( "config" );
|
||||
//OC_Util::addScript( "multiselect" );
|
||||
OC_Util::addScript('search','result');
|
||||
OC_Util::addStyle( "styles" );
|
||||
|
|
Loading…
Reference in a new issue