Sha256: dd7a202dcd1a1ab6b3ea7561e634dab3e9262d96d03608724d19c29846277097
Contents?: true
Size: 1.24 KB
Versions: 12
Compression:
Stored size: 1.24 KB
Contents
require([ 'gitbook', 'jquery' ], function(gitbook, $) { // Global search objects var engine = null; var initialized = false; // Set a new search engine function setEngine(Engine, config) { initialized = false; engine = new Engine(config); init(config); } // Initialize search engine with config function init(config) { if (!engine) throw new Error('No engine set for research. Set an engine using gitbook.research.setEngine(Engine).'); return engine.init(config) .then(function() { initialized = true; gitbook.events.trigger('search.ready'); }); } // Launch search for query q function query(q, offset, length) { if (!initialized) throw new Error('Search has not been initialized'); return engine.search(q, offset, length); } // Get stats about search function getEngine() { return engine? engine.name : null; } function isInitialized() { return initialized; } // Initialize gitbook.search gitbook.search = { setEngine: setEngine, getEngine: getEngine, query: query, isInitialized: isInitialized }; });
Version data entries
12 entries across 12 versions & 1 rubygems