|
17 | 17 |
|
18 | 18 | function escapeHtml(s) { |
19 | 19 | return String(s).replace(/[&<>"']/g, function (c) { |
20 | | - return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]; |
| 20 | + return { |
| 21 | + '&': '&', |
| 22 | + '<': '<', |
| 23 | + '>': '>', |
| 24 | + '"': '"', |
| 25 | + "'": ''', |
| 26 | + }[c]; |
21 | 27 | }); |
22 | 28 | } |
23 | 29 |
|
|
51 | 57 | document.documentElement.setAttribute('data-theme', next); |
52 | 58 | try { |
53 | 59 | localStorage.setItem(THEME_KEY, next); |
54 | | - } catch (e) { /* private mode etc. */ } |
| 60 | + } catch (e) { |
| 61 | + /* private mode etc. */ |
| 62 | + } |
55 | 63 | syncButton(); |
56 | 64 | }); |
57 | 65 | } |
|
134 | 142 | var text = pre.textContent || ''; |
135 | 143 | function done() { |
136 | 144 | btn.classList.add('copied'); |
137 | | - setTimeout(function () { btn.classList.remove('copied'); }, 1500); |
| 145 | + setTimeout(function () { |
| 146 | + btn.classList.remove('copied'); |
| 147 | + }, 1500); |
138 | 148 | } |
139 | 149 | if (navigator.clipboard && navigator.clipboard.writeText) { |
140 | 150 | navigator.clipboard.writeText(text).then(done, function () { |
|
157 | 167 | ta.select(); |
158 | 168 | try { |
159 | 169 | document.execCommand('copy'); |
160 | | - } catch (e) { /* best effort */ } |
| 170 | + } catch (e) { |
| 171 | + /* best effort */ |
| 172 | + } |
161 | 173 | document.body.removeChild(ta); |
162 | 174 | } |
163 | 175 | } |
|
208 | 220 | resultsPanel.innerHTML = matches |
209 | 221 | .map(function (entry, i) { |
210 | 222 | var href = rootPrefix() + entry.href; |
211 | | - return '<a class="search-result' + (i === selected ? ' selected' : '') + |
212 | | - '" role="option" aria-selected="' + (i === selected ? 'true' : 'false') + |
213 | | - '" href="' + escapeHtml(href) + '"><span class="search-result-kind">' + |
214 | | - escapeHtml(entry.kind || '') + '</span><span class="search-result-name">' + |
215 | | - entry.nameHtml + '</span></a>'; |
| 223 | + return ( |
| 224 | + '<a class="search-result' + |
| 225 | + (i === selected ? ' selected' : '') + |
| 226 | + '" role="option" aria-selected="' + |
| 227 | + (i === selected ? 'true' : 'false') + |
| 228 | + '" href="' + |
| 229 | + escapeHtml(href) + |
| 230 | + '"><span class="search-result-kind">' + |
| 231 | + escapeHtml(entry.kind || '') + |
| 232 | + '</span><span class="search-result-name">' + |
| 233 | + entry.nameHtml + |
| 234 | + '</span></a>' |
| 235 | + ); |
216 | 236 | }) |
217 | 237 | .join(''); |
218 | 238 | input.setAttribute('aria-expanded', 'true'); |
|
239 | 259 | if (idx === -1) { |
240 | 260 | return escapeHtml(name); |
241 | 261 | } |
242 | | - return escapeHtml(name.slice(0, idx)) + |
243 | | - '<mark>' + escapeHtml(name.slice(idx, idx + query.length)) + '</mark>' + |
244 | | - escapeHtml(name.slice(idx + query.length)); |
| 262 | + return ( |
| 263 | + escapeHtml(name.slice(0, idx)) + |
| 264 | + '<mark>' + |
| 265 | + escapeHtml(name.slice(idx, idx + query.length)) + |
| 266 | + '</mark>' + |
| 267 | + escapeHtml(name.slice(idx + query.length)) |
| 268 | + ); |
245 | 269 | } |
246 | 270 |
|
247 | 271 | function updateSearch() { |
|
268 | 292 | href: entry.href, |
269 | 293 | kind: entry.kind, |
270 | 294 | name: entry.name, |
271 | | - nameHtml: highlight(entry.name, query) |
| 295 | + nameHtml: highlight(entry.name, query), |
272 | 296 | }; |
273 | 297 | }); |
274 | 298 | selected = -1; |
275 | 299 | if (matches.length === 0) { |
276 | 300 | resultsPanel.innerHTML = |
277 | | - '<div class="search-result-empty">No results for “' + |
278 | | - escapeHtml(input.value) + '”</div>'; |
| 301 | + '<div class="search-result-empty">No results for “' + escapeHtml(input.value) + '”</div>'; |
279 | 302 | resultsPanel.hidden = false; |
280 | 303 | return; |
281 | 304 | } |
|
294 | 317 | link.style.display = query === '' || name.indexOf(query) !== -1 ? '' : 'none'; |
295 | 318 | }); |
296 | 319 | sidebar.querySelectorAll('details').forEach(function (details) { |
297 | | - var anyVisible = Array.prototype.some.call( |
298 | | - details.querySelectorAll('a[data-name]'), |
299 | | - function (a) { return a.style.display !== 'none'; } |
300 | | - ); |
| 320 | + var anyVisible = Array.prototype.some.call(details.querySelectorAll('a[data-name]'), function (a) { |
| 321 | + return a.style.display !== 'none'; |
| 322 | + }); |
301 | 323 | if (query !== '' && anyVisible && !details.open) { |
302 | 324 | details.open = true; |
303 | 325 | } |
|
424 | 446 | return; |
425 | 447 | } |
426 | 448 | current = best; |
427 | | - links.forEach(function (l) { l.classList.remove('active'); }); |
| 449 | + links.forEach(function (l) { |
| 450 | + l.classList.remove('active'); |
| 451 | + }); |
428 | 452 | best.link.classList.add('active'); |
429 | 453 | } |
430 | 454 | var ticking = false; |
431 | | - document.addEventListener('scroll', function () { |
432 | | - if (!ticking) { |
433 | | - ticking = true; |
434 | | - requestAnimationFrame(function () { |
435 | | - update(); |
436 | | - ticking = false; |
437 | | - }); |
438 | | - } |
439 | | - }, { passive: true }); |
| 455 | + document.addEventListener( |
| 456 | + 'scroll', |
| 457 | + function () { |
| 458 | + if (!ticking) { |
| 459 | + ticking = true; |
| 460 | + requestAnimationFrame(function () { |
| 461 | + update(); |
| 462 | + ticking = false; |
| 463 | + }); |
| 464 | + } |
| 465 | + }, |
| 466 | + { passive: true }, |
| 467 | + ); |
440 | 468 | update(); |
441 | 469 | } |
442 | 470 |
|
|
0 commit comments