()
| 70 | } |
| 71 | |
| 72 | generateHtml() { |
| 73 | if (this.html) return this.html; |
| 74 | const relevancyHtml = showRelevancy |
| 75 | ? `<span class='relevancy'>${this.computeRelevancy()}</span>` |
| 76 | : ""; |
| 77 | const insertTextClass = this.insertText ? "" : "no-insert-text"; |
| 78 | const insertTextIndicator = "↪"; // A right hooked arrow. |
| 79 | if (this.insertText && this.isCustomSearch) { |
| 80 | this.title = this.insertText; |
| 81 | } |
| 82 | let faviconHtml = ""; |
| 83 | if (this.description === "tab" && !bgUtils.isFirefox()) { |
| 84 | const faviconUrl = new URL(chrome.runtime.getURL("/_favicon/")); |
| 85 | faviconUrl.searchParams.set("pageUrl", this.url); |
| 86 | faviconUrl.searchParams.set("size", "16"); |
| 87 | faviconHtml = `<img class="icon" src="${faviconUrl.toString()}" />`; |
| 88 | } |
| 89 | if (this.isCustomSearch) { |
| 90 | this.html = `\ |
| 91 | <div class="top-half"> |
| 92 | <span class="source ${insertTextClass}">${insertTextIndicator}</span><span class="source">${this.description}</span> |
| 93 | <span class="title">${this.highlightQueryTerms(Utils.escapeHtml(this.title))}</span> |
| 94 | ${relevancyHtml} |
| 95 | </div>\ |
| 96 | `; |
| 97 | } else { |
| 98 | this.html = `\ |
| 99 | <div class="top-half"> |
| 100 | <span class="source ${insertTextClass}">${insertTextIndicator}</span><span class="source">${this.description}</span> |
| 101 | <span class="title">${this.highlightQueryTerms(Utils.escapeHtml(this.title))}</span> |
| 102 | </div> |
| 103 | <div class="bottom-half"> |
| 104 | <span class="source no-insert-text">${insertTextIndicator}</span>${faviconHtml}<span class="url">${ |
| 105 | this.highlightQueryTerms(Utils.escapeHtml(this.shortenUrl())) |
| 106 | }</span> |
| 107 | ${relevancyHtml} |
| 108 | </div>\ |
| 109 | `; |
| 110 | } |
| 111 | return this.html; |
| 112 | } |
| 113 | |
| 114 | // Use neat trick to snatch a domain (http://stackoverflow.com/a/8498668). |
| 115 | getUrlRoot(url) { |
no test coverage detected