Skip to content

Instantly share code, notes, and snippets.

@jspinella
Last active August 29, 2015 14:25
Show Gist options
  • Save jspinella/e5f60c1c1c21a83b95ca to your computer and use it in GitHub Desktop.
Save jspinella/e5f60c1c1c21a83b95ca to your computer and use it in GitHub Desktop.
Uses jQuery to fetch Font Awesome font-icon name values (in alphabetical order) from Font Awesome's website. Paste code into your browser's Js Developer Console while on Font Awesome's Cheatsheet page!
// ParseFA-Name
// FontAwesome Names, first letter alphabetized, hyphens replaced with spaces
var awesomeOutput= "";
$(".col-md-4.col-sm-6.col-lg-3").each(function (i, element) {
var properName = $(element).text().split("\n")[2].trim(); // takes all text items in element (the FA icon, class name, and unicode value), says "hey I just want [2], the class name,", and trims the extra space
properName = properName.replace("fa-", "").replace(/-/g, " "); // since class name is almost the same as the name, this removes the "fa-" prefix and replaces hyphens (-) with spaces ( )
properName = properName.charAt(0).toUpperCase() + properName.substr(1) // capitalizes the first letter of the first word in the name
awesomeOutput += ('\n' + properName); // puts each name on its own line
});
console.log(awesomeOutput);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment