X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=build%2Fjs%2Fparse.js;h=c9454d173ce1c36ca361ca2224815542e34f834a;hb=ccabf2823b528c09455432cafdb504c6a0216a18;hp=5b60b0a5bddedca89415c44889164a20d60f2316;hpb=5ae02b2ecd6293ef33de3d3acf00c456ed01b776;p=jquery.git diff --git a/build/js/parse.js b/build/js/parse.js index 5b60b0a..c9454d1 100644 --- a/build/js/parse.js +++ b/build/js/parse.js @@ -67,3 +67,31 @@ function parse( f ) { return c; } + +function categorize( json ) { + var obj = { methods: [] }; + + for ( var i = 0; i < json.length; i++ ) { + if ( !json[i].cat ) json[i].cat = ""; + + var cat = json[i].cat.split("/"); + + var pos = obj; + for ( var j = 0; j < cat.length; j++ ) { + var c = cat[j]; + + // Create current category + if ( !pos[c] ) pos[c] = { methods: [] }; + + // If we're at the end, add the method + if ( j == cat.length - 1 ) + pos[c].methods.push( json[i] ); + + // Otherwise, traverse deeper + else + pos = pos[c]; + } + } + + return obj; +}