Skip to content

Instantly share code, notes, and snippets.

@llemurya
Last active January 17, 2017 10:58
Show Gist options
  • Save llemurya/950f90368b453acf977b81c79303fb49 to your computer and use it in GitHub Desktop.
Save llemurya/950f90368b453acf977b81c79303fb49 to your computer and use it in GitHub Desktop.
font-awesome parse icons and group by categories
(function(){
var sections = jQuery('#icons').children();
var collector = [];
sections.each(function(){
var that = jQuery(this);
if(that.attr('id') !== 'new'){
jQuery(this).find('i').filter(function(){ return !jQuery(this).siblings('.text-muted').length }).each(function(){
var obj = {};
found = _.findWhere(collector, {'icon': jQuery(this).attr('class').replace('fa fa-', '') });
if(found !== undefined){
found.category.push(that.attr('id'));
return;
}
obj['icon'] = jQuery(this).attr('class').replace('fa fa-', '');
obj['category']= [];
obj['category'].push(that.attr('id'));
collector.push(obj);
});
}
});
console.log('Length', collector.length);
console.log(JSON.stringify(collector));
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment