Skip to content

Instantly share code, notes, and snippets.

@vampy
Created September 29, 2012 20:22
Show Gist options
  • Save vampy/3805097 to your computer and use it in GitHub Desktop.
Save vampy/3805097 to your computer and use it in GitHub Desktop.
Generate PHP array("key" => "class-name") from Icon glyphs documentation for Twitter Bootstrap
//@link http://twitter.github.com/bootstrap/base-css.html#icons
var bigOutput = "array(\n";
var number = 1;
//how many results per line
var resultsPerLine = 4;
$("#icons .the-icons i").each(function(index)
{
var vector = (this.className).split("-");
//console.log(index + " : " + this.className +" : " + vector);
var output = "";
output += '"';
for(var i = 1; i < vector.length; i++)
{
output += vector[i];
if(i !== vector.length - 1)
output += '-';
}
output += '" => "'+ this.className +'", ';
bigOutput += output;
if(number % resultsPerLine == 0)
bigOutput += "\n";
number++;
});
//remove last commma
bigOutput = bigOutput.substring(0, bigOutput.length - 3);
bigOutput += "\n );";
alert(bigOutput);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment