Created
April 30, 2015 13:25
-
-
Save manufaktor/2e8003bd15cfa5ceceac to your computer and use it in GitHub Desktop.
Create a CSS properties report from the visible elements on page, so you can easily check if you're using too many font-sizes or colors.
This file contains hidden or 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
// needs jQuery trollollooo | |
// example: report("fontSize") | |
// example: report("fontSize", false) // reports the elements which have the given properties | |
function gather(prop){ | |
var reduce = function(result, item){ | |
var $item = $(item); | |
var propValue = $item.css(prop); | |
result[propValue] = result[propValue] || []; | |
result[propValue].push(item); | |
return result; | |
}; | |
return $("*:visible").toArray().reduce(reduce, {}); | |
} | |
function report(prop, simple){ | |
var result = gather(prop); | |
var list = $.map(result, function(value, index){ | |
if(simple !== false){ | |
return[index, value.length]; | |
} | |
return { | |
count: value.length, | |
value: index, | |
elements: value | |
} | |
}); | |
return list; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment