Created
January 17, 2017 11:03
-
-
Save llemurya/41a35e31c093a56fc4a1b552606b7aae to your computer and use it in GitHub Desktop.
parse dashicons 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 children = jQuery('#iconlist').children(); | |
console.log(children); | |
var category = ''; | |
var collector = []; | |
children.each(function(){ | |
if (jQuery(this).is('h4')) { | |
console.log('is h4'); | |
category = jQuery(this).text().toLowerCase().replace(' ', '-'); | |
console.log(category); | |
} else { | |
var obj = {}; | |
obj['category'] =[]; | |
obj.category.push(category); | |
obj['icon'] = jQuery(this).attr('class').replace('dashicons dashicons-', ''); | |
collector.push(obj); | |
} | |
}); | |
return JSON.stringify(collector); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment