scripts.html 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. {{ $enquire := resources.Get "js/enquire.min.js" | resources.Fingerprint }}
  2. <script src="{{ $enquire.RelPermalink }}"></script>
  3. {{ $fuse := resources.Get "js/fuse.min.js" | resources.Fingerprint }}
  4. <script defer src="{{ $fuse.RelPermalink }}"></script>
  5. {{ $lazysizes := resources.Get "js/lazysizes.min.js" | resources.Fingerprint }}
  6. <script defer src="{{ $lazysizes.RelPermalink }}"></script>
  7. {{ $getParents := resources.Get "js/helper/getParents.js" | resources.Minify | resources.Fingerprint }}
  8. <script defer src="{{ $getParents.RelPermalink }}"></script>
  9. {{ $fadeinout := resources.Get "js/helper/fadeinout.js" | resources.Minify | resources.Fingerprint }}
  10. <script defer src="{{ $fadeinout.RelPermalink }}"></script>
  11. <script>
  12. "use strict";
  13. window.onload = function() {
  14. // ======================= toggle theme =======================
  15. var root = document.getElementById('root');
  16. var toggleToLightBtn = document.getElementById('toggleToLight');
  17. var toggleToDarkBtn = document.getElementById('toggleToDark');
  18. toggleToDark.onclick = function(e) {
  19. root.className = 'theme__dark';
  20. localStorage.setItem('theme', 'dark');
  21. toggleToLightBtn.className = 'navbar__icons--icon';
  22. toggleToDarkBtn.className = 'hide';
  23. }
  24. toggleToLight.onclick = function (e) {
  25. root.className = 'theme__light';
  26. localStorage.setItem('theme', 'light');
  27. toggleToLightBtn.className = 'hide';
  28. toggleToDarkBtn.className = 'navbar__icons--icon';
  29. }
  30. // =================== section menu collapse ==================
  31. document.querySelectorAll('.menu__list').forEach(function(elem) {
  32. if (elem.classList.contains('active')) {
  33. elem.style.maxHeight = elem.scrollHeight + "px";
  34. }
  35. });
  36. document.querySelectorAll('.menu__title--collapse').forEach(function(elem) {
  37. elem.addEventListener('click', function (e) {
  38. var content = this.nextElementSibling;
  39. var menuTitleIcon = this.querySelector('.menu__title--icon');
  40. console.log(menuTitleIcon);
  41. if (!content) {
  42. return null;
  43. }
  44. if (content.style.maxHeight) {
  45. content.style.maxHeight = null;
  46. content.classList.remove('active');
  47. menuTitleIcon.classList.add('right');
  48. menuTitleIcon.classList.remove('down');
  49. } else {
  50. content.style.maxHeight = content.scrollHeight + "px";
  51. content.classList.add('active');
  52. menuTitleIcon.classList.remove('right');
  53. menuTitleIcon.classList.add('down');
  54. }
  55. });
  56. });
  57. // ============================================================
  58. // ========================== drawer ==========================
  59. var mobileLogo = document.getElementById('mobileLogo');
  60. var modal = document.getElementById("myModal");
  61. var drawer = document.getElementById('myDrawer');
  62. var drawerCloseBtn = document.querySelector('.drawer__close');
  63. var openDrawer = function() {
  64. modal.style.left = 0;
  65. modal.style.opacity = 1;
  66. drawer.style.left = 0;
  67. drawer.style.transition = "left 0.3s ease-out";
  68. drawer.style.webkitTransition = "left 0.3s ease-out";
  69. }
  70. var closeDrawer = function() {
  71. modal.style.opacity = 0;
  72. drawer.style.left = '-100%';
  73. setTimeout(function () {
  74. modal.style.left = '-100%';
  75. }, 250);
  76. }
  77. mobileLogo.onclick = function () {
  78. openDrawer();
  79. localStorage.setItem('isDrawerOpen', 'true');
  80. }
  81. modal.onclick = function () {
  82. closeDrawer();
  83. localStorage.setItem('isDrawerOpen', 'false');
  84. }
  85. drawerCloseBtn.onclick = function () {
  86. closeDrawer();
  87. localStorage.setItem('isDrawerOpen', 'false');
  88. }
  89. // ==============================================================
  90. // =========================== scroll ===========================
  91. var lastScrollTop = window.pageYOffset || document.documentElement.scrollTop;
  92. var tocElem = document.querySelector('.toc');
  93. var tableOfContentsElem = tocElem ? tocElem.querySelector('#TableOfContents') : null;
  94. var singleContentsElem = document.querySelector('.single__contents');
  95. window.onscroll = function () {
  96. var st = window.pageYOffset || document.documentElement.scrollTop;
  97. if (st > lastScrollTop) { // scroll down
  98. singleContentsElem ?
  99. singleContentsElem.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach(function(elem) {
  100. if (document.documentElement.scrollTop >= elem.offsetTop) {
  101. if (tableOfContentsElem) {
  102. var id = elem.getAttribute('id');
  103. tocElem.querySelectorAll('a').forEach(function (elem) {
  104. elem.classList.remove('active');
  105. });
  106. tocElem.querySelector('a[href="#' + id + '"]') ?
  107. tocElem.querySelector('a[href="#' + id + '"]').classList.add('active') : null;
  108. }
  109. }
  110. }) : null;
  111. } else { // scroll up
  112. singleContentsElem ?
  113. singleContentsElem.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach(function(elem) {
  114. if (document.documentElement.scrollTop >= elem.offsetTop) {
  115. if (tableOfContentsElem) {
  116. var id = elem.getAttribute('id');
  117. tocElem.querySelectorAll('a').forEach(function (elem) {
  118. elem.classList.remove('active');
  119. });
  120. tocElem.querySelector('a[href="#' + id + '"]') ?
  121. tocElem.querySelector('a[href="#' + id + '"]').classList.add('active') : null;
  122. }
  123. }
  124. }) : null;
  125. }
  126. lastScrollTop = st <= 0 ? 0 : st;
  127. };
  128. // ============================================================
  129. // ====================== mobile search =======================
  130. var mobileSearchInputElem = document.querySelector('#search-mobile');
  131. var mobileSearchClassElem = document.querySelector('.mobile-search');
  132. var mobileSearchBtnElem = document.querySelector('#mobileSearchBtn');
  133. var mobileSearchCloseBtnElem = document.querySelector('#search-mobile-close');
  134. var mobileSearchContainer = document.querySelector('#search-mobile-container');
  135. var mobileSearchResultsElem = document.querySelector('#search-mobile-results');
  136. var htmlElem = document.querySelector('html');
  137. if (mobileSearchClassElem) {
  138. mobileSearchClassElem.style.display = 'none';
  139. }
  140. mobileSearchBtnElem ?
  141. mobileSearchBtnElem.addEventListener('click', function () {
  142. if (mobileSearchContainer) {
  143. mobileSearchContainer.style.display = 'block';
  144. }
  145. if (mobileSearchInputElem) {
  146. mobileSearchInputElem.focus();
  147. }
  148. if (htmlElem) {
  149. htmlElem.style.overflowY = 'hidden';
  150. }
  151. }) : null;
  152. mobileSearchCloseBtnElem ?
  153. mobileSearchCloseBtnElem.addEventListener('click', function() {
  154. if (mobileSearchContainer) {
  155. mobileSearchContainer.style.display = 'none';
  156. }
  157. if (mobileSearchInputElem) {
  158. mobileSearchInputElem.value = '';
  159. }
  160. if (mobileSearchResultsElem) {
  161. while (mobileSearchResultsElem.firstChild) {
  162. mobileSearchResultsElem.removeChild(mobileSearchResultsElem.firstChild);
  163. }
  164. }
  165. if (htmlElem) {
  166. htmlElem.style.overflowY = 'visible';
  167. }
  168. }) : null;
  169. mobileSearchInputElem ?
  170. mobileSearchInputElem.addEventListener('keydown', function(e) {
  171. if (e.key === 'Escape') {
  172. if (mobileSearchContainer) {
  173. mobileSearchContainer.style.display = 'none';
  174. }
  175. if (mobileSearchInputElem) {
  176. mobileSearchInputElem.value = '';
  177. }
  178. if (mobileSearchResultsElem) {
  179. while (mobileSearchResultsElem.firstChild) {
  180. mobileSearchResultsElem.removeChild(mobileSearchResultsElem.firstChild);
  181. }
  182. }
  183. if (htmlElem) {
  184. htmlElem.style.overflowY = 'visible';
  185. }
  186. }
  187. }) : null;
  188. // ============================================================
  189. // ======================= theme change =======================
  190. var localTheme = localStorage.getItem('theme');
  191. var rootEleme = document.getElementById('root');
  192. var selectThemeElem = document.querySelectorAll('.select-theme');
  193. var selectThemeItemElem = document.querySelectorAll('.select-theme__item');
  194. if (localTheme) {
  195. selectThemeItemElem ?
  196. selectThemeItemElem.forEach(function (elem) {
  197. if (elem.text.trim() === localTheme) {
  198. elem.classList.add('is-active');
  199. } else {
  200. elem.classList.remove('is-active');
  201. }
  202. }) : null;
  203. }
  204. selectThemeItemElem ?
  205. selectThemeItemElem.forEach(function (v, i) {
  206. v.addEventListener('click', function (e) {
  207. var selectedThemeVariant = e.target.text.trim();
  208. localStorage.setItem('theme', selectedThemeVariant);
  209. rootEleme.removeAttribute('class');
  210. rootEleme.classList.add(`theme__${selectedThemeVariant}`);
  211. selectThemeElem.forEach(function(rootElem) {
  212. rootElem.querySelectorAll('a').forEach(function (elem) {
  213. if (elem.classList) {
  214. if (elem.text.trim() === selectedThemeVariant) {
  215. if (!elem.classList.contains('is-active')) {
  216. elem.classList.add('is-active');
  217. }
  218. } else {
  219. if (elem.classList.contains('is-active')) {
  220. elem.classList.remove('is-active');
  221. }
  222. }
  223. }
  224. });
  225. });
  226. if (window.mermaid) {
  227. if (selectedThemeVariant === "dark" || selectedThemeVariant === "hacker") {
  228. mermaid.initialize({ theme: 'dark' });
  229. location.reload();
  230. } else {
  231. mermaid.initialize({ theme: 'default' });
  232. location.reload();
  233. }
  234. }
  235. var utterances = document.querySelector('iframe');
  236. if (utterances) {
  237. utterances.contentWindow.postMessage({
  238. type: 'set-theme',
  239. theme: selectedThemeVariant === "dark" || selectedThemeVariant === "hacker" ? 'photon-dark' : selectedThemeVariant === 'kimbie' ? 'github-dark-orange' : 'github-light',
  240. }, 'https://utteranc.es');
  241. }
  242. });
  243. }) : null;
  244. // ============================================================
  245. // ========================== search ==========================
  246. var baseurl = null;
  247. {{ $siteBaseURL:= .Site.BaseURL }}
  248. var siteBaseURL = JSON.parse({{ $siteBaseURL | jsonify }});
  249. var siteBaseChecker = /\/\w+\//i;
  250. var isSlug = siteBaseChecker.test(siteBaseURL);
  251. var isThemeSite = location.origin.includes('themes.gohugo.io');
  252. {{ if .Site.IsMultiLingual }}
  253. if (isThemeSite) {
  254. baseurl = "{{.Site.BaseURL}}{{.Site.LanguagePrefix}}";
  255. } else {
  256. var hasLangPostfix = location.pathname.includes("/{{.Site.Language.Lang}}");
  257. if (hasLangPostfix) {
  258. if (isSlug) {
  259. baseurl = location.origin + siteBaseURL.match(siteBaseChecker)[0] + "{{.Site.Language.Lang}}";
  260. } else {
  261. baseurl = location.origin + "/{{.Site.Language.Lang}}";
  262. }
  263. } else {
  264. if (isSlug) {
  265. baseurl = location.origin + siteBaseURL.match(siteBaseChecker)[0];
  266. } else {
  267. baseurl = location.origin;
  268. }
  269. }
  270. }
  271. {{ else }}
  272. if (isThemeSite) {
  273. baseurl = "{{.Site.BaseURL}}";
  274. } else {
  275. if (isSlug) {
  276. baseurl = location.origin + siteBaseURL.match(siteBaseChecker)[0];
  277. } else {
  278. baseurl = location.origin;
  279. }
  280. }
  281. {{ end }}
  282. var searchResults = null;
  283. var searchMenu = null;
  284. var searchText = null;
  285. {{ $enableSearchHighlight := ($.Param "enableSearchHighlight") }}
  286. var enableSearchHighlight = JSON.parse({{ $enableSearchHighlight | jsonify }});
  287. var fuse = null;
  288. function endsWith(str, suffix) {
  289. return str.indexOf(suffix, str.length - suffix.length) !== -1;
  290. }
  291. function initFuse() {
  292. if (!endsWith(baseurl, "/")) {
  293. baseurl = baseurl + '/';
  294. };
  295. var xhr = new XMLHttpRequest();
  296. xhr.open('GET', baseurl + "index.json");
  297. xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8');
  298. xhr.onload = function () {
  299. if (xhr.status === 200) {
  300. fuse = new Fuse(JSON.parse(xhr.response.toString('utf-8')), {
  301. keys: ['title', 'description', 'content'],
  302. includeMatches: enableSearchHighlight,
  303. shouldSort: true,
  304. threshold: 0.4,
  305. location: 0,
  306. distance: 100,
  307. maxPatternLength: 32,
  308. minMatchCharLength: 1,
  309. });
  310. }
  311. else {
  312. console.error(`[${xhr.status}]Error:`, xhr.statusText);
  313. }
  314. };
  315. xhr.send();
  316. }
  317. function renderSearchResults(results) { // [{}, {}, ...] or [{item: {}, matches: []}, ...]
  318. searchResults = document.getElementById('search-results');
  319. searchMenu = document.getElementById('search-menu');
  320. searchResults.setAttribute('class', 'dd is-active');
  321. var content = document.createElement('div');
  322. content.setAttribute('class', 'dd-content search-content');
  323. if (results.length > 0) {
  324. results.forEach(function (result) {
  325. var item = document.createElement('a');
  326. item.setAttribute('href', result.uri);
  327. item.setAttribute('class', 'dd-item');
  328. item.innerHTML = `<div class="menu-item"><div class="menu-item__title">📄 ${result.title}</div><div class="menu-item__desc">${result.description ? result.description : result.content}</div></div>`;
  329. content.appendChild(item);
  330. });
  331. } else {
  332. var item = document.createElement('span');
  333. item.setAttribute('class', 'dd-item');
  334. item.innerText = 'No results found';
  335. content.appendChild(item);
  336. }
  337. while (searchMenu.hasChildNodes()) {
  338. searchMenu.removeChild(
  339. searchMenu.lastChild
  340. );
  341. }
  342. searchMenu.appendChild(content);
  343. }
  344. function renderSearchHighlightResults(results) {
  345. searchResults = document.getElementById('search-results');
  346. searchMenu = document.getElementById('search-menu');
  347. searchResults.setAttribute('class', 'dd is-active');
  348. var content = document.createElement('div');
  349. content.setAttribute('class', 'dd-content search-content');
  350. if (results.length > 0) {
  351. results.forEach(function (result) {
  352. var item = document.createElement('a');
  353. item.setAttribute('href', result.item.uri);
  354. item.setAttribute('class', 'dd-item');
  355. item.innerHTML = `<div class="menu-item"><div class="menu-item__title">📄 ${generateHighlightedText(result.item.title, result.matches[0].indices)}</div><div class="menu-item__desc">${result.matches[1] ? generateHighlightedText(result.item.description, result.matches[1].indices) : result.matches[2] ? generateHighlightedText(result.item.content, result.matches[2].indices) : ''}</div></div>`;
  356. content.appendChild(item);
  357. });
  358. } else {
  359. var item = document.createElement('span');
  360. item.setAttribute('class', 'dd-item');
  361. item.innerText = 'No results found';
  362. content.appendChild(item);
  363. }
  364. while (searchMenu.hasChildNodes()) {
  365. searchMenu.removeChild(
  366. searchMenu.lastChild
  367. );
  368. }
  369. searchMenu.appendChild(content);
  370. }
  371. function renderSearchResultsMobile(results) {
  372. searchResults = document.getElementById('search-mobile-results');
  373. var content = document.createElement('div');
  374. content.setAttribute('class', 'mobile-search__content');
  375. if (results.length > 0) {
  376. results.forEach(function (result) {
  377. var item = document.createElement('a');
  378. item.setAttribute('href', result.uri);
  379. item.innerHTML = `<div class="mobile-search__item"><div class="mobile-search__item--title">📄 ${result.title}</div><div class="mobile-search__item--desc">${result.description ? result.description : result.content}</div></div>`;
  380. content.appendChild(item);
  381. });
  382. } else {
  383. var item = document.createElement('span');
  384. content.appendChild(item);
  385. }
  386. let wrap = document.getElementById('search-mobile-results');
  387. while (wrap.firstChild) {
  388. wrap.removeChild(wrap.firstChild)
  389. }
  390. searchResults.appendChild(content);
  391. }
  392. function renderSearchHighlightResultsMobile(results) {
  393. searchResults = document.getElementById('search-mobile-results');
  394. var content = document.createElement('div');
  395. content.setAttribute('class', 'mobile-search__content');
  396. if (results.length > 0) {
  397. results.forEach(function (result) {
  398. var item = document.createElement('a');
  399. item.setAttribute('href', result.item.uri);
  400. item.innerHTML = `<div class="mobile-search__item"><div class="mobile-search__item--title">📄 ${generateHighlightedText(result.item.title, result.matches[0].indices)}</div><div class="mobile-search__item--desc">${result.matches[1] ? generateHighlightedText(result.item.description, result.matches[1].indices) : result.matches[2] ? generateHighlightedText(result.item.content, result.matches[2].indices) : ''}</div></div>`;
  401. content.appendChild(item);
  402. });
  403. } else {
  404. var item = document.createElement('span');
  405. content.appendChild(item);
  406. }
  407. let wrap = document.getElementById('search-mobile-results');
  408. while (wrap.firstChild) {
  409. wrap.removeChild(wrap.firstChild)
  410. }
  411. searchResults.appendChild(content);
  412. }
  413. function generateHighlightedText(text, regions) {
  414. if (!regions) {
  415. return text;
  416. }
  417. var content = '', nextUnhighlightedRegionStartingIndex = 0;
  418. regions.forEach(function(region) {
  419. if (region[0] === region[1]) {
  420. return null;
  421. }
  422. content += '' +
  423. text.substring(nextUnhighlightedRegionStartingIndex, region[0]) +
  424. '<span class="search__highlight">' +
  425. text.substring(region[0], region[1] + 1) +
  426. '</span>' +
  427. '';
  428. nextUnhighlightedRegionStartingIndex = region[1] + 1;
  429. });
  430. content += text.substring(nextUnhighlightedRegionStartingIndex);
  431. return content;
  432. };
  433. initFuse();
  434. var searchElem = document.getElementById('search');
  435. var searchMobile = document.getElementById('search-mobile');
  436. searchElem.addEventListener('input', function(e) {
  437. if (!e.target.value) {
  438. document.getElementById('search-results').setAttribute('class', 'dd');
  439. return null;
  440. }
  441. if (window.innerWidth < 770) {
  442. return null;
  443. }
  444. searchText = e.target.value;
  445. var results = fuse.search(e.target.value);
  446. if (enableSearchHighlight) {
  447. renderSearchHighlightResults(results);
  448. } else {
  449. renderSearchResults(results);
  450. }
  451. });
  452. searchElem.addEventListener('blur', function() {
  453. if (window.innerWidth < 770) {
  454. return null;
  455. }
  456. setTimeout(function () {
  457. document.getElementById('search-results').setAttribute('class', 'dd');
  458. }, 100);
  459. });
  460. searchElem.addEventListener('click', function(e) {
  461. if (window.innerWidth < 770) {
  462. return null;
  463. }
  464. if (!e.target.value) {
  465. document.getElementById('search-results').setAttribute('class', 'dd');
  466. return null;
  467. }
  468. searchText = e.target.value;
  469. var results = fuse.search(e.target.value);
  470. if (enableSearchHighlight) {
  471. renderSearchHighlightResults(results);
  472. } else {
  473. renderSearchResults(results);
  474. }
  475. });
  476. function indexInParent(node) {
  477. var children = node.parentNode.childNodes;
  478. var num = 0;
  479. for (var i = 0; i < children.length; i++) {
  480. if (children[i] == node) return num;
  481. if (children[i].nodeType == 1) num++;
  482. }
  483. return -1;
  484. }
  485. var searchMenuElem = document.getElementById("search-menu");
  486. var activeItem = document.querySelector('#search-menu .dd-item.is-active');
  487. var activeIndex = null;
  488. var items = null;
  489. var searchContainerMaxHeight = 350;
  490. searchElem.addEventListener('keydown', function(e) {
  491. if (window.innerWidth < 770) {
  492. return null;
  493. }
  494. var items = document.querySelectorAll('#search-menu .dd-item');
  495. if (e.key === 'ArrowDown') {
  496. if (activeIndex === null) {
  497. activeIndex = 0;
  498. items[activeIndex].classList.remove('is-active');
  499. } else {
  500. items[activeIndex].classList.remove('is-active');
  501. activeIndex = activeIndex === items.length - 1 ? 0 : activeIndex + 1;
  502. }
  503. items[activeIndex].classList.add('is-active');
  504. let overflowedPixel = items[activeIndex].offsetTop + items[activeIndex].clientHeight - searchContainerMaxHeight;
  505. if (overflowedPixel > 0) {
  506. document.querySelector(".search-content").scrollTop += items[activeIndex].getBoundingClientRect().height;
  507. } else if (activeIndex === 0) {
  508. document.querySelector(".search-content").scrollTop = 0;
  509. }
  510. } else if (e.key === 'ArrowUp') {
  511. if (activeIndex === null) {
  512. activeIndex = items.length - 1;
  513. items[activeIndex].classList.remove('is-active');
  514. } else {
  515. items[activeIndex].classList.remove('is-active');
  516. activeIndex = activeIndex === 0 ? items.length - 1 : activeIndex - 1;
  517. }
  518. items[activeIndex].classList.add('is-active');
  519. let overflowedPixel = items[activeIndex].offsetTop + items[activeIndex].clientHeight - searchContainerMaxHeight;
  520. if (overflowedPixel < 0) {
  521. document.querySelector(".search-content").scrollTop -= items[activeIndex].getBoundingClientRect().height;
  522. } else {
  523. document.querySelector(".search-content").scrollTop = overflowedPixel + items[activeIndex].getBoundingClientRect().height;
  524. }
  525. } else if (e.key === 'Enter') {
  526. var currentItemLink = items[activeIndex].getAttribute('href');
  527. if (currentItemLink) {
  528. location.href = currentItemLink;
  529. }
  530. } else if (e.key === 'Escape') {
  531. e.target.value = null;
  532. if (searchResults) {
  533. searchResults.classList.remove('is-active');
  534. }
  535. }
  536. });
  537. searchMobile.addEventListener('input', function(e) {
  538. if (!e.target.value) {
  539. let wrap = document.getElementById('search-mobile-results');
  540. while (wrap.firstChild) {
  541. wrap.removeChild(wrap.firstChild);
  542. }
  543. return null;
  544. }
  545. searchText = e.target.value;
  546. var results = fuse.search(e.target.value);
  547. renderSearchResultsMobile(results);
  548. if (enableSearchHighlight) {
  549. renderSearchHighlightResultsMobile(results);
  550. } else {
  551. renderSearchResultsMobile(results);
  552. }
  553. });
  554. // ============================================================
  555. }
  556. </script>