Last active
December 15, 2015 05:49
-
-
Save cincauhangus/5211405 to your computer and use it in GitHub Desktop.
Bookmarklet to log ExtJS events
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
| //<a href="javascript:[ABSTRACT FUNCTION]">Log all Ext events</a> | |
| //////// Version 1 | |
| (function () { | |
| var a, l, o = (Ext ? Ext.util.Observable.prototype : false); | |
| if (!o) { | |
| alert('Ext not in page'); | |
| return; | |
| } | |
| if (!(l = console ? console.log : false)) { | |
| alert('Use Firefox with Firebug'); | |
| return; | |
| } | |
| o.fireEvent = o.fireEvent.createInterceptor(function (evt) { | |
| a = arguments; | |
| l(this, ' fired event ', evt, ' with args ', Array.prototype.slice.call(a, 1, a.length)); | |
| }); | |
| })(); |
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
| //<a href="javascript:[ABSTRACT FUNCTION]">Log all Ext events</a> | |
| //////// Version 2 | |
| (function () { | |
| var identifyClasses = function (ns) { | |
| var className = /^[A-Z].*$/; | |
| for (var n in ns) { | |
| if (ns.hasOwnProperty && ns.hasOwnProperty(n) && typeof n === 'string' && ns[n]) { | |
| if (typeof ns[n] === 'object') { | |
| identifyClasses(ns[n]); | |
| } else if (className.test(n) && typeof ns[n] === 'function' && !ns[n].prototype.hasOwnProperty('toString')) { | |
| ns[n].prototype.toString = (function (s) { | |
| return s; | |
| }).createCallback(n + ' :'); | |
| } | |
| } | |
| } | |
| }; | |
| identifyClasses(Ext); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment