Skip to content

Commit

Permalink
rename of jssearch
Browse files Browse the repository at this point in the history
  • Loading branch information
cebe committed Apr 25, 2014
1 parent d8f6ec3 commit 2bc3ff9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
22 changes: 11 additions & 11 deletions jssearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ var jssearch = {
queryWords: [],

search: function(query) {
var words = $.jssearch.tokenizeString(query);
var words = jssearch.tokenizeString(query);
var result = {};

$.jssearch.queryWords = words.map(function(i) { return i.t; });
jssearch.queryWords = words.map(function(i) { return i.t; });

// do not search when no words given
if (!words.length) {
return result;
}

// result = $.jssearch.searchForWords(words);
// result = jssearch.searchForWords(words);
// if ($.isEmptyObject(result)) {
words = $.jssearch.completeWords(words);
$.jssearch.queryWords = words.map(function(i) { return i.t; });
result = $.jssearch.searchForWords(words);
words = jssearch.completeWords(words);
jssearch.queryWords = words.map(function(i) { return i.t; });
result = jssearch.searchForWords(words);
// }

var res = [];
Expand All @@ -75,13 +75,13 @@ var jssearch = {
searchForWords: function(words) {
var result = {};
words.forEach(function(word) {
if ($.jssearch.index[word.t]) {
$.jssearch.index[word.t].forEach(function(file) {
if (jssearch.index[word.t]) {
jssearch.index[word.t].forEach(function(file) {
if (result[file.f]) {
result[file.f].weight *= file.w * word.w;
} else {
result[file.f] = {
file: $.jssearch.files[file.f],
file: jssearch.files[file.f],
weight: file.w * word.w
};
}
Expand All @@ -95,9 +95,9 @@ var jssearch = {
var result = [];

words.forEach(function(word) {
if (!$.jssearch.index[word.t] && word.t.length > 2) {
if (!jssearch.index[word.t] && word.t.length > 2) {
// complete words that are not in the index
for(var w in $.jssearch.index) {
for(var w in jssearch.index) {
if (w.substr(0, word.t.length) === word.t) {
result.push({t: w, w: 1});
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public function exportJs()
$tokenizeString = $this->getTokenizer()->tokenizeJs();

return <<<JS
$.jssearch.index = $index;
$.jssearch.files = $files;
$.jssearch.tokenizeString = $tokenizeString;
jssearch.index = $index;
jssearch.files = $files;
jssearch.tokenizeString = $tokenizeString;
JS;
}

Expand Down

0 comments on commit 2bc3ff9

Please sign in to comment.