0a8bd44d15871bcfba3dc853efd6e0cb5f724d3d
[myslice.git] / engine / static / js / plugin.js
1 /*
2  * This file is included in includes/js_libraries.php
3  */
4
5 function getMetadata(){
6     return all_headers;
7 }
8 // returns all fields of a given method
9 function getMetadata_fields(method){
10     var result=new Array();
11     jQuery.each(all_headers, function(m,obj){
12         if(m==method){
13             jQuery.each(obj['column'], function(i,f){
14                 result.push(f);
15             });
16             return false;
17         }
18     });
19     result.sort(sort_by('column', false, function(a){return a.toUpperCase()}));
20     //result=jQuery(result).sort("column", "asc");
21     return result;
22 }
23 // returns all properties of a given field
24 function getMetadata_field(method, field){
25     //console.log(all_headers);
26     var result=new Array();
27     jQuery.each(all_headers, function(m,obj){
28         if(m==method){
29             jQuery.each(obj['column'], function(i,f){
30                 if(f['column']==field){
31                     result.push(f);
32                     return false;
33                 }
34             });
35             return false;
36         }
37     });
38     return result[0];
39 }
40 // returns the value of a property from a field within a method (type of object : resource,node,lease,slice...)
41 function getMetadata_property(method, field, property){
42     //console.log(all_headers);
43     var result=null;
44     jQuery.each(all_headers, function(m,obj){
45         if(m==method){
46             jQuery.each(obj['column'], function(i,f){
47                 if(f['column']==field){
48                     result=f[property];
49                     return false;
50                 }
51             });
52             return false;
53         }
54     });
55     return result;
56     //all_headers[method]['column']
57     //[field][]
58 }