X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=engine%2Fstatic%2Fjs%2Fplugin.js;fp=engine%2Fstatic%2Fjs%2Fplugin.js;h=0a8bd44d15871bcfba3dc853efd6e0cb5f724d3d;hb=d0114fed8d99015bdf68202ccace76bf908aae39;hp=0000000000000000000000000000000000000000;hpb=b490e035bac3b74b66130548f5a4bf4a30ad8375;p=myslice.git diff --git a/engine/static/js/plugin.js b/engine/static/js/plugin.js new file mode 100644 index 00000000..0a8bd44d --- /dev/null +++ b/engine/static/js/plugin.js @@ -0,0 +1,58 @@ +/* + * This file is included in includes/js_libraries.php + */ + +function getMetadata(){ + return all_headers; +} +// returns all fields of a given method +function getMetadata_fields(method){ + var result=new Array(); + jQuery.each(all_headers, function(m,obj){ + if(m==method){ + jQuery.each(obj['column'], function(i,f){ + result.push(f); + }); + return false; + } + }); + result.sort(sort_by('column', false, function(a){return a.toUpperCase()})); + //result=jQuery(result).sort("column", "asc"); + return result; +} +// returns all properties of a given field +function getMetadata_field(method, field){ + //console.log(all_headers); + var result=new Array(); + jQuery.each(all_headers, function(m,obj){ + if(m==method){ + jQuery.each(obj['column'], function(i,f){ + if(f['column']==field){ + result.push(f); + return false; + } + }); + return false; + } + }); + return result[0]; +} +// returns the value of a property from a field within a method (type of object : resource,node,lease,slice...) +function getMetadata_property(method, field, property){ + //console.log(all_headers); + var result=null; + jQuery.each(all_headers, function(m,obj){ + if(m==method){ + jQuery.each(obj['column'], function(i,f){ + if(f['column']==field){ + result=f[property]; + return false; + } + }); + return false; + } + }); + return result; + //all_headers[method]['column'] + //[field][] +}