Skip to content

Instantly share code, notes, and snippets.

@cincauhangus
Last active December 15, 2015 05:49
Show Gist options
  • Select an option

  • Save cincauhangus/5211405 to your computer and use it in GitHub Desktop.

Select an option

Save cincauhangus/5211405 to your computer and use it in GitHub Desktop.
Bookmarklet to log ExtJS events
//<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));
});
})();
//<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