Skip to content

Instantly share code, notes, and snippets.

@petsel
Last active December 12, 2015 03:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petsel/4706900 to your computer and use it in GitHub Desktop.
Save petsel/4706900 to your computer and use it in GitHub Desktop.
(function () {
var
global = this,
ArrProto = global.Array.prototype,
proto_slice = ArrProto.slice,
proto_map = ArrProto.map,
proto_reduce = ArrProto.reduce,
object_keys = global.Object.keys,
doc = global.document,
idList = proto_map.call(
doc.querySelectorAll("[id]"),
function (elm) {
return elm.id;
}
).sort(),
classNameList = object_keys(proto_reduce.call(
doc.querySelectorAll("[class]"),
function (collector, elm) {
return collector.concat(proto_slice.call(elm.classList));
}, []).reduce(function (collector, className) {
return ((collector[className] = 1) && collector);
}, {})
).sort()
;
return {
"idList" : idList,
"idStream" : idList.join(", "),
"classNameList" : classNameList,
"classNameStream" : classNameList.join(", ")
};
}).call(null);
(function(){var a=this.Array.prototype,d=a.slice,b=a.reduce,e=this.Object.keys,c=this.document,a=a.map.call(c.querySelectorAll("[id]"),function(a){return a.id}).sort(),b=e(b.call(c.querySelectorAll("[class]"),function(a,b){return a.concat(d.call(b.classList))},[]).reduce(function(a,b){return(a[b]=1)&&a},{})).sort();return{idList:a,idStream:a.join(", "),classNameList:b,classNameStream:b.join(", ")}}).call(null);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment