mirror of https://github.com/vacp2p/rfc.git
1 line
1.2 KiB
JavaScript
1 line
1.2 KiB
JavaScript
|
'use strict';(function(){const a=document.querySelector('#book-search-input'),b=document.querySelector('#book-search-results');if(!a)return;a.addEventListener('focus',c),a.addEventListener('keyup',d),document.addEventListener('keypress',f);function f(b){if(a===document.activeElement)return;const c=String.fromCharCode(b.charCode);if(!g(c))return;a.focus(),b.preventDefault()}function g(b){const c=a.getAttribute('data-hotkeys')||'';return c.indexOf(b)>=0}function c(){a.removeEventListener('focus',c),a.required=!0,e('/flexsearch.min.js'),e('/en.search-data.min.e4ca60e2c14afd8634e585c938ab1168879d791ec6f8098f769aaffcd87f4684.js',function(){a.required=!1,d()})}function d(){while(b.firstChild)b.removeChild(b.firstChild);if(!a.value)return;const c=window.bookSearchIndex.search(a.value,10);c.forEach(function(a){const c=h('<li><a href></a><small></small></li>'),d=c.querySelector('a'),e=c.querySelector('small');d.href=a.href,d.textContent=a.title,e.textContent=a.section,b.appendChild(c)})}function e(b,c){const a=document.createElement('script');a.defer=!0,a.async=!1,a.src=b,a.onload=c,document.head.appendChild(a)}function h(b){const a=document.createElement('div');return a.innerHTML=b,a.firstChild}})()
|