Last active
January 17, 2017 10:58
-
-
Save llemurya/950f90368b453acf977b81c79303fb49 to your computer and use it in GitHub Desktop.
font-awesome parse icons and group by categories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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