MCPcopy
hub / github.com/philc/vimium / populatePage

Function populatePage

pages/doc_search_completion.js:11–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9}
10
11export function populatePage() {
12 const template = document.querySelector("#engine-template").content;
13 for (const engineClass of completionEngines.list) {
14 const el = template.cloneNode(true);
15 const engine = new engineClass();
16 const h4 = el.querySelector("h4");
17 h4.textContent = engine.constructor.name;
18 // This data attribute is used in tests.
19 h4.dataset.engine = engine.constructor.name;
20 const explanationEl = el.querySelector(".explanation");
21 if (engine.example.explanation) {
22 explanationEl.textContent = engine.example.explanation;
23 } else {
24 explanationEl.remove();
25 }
26
27 const exampleEl = el.querySelector(".engine-example");
28 if (engine.example.searchUrl && engine.example.keyword) {
29 const desc = engine.example.description || engine.constructor.name;
30 exampleEl.querySelector("pre").textContent =
31 `${engine.example.keyword}: ${engine.example.searchUrl} ${desc}`;
32 } else {
33 exampleEl.remove();
34 }
35
36 const regexpsEl = el.querySelector(".regexps");
37 if (engine.regexps) {
38 let content = "";
39 for (const re of engine.regexps) {
40 content += `${cleanUpRegexp(re)}\n`;
41 }
42 regexpsEl.querySelector("pre").textContent = content;
43 } else {
44 regexpsEl.remove();
45 }
46 document.querySelector("#engine-list").appendChild(el);
47 }
48}
49
50const testEnv = globalThis.window == null;
51if (!testEnv) {

Callers

nothing calls this directly

Calls 2

cleanUpRegexpFunction · 0.85
removeMethod · 0.80

Tested by

no test coverage detected