|
@@ -1,10 +1,27 @@
|
|
|
(function() {
|
|
(function() {
|
|
|
importScripts('lunr.min.js');
|
|
importScripts('lunr.min.js');
|
|
|
|
|
+
|
|
|
|
|
+ var searchData = [];
|
|
|
|
|
+ var searchDataRequest = new XMLHttpRequest();
|
|
|
|
|
+ searchDataRequest.open('GET', '../index.json', false);
|
|
|
|
|
+ searchDataRequest.onload = function() {
|
|
|
|
|
+ if (this.status != 200) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ searchData = JSON.parse(this.responseText);
|
|
|
|
|
+ }
|
|
|
|
|
+ searchDataRequest.send();
|
|
|
|
|
+
|
|
|
var lunrIndex = lunr(function() {
|
|
var lunrIndex = lunr(function() {
|
|
|
this.pipeline.remove(lunr.stopWordFilter);
|
|
this.pipeline.remove(lunr.stopWordFilter);
|
|
|
this.ref('href');
|
|
this.ref('href');
|
|
|
this.field('title', {boost: 50});
|
|
this.field('title', {boost: 50});
|
|
|
this.field('keywords', {boost: 20});
|
|
this.field('keywords', {boost: 20});
|
|
|
|
|
+
|
|
|
|
|
+ for (var prop in searchData) {
|
|
|
|
|
+ this.add(searchData[prop]);
|
|
|
|
|
+ }
|
|
|
|
|
+ postMessage({e: 'index-ready'});
|
|
|
});
|
|
});
|
|
|
lunr.tokenizer.seperator = /[\s\-\.]+/;
|
|
lunr.tokenizer.seperator = /[\s\-\.]+/;
|
|
|
|
|
|
|
@@ -21,22 +38,6 @@
|
|
|
}
|
|
}
|
|
|
stopWordsRequest.send();
|
|
stopWordsRequest.send();
|
|
|
|
|
|
|
|
- var searchData = {};
|
|
|
|
|
- var searchDataRequest = new XMLHttpRequest();
|
|
|
|
|
-
|
|
|
|
|
- searchDataRequest.open('GET', '../index.json');
|
|
|
|
|
- searchDataRequest.onload = function() {
|
|
|
|
|
- if (this.status != 200) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- searchData = JSON.parse(this.responseText);
|
|
|
|
|
- for (var prop in searchData) {
|
|
|
|
|
- lunrIndex.add(searchData[prop]);
|
|
|
|
|
- }
|
|
|
|
|
- postMessage({e: 'index-ready'});
|
|
|
|
|
- }
|
|
|
|
|
- searchDataRequest.send();
|
|
|
|
|
-
|
|
|
|
|
onmessage = function(oEvent) {
|
|
onmessage = function(oEvent) {
|
|
|
var q = oEvent.data.q;
|
|
var q = oEvent.data.q;
|
|
|
var chapter = oEvent.data.chapter;
|
|
var chapter = oEvent.data.chapter;
|