rfc/en.search.min.91fd3c536519b...

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.0dbb4b4c8d5dbe29e0db9902513c1ca72dedc3f76bd8a0e4dcf9958e4a51b796.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}})()