mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 23:06:16 -04:00
Initial pages commit
This commit is contained in:
parent
b1d73a725d
commit
56dbb3fa40
376 changed files with 252899 additions and 88317 deletions
36
docs/scripts/fulltext-search.js
Executable file
36
docs/scripts/fulltext-search.js
Executable file
|
@ -0,0 +1,36 @@
|
|||
window.Searcher = (function() {
|
||||
function Searcher() {
|
||||
this._index = lunr(function () {
|
||||
this.field('title', {boost: 10})
|
||||
this.field('body')
|
||||
this.ref('id')
|
||||
}) ;
|
||||
|
||||
this._indexContent = undefined;
|
||||
}
|
||||
|
||||
Searcher.prototype.init = function() {
|
||||
var self = this;
|
||||
|
||||
$("script[type='text/x-docstrap-searchdb']").each(function(idx, item) {
|
||||
self._indexContent = JSON.parse(item.innerHTML);
|
||||
|
||||
for (var entryId in self._indexContent) {
|
||||
self._index.add(self._indexContent[entryId]);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Searcher.prototype.search = function(searchTerm) {
|
||||
var results = [],
|
||||
searchResults = this._index.search(searchTerm);
|
||||
|
||||
for (var idx = 0; idx < searchResults.length; idx++) {
|
||||
results.push(this._indexContent[searchResults[idx].ref])
|
||||
}
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
return new Searcher();
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue