MCPcopy Create free account
hub / github.com/zhongsp/TypeScript / init

Function init

docs/searcher.js:255–273  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

253 }
254
255 function init(config) {
256 results_options = config.results_options;
257 search_options = config.search_options;
258 searchbar_outer = config.searchbar_outer;
259 doc_urls = config.doc_urls;
260 searchindex = elasticlunr.Index.load(config.index);
261
262 // Set up events
263 searchicon.addEventListener('click', function(e) { searchIconClickHandler(); }, false);
264 searchbar.addEventListener('keyup', function(e) { searchbarKeyUpHandler(); }, false);
265 document.addEventListener('keydown', function(e) { globalKeyHandler(e); }, false);
266 // If the user uses the browser buttons, do the same as if a reload happened
267 window.onpopstate = function(e) { doSearchOrMarkFromUrl(); };
268 // Suppress "submit" events so the page doesn't reload when the user presses Enter
269 document.addEventListener('submit', function(e) { e.preventDefault(); }, false);
270
271 // If reloaded, do the search or mark again, depending on the current url parameters
272 doSearchOrMarkFromUrl();
273 }
274
275 function unfocusSearchbar() {
276 // hacky, but just focusing a div only works once

Callers 1

searcher.jsFile · 0.85

Calls 4

searchIconClickHandlerFunction · 0.85
searchbarKeyUpHandlerFunction · 0.85
globalKeyHandlerFunction · 0.85
doSearchOrMarkFromUrlFunction · 0.85

Tested by

no test coverage detected