Skip to content

Commit 75a1444

Browse files
committed
Update js
1 parent 3744e1a commit 75a1444

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

readthedocs/core/static-src/core/js/doc-embed/search.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ function attach_elastic_search_query_sphinx(data) {
5656
search_def
5757
.then(function (data) {
5858
var hit_list = data.results || [];
59-
var total_count = data.count || 0;
6059

6160
if (hit_list.length) {
6261
for (var i = 0; i < hit_list.length; i += 1) {
@@ -272,9 +271,14 @@ function attach_elastic_search_query_sphinx(data) {
272271
};
273272

274273
if (typeof Search !== 'undefined' && project && version) {
275-
var query_fallback = Search.query;
276-
Search.query_fallback = query_fallback;
277-
Search.query = query_override;
274+
// Do not replace the built-in search if RTD's docsearch is disabled
275+
if (!data.features || !data.features.docsearch_disabled) {
276+
var query_fallback = Search.query;
277+
Search.query_fallback = query_fallback;
278+
Search.query = query_override;
279+
} else {
280+
console.log('Server side search is disabled.');
281+
}
278282
}
279283
$(document).ready(function () {
280284
if (typeof Search !== 'undefined') {
@@ -409,19 +413,18 @@ function attach_elastic_search_query_mkdocs(data) {
409413
}
410414

411415

412-
413416
function init() {
414417
var data = rtddata.get();
415-
// Do not replace the built-in search if RTD's docsearch is disabled
416-
if (!data.features || !data.features.docsearch_disabled) {
417-
if (data.is_sphinx_builder()) {
418-
attach_elastic_search_query_sphinx(data);
419-
} else {
420-
// MkDocs projects should have this flag explicitly for now.
421-
if (data.features && !data.features.docsearch_disabled) {
422-
attach_elastic_search_query_mkdocs(data);
423-
}
424-
}
418+
if (data.is_sphinx_builder()) {
419+
// Check for disabled server side search for sphinx
420+
// happens inside the function, because we still need to call Search.init().
421+
attach_elastic_search_query_sphinx(data);
422+
}
423+
// MkDocs projects should have this flag explicitly for now.
424+
else if (data.features && !data.features.docsearch_disabled) {
425+
attach_elastic_search_query_mkdocs(data);
426+
} else {
427+
console.log('Server side search is disabled.');
425428
}
426429
}
427430

0 commit comments

Comments
 (0)