MCPcopy Create free account
hub / github.com/mitmproxy/mitmproxy / onInput

Function onInput

docs/src/assets/search.js:67–102  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65}
66
67function onInput() {
68 setContent((() => {
69 const term = getSearchTerm();
70 if (!term) {
71 return null
72 }
73 if (searchErr) {
74 return `<h3>Error: ${searchErr}</h3>`
75 }
76 if (!search) {
77 return "<h3>Searching...</h3>"
78 }
79
80 window.scrollTo({top: 0, left: 0, behavior: 'auto'});
81
82 const results = search(term);
83
84 let html;
85 if (results.length === 0) {
86 html = `No search results for '${escapeHTML(term)}'.`
87 } else {
88 html = `<h4>${results.length} search result${results.length > 1 ? "s" : ""} for '${escapeHTML(term)}'.</h4>`;
89 }
90 for (let result of results) {
91 let doc = result.doc;
92 let url = `${root}${doc.url}`;
93 html += `
94 <div class="search-result">
95 [${doc.section}] <a href="${url}">${doc.title}</a>
96 </div>
97 `;
98
99 }
100 return html;
101 })());
102}
103
104if (getSearchTerm()) {
105 initialize();

Callers 2

search.jsFile · 0.85
initializeFunction · 0.85

Calls 3

setContentFunction · 0.85
getSearchTermFunction · 0.85
escapeHTMLFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…