Created
August 11, 2010 05:32
-
-
Save DylanFM/518525 to your computer and use it in GitHub Desktop.
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
| window.boundEvents = { all: { count: 0, elements: [] } }; | |
| // Collect all the events | |
| $('html').find('*').andSelf().each(function() { | |
| var events = $(this).data('events'); | |
| if ($.isPlainObject(events) === true) { | |
| $.each(events, function(n, e) { | |
| if (window.boundEvents[n] === undefined) { | |
| window.boundEvents[n] = { count: 0, elements: [] }; | |
| } | |
| }); | |
| } | |
| }); | |
| var bindTo = ''; | |
| $.each(window.boundEvents, function(n, c) { bindTo += n + ' '; }); | |
| // Bind to these events | |
| $('html').bind(bindTo, function(e) { | |
| if ($.isPlainObject(window.boundEvents[e['type']])) { | |
| var el = e.target.nodeName; | |
| // Increment counts | |
| window.boundEvents[e.type].count++; | |
| window.boundEvents['all'].count++; | |
| // Track the element types | |
| window.boundEvents[e.type].elements.push(el); | |
| window.boundEvents['all'].elements.push(el); | |
| } | |
| }); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The previous version is nicer to look at in the console, but this one tracks what elements are targetted by the events.