Created
September 29, 2012 20:22
-
-
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
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
//@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