History

Prettier.io

Simon Legner committed 2 years ago

Commit a905bdf1 parent 6b335fb80 files · +13159 −10611Browse files

Showing the changes to assets/javascripts/debug.js (1 of 80 files). Show all

Unified · Split

assets/javascripts/debug.js+58−31
@@ -9,26 +9,33 @@ · 8 unmodified lines
9 * DS209: Avoid top-level return9 * DS209: Avoid top-level return
10 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md10 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
11 */11 */
12if (!(typeof console !== 'undefined' && console !== null ? console.time : undefined) || !console.groupCollapsed) { return; }12if (
13 !(typeof console !== "undefined" && console !== null
14 ? console.time
15 : undefined) ||
16 !console.groupCollapsed
17) {
18 return;
19}
13 20
14//21//
15// App22// App
16//23//
17 24
18const _init = app.init;25const _init = app.init;
19app.init = function() {26app.init = function () {
20 console.time('Init');27 console.time("Init");
21 _init.call(app);28 _init.call(app);
22 console.timeEnd('Init');29 console.timeEnd("Init");
23 return console.time('Load');30 return console.time("Load");
24};31};
25 32
26const _start = app.start;33const _start = app.start;
27app.start = function() {34app.start = function () {
28 console.timeEnd('Load');35 console.timeEnd("Load");
29 console.time('Start');36 console.time("Start");
30 _start.call(app, ...arguments);37 _start.call(app, ...arguments);
31 return console.timeEnd('Start');38 return console.timeEnd("Start");
32};39};
33 40
34//41//
@@ -38,47 +45,50 @@ app.start = function() { · 3 unmodified lines
38const _super = app.Searcher;45const _super = app.Searcher;
39const _proto = app.Searcher.prototype;46const _proto = app.Searcher.prototype;
40 47
41app.Searcher = function() {48app.Searcher = function () {
42 _super.apply(this, arguments);49 _super.apply(this, arguments);
43 50
44 const _setup = this.setup.bind(this);51 const _setup = this.setup.bind(this);
45 this.setup = function() {52 this.setup = function () {
46 console.groupCollapsed(`Search: ${this.query}`);53 console.groupCollapsed(`Search: ${this.query}`);
47 console.time('Total');54 console.time("Total");
48 return _setup();55 return _setup();
49 };56 };
50 57
51 const _match = this.match.bind(this);58 const _match = this.match.bind(this);
52 this.match = () => {59 this.match = () => {
53 if (this.matcher) { console.timeEnd(this.matcher.name); }60 if (this.matcher) {
61 console.timeEnd(this.matcher.name);
62 }
54 return _match();63 return _match();
55 };64 };
56 65
57 const _setupMatcher = this.setupMatcher.bind(this);66 const _setupMatcher = this.setupMatcher.bind(this);
58 this.setupMatcher = function() {67 this.setupMatcher = function () {
59 console.time(this.matcher.name);68 console.time(this.matcher.name);
60 return _setupMatcher();69 return _setupMatcher();
61 };70 };
62 71
63 const _end = this.end.bind(this);72 const _end = this.end.bind(this);
64 this.end = function() {73 this.end = function () {
65 console.log(`Results: ${this.totalResults}`);74 console.log(`Results: ${this.totalResults}`);
66 console.timeEnd('Total');75 console.timeEnd("Total");
67 console.groupEnd();76 console.groupEnd();
68 return _end();77 return _end();
69 };78 };
70 79
71 const _kill = this.kill.bind(this);80 const _kill = this.kill.bind(this);
72 this.kill = function() {81 this.kill = function () {
73 if (this.timeout) {82 if (this.timeout) {
74 if (this.matcher) { console.timeEnd(this.matcher.name); }83 if (this.matcher) {
84 console.timeEnd(this.matcher.name);
85 }
75 console.groupEnd();86 console.groupEnd();
76 console.timeEnd('Total');87 console.timeEnd("Total");
77 console.warn('Killed');88 console.warn("Killed");
78 }89 }
79 return _kill();90 return _kill();
80 };91 };
81
82};92};
83 93
84$.extend(app.Searcher, _super);94$.extend(app.Searcher, _super);
@@ -89,23 +99,40 @@ app.Searcher.prototype = _proto; · 4 unmodified lines
89// View tree99// View tree
90//100//
91 101
92this.viewTree = function(view, level, visited) {102this.viewTree = function (view, level, visited) {
93 if (view == null) { view = app.document; }103 if (view == null) {
94 if (level == null) { level = 0; }104 view = app.document;
95 if (visited == null) { visited = []; }105 }
96 if (visited.indexOf(view) >= 0) { return; }106 if (level == null) {
107 level = 0;
108 }
109 if (visited == null) {
110 visited = [];
111 }
112 if (visited.indexOf(view) >= 0) {
113 return;
114 }
97 visited.push(view);115 visited.push(view);
98 116
99 console.log(`%c ${Array(level + 1).join(' ')}${view.constructor.name}: ${!!view.activated}`,117 console.log(
100 'color:' + ((view.activated && 'green') || 'red'));118 `%c ${Array(level + 1).join(" ")}${
119 view.constructor.name
120 }: ${!!view.activated}`,
121 "color:" + ((view.activated && "green") || "red"),
122 );
101 123
102 for (var key of Object.keys(view || {})) {124 for (var key of Object.keys(view || {})) {
103 var value = view[key];125 var value = view[key];
104 if ((key !== 'view') && value) {126 if (key !== "view" && value) {
105 if ((typeof value === 'object') && value.setupElement) {127 if (typeof value === "object" && value.setupElement) {
106 this.viewTree(value, level + 1, visited);128 this.viewTree(value, level + 1, visited);
107 } else if (value.constructor.toString().match(/Object\(\)/)) {129 } else if (value.constructor.toString().match(/Object\(\)/)) {
108 for (var k of Object.keys(value || {})) { var v = value[k]; if (v && (typeof v === 'object') && v.setupElement) { this.viewTree(v, level + 1, visited); } }130 for (var k of Object.keys(value || {})) {
131 var v = value[k];
132 if (v && typeof v === "object" && v.setupElement) {
133 this.viewTree(v, level + 1, visited);
134 }
135 }
109 }136 }
110 }137 }
111 }138 }