new object pluginset
[myslice.git] / engine / static / js / plugin.js
1 function getMetadata(){
2     return all_headers;
3 }
4 // returns all fields of a given method
5 function getMetadata_fields(method){
6     var result=new Array();
7     jQuery.each(all_headers, 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     //console.log(all_headers);
22     var result=new Array();
23     jQuery.each(all_headers, function(m,obj){
24         if(m==method){
25             jQuery.each(obj['column'], function(i,f){
26                 if(f['column']==field){
27                     result.push(f);
28                     return false;
29                 }
30             });
31             return false;
32         }
33     });
34     return result[0];
35 }
36 // returns the value of a property from a field within a method (type of object : resource,node,lease,slice...)
37 function getMetadata_property(method, field, property){
38     //console.log(all_headers);
39     var result=null;
40     jQuery.each(all_headers, function(m,obj){
41         if(m==method){
42             jQuery.each(obj['column'], function(i,f){
43                 if(f['column']==field){
44                     result=f[property];
45                     return false;
46                 }
47             });
48             return false;
49         }
50     });
51     return result;
52     //all_headers[method]['column']
53     //[field][]
54 }