mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 07:26:04 +08:00
18 lines
434 B
JavaScript
18 lines
434 B
JavaScript
/**
|
|
Return the count of users at the given trust level.
|
|
|
|
@method valueAtTrustLevel
|
|
@for Handlebars
|
|
**/
|
|
Handlebars.registerHelper('valueAtTrustLevel', function(property, trustLevel) {
|
|
var data = Ember.Handlebars.get(this, property);
|
|
if( data ) {
|
|
var item = data.find( function(d) { return parseInt(d.x,10) === parseInt(trustLevel,10); } );
|
|
if( item ) {
|
|
return item.y;
|
|
} else {
|
|
return 0;
|
|
}
|
|
}
|
|
});
|