split engine/ into manifold/ (backend oriented) and unfold/ (the UI)
[myslice.git] / unfold / js / plugin.js
1 function getMetadata(){
2     return MANIFOLD_METADATA;
3 }
4 // returns all fields of a given method
5 function getMetadata_fields(method){
6     var result=new Array();
7     jQuery.each(MANIFOLD_METADATA, function(m,obj){
8         if(m==method){
9             jQuery.each(obj['column'], function(i,f){
10                 result.push(f);
11             });
12             return false;
13         }
14     });
15     result.sort(sort_by('column', false, function(a){return a.toUpperCase()}));
16     //result=jQuery(result).sort("column", "asc");
17     return result;
18 }
19 // returns all properties of a given field
20 function getMetadata_field(method, field){
21     var result=new Array();
22     jQuery.each(MANIFOLD_METADATA, function(m,obj){
23         if(m==method){
24             jQuery.each(obj['column'], function(i,f){
25                 if(f['column']==field){
26                     result.push(f);
27                     return false;
28                 }
29             });
30             return false;
31         }
32     });
33     return result[0];
34 }
35 // returns the value of a property from a field within a method (type of object : resource,node,lease,slice...)
36 function getMetadata_property(method, field, property){
37     var result=null;
38     jQuery.each(MANIFOLD_METADATA, function(m,obj){
39         if(m==method){
40             jQuery.each(obj['column'], function(i,f){
41                 if(f['column']==field){
42                     result=f[property];
43                     return false;
44                 }
45             });
46             return false;
47         }
48     });
49     return result;
50 }