MCPcopy Create free account
hub / github.com/dtmilano/AndroidViewClient / _displayItem

Function _displayItem

docs/_static/searchtools.js:60–102  ·  view source on GitHub ↗
(item, searchTerms)

Source from the content-addressed store, hash-verified

58 string.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
59
60const _displayItem = (item, searchTerms) => {
61 const docBuilder = DOCUMENTATION_OPTIONS.BUILDER;
62 const docUrlRoot = DOCUMENTATION_OPTIONS.URL_ROOT;
63 const docFileSuffix = DOCUMENTATION_OPTIONS.FILE_SUFFIX;
64 const docLinkSuffix = DOCUMENTATION_OPTIONS.LINK_SUFFIX;
65 const showSearchSummary = DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY;
66
67 const [docName, title, anchor, descr, score, _filename] = item;
68
69 let listItem = document.createElement("li");
70 let requestUrl;
71 let linkUrl;
72 if (docBuilder === "dirhtml") {
73 // dirhtml builder
74 let dirname = docName + "/";
75 if (dirname.match(/\/index\/$/))
76 dirname = dirname.substring(0, dirname.length - 6);
77 else if (dirname === "index/") dirname = "";
78 requestUrl = docUrlRoot + dirname;
79 linkUrl = requestUrl;
80 } else {
81 // normal html builders
82 requestUrl = docUrlRoot + docName + docFileSuffix;
83 linkUrl = docName + docLinkSuffix;
84 }
85 let linkEl = listItem.appendChild(document.createElement("a"));
86 linkEl.href = linkUrl + anchor;
87 linkEl.dataset.score = score;
88 linkEl.innerHTML = title;
89 if (descr)
90 listItem.appendChild(document.createElement("span")).innerHTML =
91 " (" + descr + ")";
92 else if (showSearchSummary)
93 fetch(requestUrl)
94 .then((responseData) => responseData.text())
95 .then((data) => {
96 if (data)
97 listItem.appendChild(
98 Search.makeSearchSummary(data, searchTerms)
99 );
100 });
101 Search.output.appendChild(listItem);
102};
103const _finishSearch = (resultCount) => {
104 Search.stopPulse();
105 Search.title.innerText = _("Search Results");

Callers 1

_displayNextItemFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected