Skip to content

Instantly share code, notes, and snippets.

@bromne
Created July 31, 2016 11:58
Show Gist options
  • Select an option

  • Save bromne/3c4277b2559feb5c8717a3354466d47a to your computer and use it in GitHub Desktop.

Select an option

Save bromne/3c4277b2559feb5c8717a3354466d47a to your computer and use it in GitHub Desktop.
Font Awesome: extract codes
// このサイトで使った。
// http://fontawesome.io/cheatsheet/
var data = $("div.col-md-4.col-sm-6.col-lg-3").toArray()
.map(function(element) {
var name = $(element).contents()
.filter(function() {
return this.nodeType === 3;
}).text()
.replace(/(^\s+)|(\s+$)/g, "");
var charcter = $("i", element).text();
var code = $("span.text-muted", element)
.text()
.replace(/^(?:\(alias\))?\[(.+)\]$/, "$1");
return name + "\t" + code;
}).join("\n");
console.log(data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment