Search only in current language, fixes #48
This commit is contained in:
parent
10070f9b90
commit
7d8d5c86cf
@ -82,6 +82,7 @@
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
window.searchLanguage = <?= json_encode($page['language']) ?>;
|
||||||
window.searchTranslation = <?= json_encode($search_translations) ?>;
|
window.searchTranslation = <?= json_encode($search_translations) ?>;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -169,32 +169,41 @@
|
|||||||
function getResults(searchFor, standard) {
|
function getResults(searchFor, standard) {
|
||||||
var found = [];
|
var found = [];
|
||||||
|
|
||||||
|
var pages = tipuesearch_in.pages;
|
||||||
|
|
||||||
|
// If a searchLanguage is set, filter out all other pages
|
||||||
|
if (window.searchLanguage) {
|
||||||
|
pages = pages.filter(function(item) {
|
||||||
|
return item.url.indexOf(window.searchLanguage + "/") === 0;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if (standard) {
|
if (standard) {
|
||||||
var d_w = searchFor.split(' ');
|
var d_w = searchFor.split(' ');
|
||||||
for (var i = 0; i < tipuesearch_in.pages.length; i++) {
|
for (var i = 0; i < pages.length; i++) {
|
||||||
var score = 0;
|
var score = 0;
|
||||||
var text = tipuesearch_in.pages[i].text;
|
var text = pages[i].text;
|
||||||
for (var f = 0; f < d_w.length; f++) {
|
for (var f = 0; f < d_w.length; f++) {
|
||||||
if (d_w[f].match('^-')) {
|
if (d_w[f].match('^-')) {
|
||||||
var pat = new RegExp(d_w[f].substring(1), 'i');
|
var pat = new RegExp(d_w[f].substring(1), 'i');
|
||||||
if (tipuesearch_in.pages[i].title.search(pat) != -1 || tipuesearch_in.pages[i].text.search(pat) != -1 || tipuesearch_in.pages[i].tags.search(pat) != -1) {
|
if (pages[i].title.search(pat) != -1 || pages[i].text.search(pat) != -1 || pages[i].tags.search(pat) != -1) {
|
||||||
score = 0;
|
score = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
score += getScore(d_w[f], tipuesearch_in.pages[i]);
|
score += getScore(d_w[f], pages[i]);
|
||||||
text = highlightText(d_w[f], text);
|
text = highlightText(d_w[f], text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (score != 0) {
|
if (score != 0) {
|
||||||
found.push(makeResult(score, tipuesearch_in.pages[i], text));
|
found.push(makeResult(score, pages[i], text));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (var i = 0; i < tipuesearch_in.pages.length; i++) {
|
for (var i = 0; i < pages.length; i++) {
|
||||||
var score = getScore(searchFor, tipuesearch_in.pages[i]);
|
var score = getScore(searchFor, pages[i]);
|
||||||
if (score != 0) {
|
if (score != 0) {
|
||||||
found.push(makeResult(score, tipuesearch_in.pages[i], highlightText(searchFor, tipuesearch_in.pages[i].text)));
|
found.push(makeResult(score, pages[i], highlightText(searchFor, pages[i].text)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user