Revision e4574d0f

b/ui/static/snf/js/tests/jquery.profile.js
1
//this object holds the results
2
$profile = {};
3
old$ = jQuery;
4
$ = function () {
5
var args = Array.prototype.slice.apply(arguments);
6
if (args && args[0] && typeof args[0] === "string") {
7
    $profile[args[0]] = typeof $profile[args[0]] === "undefined" ? 1 : $profile[args[0]] += 1;
8
}
9
return old$.apply(this, arguments);
10
};
11
old$.extend(true, $, old$);
12
jQuery = $;
13

  
14
$$profile = function(limit) {
15
    var limit = limit || 10;
16
    results = _.select(_.map($profile, function(val,key){
17
        if (val > limit)
18
            return [key, val]
19

  
20
        return false;
21
    }), function(r){ return r })
22
    
23
    var sorted = _.sortBy(results, function(el) {
24
        return -el[1];
25
    })
26

  
27
    _.each(sorted, function(el) {
28
        console.log(el[0], el[1])
29
    })
30
}

Also available in: Unified diff