You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
devdocs/assets/javascripts/debug.js

132 lines
3.0 KiB

// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS203: Remove `|| {}` from converted for-own loops
* DS207: Consider shorter variations of null checks
* DS208: Avoid top-level this
* DS209: Avoid top-level return
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/
//
// App
//
const _init = app.init;
1 year ago
app.init = function () {
console.time("Init");
_init.call(app);
1 year ago
console.timeEnd("Init");
return console.time("Load");
};
const _start = app.start;
1 year ago
app.start = function () {
console.timeEnd("Load");
console.time("Start");
_start.call(app, ...arguments);
1 year ago
return console.timeEnd("Start");
};
//
// Searcher
//
const _super = app.Searcher;
const _proto = app.Searcher.prototype;
1 year ago
app.Searcher = function () {
_super.apply(this, arguments);
const _setup = this.setup.bind(this);
1 year ago
this.setup = function () {
console.groupCollapsed(`Search: ${this.query}`);
1 year ago
console.time("Total");
return _setup();
};
const _match = this.match.bind(this);
this.match = () => {
1 year ago
if (this.matcher) {
console.timeEnd(this.matcher.name);
}
return _match();
};
const _setupMatcher = this.setupMatcher.bind(this);
1 year ago
this.setupMatcher = function () {
console.time(this.matcher.name);
return _setupMatcher();
};
const _end = this.end.bind(this);
1 year ago
this.end = function () {
console.log(`Results: ${this.totalResults}`);
1 year ago
console.timeEnd("Total");
console.groupEnd();
return _end();
};
const _kill = this.kill.bind(this);
1 year ago
this.kill = function () {
if (this.timeout) {
1 year ago
if (this.matcher) {
console.timeEnd(this.matcher.name);
}
console.groupEnd();
1 year ago
console.timeEnd("Total");
console.warn("Killed");
}
return _kill();
};
};
$.extend(app.Searcher, _super);
_proto.constructor = app.Searcher;
app.Searcher.prototype = _proto;
//
// View tree
//
1 year ago
this.viewTree = function (view, level, visited) {
if (view == null) {
view = app.document;
}
if (level == null) {
level = 0;
}
if (visited == null) {
visited = [];
}
if (visited.indexOf(view) >= 0) {
return;
}
visited.push(view);
1 year ago
console.log(
`%c ${Array(level + 1).join(" ")}${
view.constructor.name
}: ${!!view.activated}`,
"color:" + ((view.activated && "green") || "red")
1 year ago
);
for (var key of Object.keys(view || {})) {
var value = view[key];
1 year ago
if (key !== "view" && value) {
if (typeof value === "object" && value.setupElement) {
this.viewTree(value, level + 1, visited);
} else if (value.constructor.toString().match(/Object\(\)/)) {
1 year ago
for (var k of Object.keys(value || {})) {
var v = value[k];
if (v && typeof v === "object" && v.setupElement) {
this.viewTree(v, level + 1, visited);
}
}
}
}
}
};