X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=build%2Fjs%2Fparse.js;h=498361d71112fd97a6052281689c6b7d8eea7482;hb=3527e8f6745786e65dc209f1518372f3270a9920;hp=5b60b0a5bddedca89415c44889164a20d60f2316;hpb=7448c61ee2199f6f7002e33e533cebc42b000c89;p=jquery.git diff --git a/build/js/parse.js b/build/js/parse.js index 5b60b0a..498361d 100644 --- a/build/js/parse.js +++ b/build/js/parse.js @@ -67,3 +67,40 @@ function parse( f ) { return c; } + +function categorize( json ) { + var obj = { cat: [], method: [] }; + + 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]; + var curCat = null; + + // Locate current category + for ( var n = 0; n < pos.cat.length; n++ ) + if ( pos.cat[n].value == c ) + curCat = pos.cat[n]; + + // Create current category + if ( !curCat ) { + curCat = { value: c, cat: [], method: [] }; + pos.cat.push( curCat ) + } + + // If we're at the end, add the method + if ( j == cat.length - 1 ) + curCat.method.push( json[i] ); + + // Otherwise, traverse deeper + else + pos = curCat; + } + } + + return obj; +}