I build app that will present a lot of icons so I need list of all Font-Awesome class name like
[\"fa-dropbox\",\"fa-rocket\",\"fa-globe\", ....]
so on is ther
how to get Font Awesome Icons in a JSON object grouped by categories
I made this to use with the excellent jQuery fontIconPicker
Done with with FA Version 5.0.6
JSON result is available at https://gist.github.com/migliori/60154172ba0eea70e3c0dd4c3b5d82d0 for lazy people.
Navigate to https://fontawesome.com/icons?d=gallery&m=free
Paste this code in your browser console to grab the available categories and their icons. Wait about 2 minutes and it will return them into a JSON Object
if(typeof endList == 'undefined') {
var endList = new Object();
var catList = document.getElementsByClassName('fa-ul')[2];
var catListElements = catList.getElementsByTagName('li');
var catListLength = catListElements.length;
console.log(catListLength);
var i;
var getIcons = function(el) {
var classes = new Array();
var name = el.innerText;
console.log(name);
var icons = document.getElementById('results-icons').getElementsByTagName('svg');
for (var icon of icons) {
var clazz = icon.getAttribute('data-prefix') + ' fa-' + icon.getAttribute('data-icon');
classes.push(clazz);
}
console.log(classes);
console.log('-----');
endList[name] = classes;
if(i + 1 < catListLength) {
el.getElementsByClassName('relative')[0].click();
i++;
setTimeout(getCategory, 3000);
} else {
console.log(JSON.stringify(endList));
}
return;
}
var getCategory = function() {
var el = catListElements[i];
el.getElementsByClassName('relative')[0].click();
setTimeout(function() {
getIcons(el);
}, 3000);
}
}
i = 0;
getCategory();