Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doxyconfig-header.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

<!--BEGIN TITLEAREA-->
<div id="titlearea">
<table cellspacing="0" cellpadding="0"> <!-- NOSONAR Web:S5256, Web:S1827 -->
<table cellspacing="0" cellpadding="0"> <!-- //NOSONAR(Web:S5256,Web:S1827) -->
<tbody>
<tr id="projectrow">
<!--BEGIN PROJECT_LOGO-->
Expand All @@ -80,7 +80,7 @@
<!--BEGIN !PROJECT_NAME-->
<!--BEGIN PROJECT_BRIEF-->
<td>
<div id="projectbrief">$projectbrief</div> <!-- NOSONAR Web:S7930 -->
<div id="projectbrief">$projectbrief</div> <!-- //NOSONAR(Web:S7930) -->
<!--END PROJECT_BRIEF-->
<!--END !PROJECT_NAME-->
<!--BEGIN DISABLE_INDEX-->
Expand Down
79 changes: 39 additions & 40 deletions doxyconfig-readthedocs-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,49 +103,48 @@ class ReadtheDocsSearch {
let url = `${ReadtheDocsSearch.serverUrl}search/?q=project:${projectSlug}/${projectVersion}+${query}&page=${page + 1}&page_size=${count}`;
console.log(url);

let firstUrl = true;

function fetchResults(url) {
$.ajax({
url: url,
dataType: 'json',
success: function (data) {
// Add the query to the search field
// This seems only be working if applied in the ajax success function...
// maybe the field is not available before this point
$('#MSearchField').val(query);

if (firstUrl) {
if (data.count > 0) {
if (data.count === 1) {
resultSummary.innerHTML = ReadtheDocsSearch.searchResultsText[1];
} else {
resultSummary.innerHTML = ReadtheDocsSearch.searchResultsText[2].replace(/\$num/, data.count);
}
} else {
resultSummary.innerHTML = ReadtheDocsSearch.searchResultsText[0];
}
}

$.each(data.results, function (i, item) {
ReadtheDocsSearch.appendResultItem(resultList, item);
});

// Add pagination
firstUrl = false;
if (data.next) {
fetchResults(data.next);
} else {
// Clear the interval when the search is complete
clearInterval(titleInterval);
pageTitle.text(originalTitle);
}
const ctx = {
query, resultSummary, resultList, titleInterval, pageTitle, originalTitle, firstUrl: true
};

ReadtheDocsSearch.fetchResults(url, ctx);
}
}

static fetchResults(url, ctx) {
$.ajax({
url: url,
dataType: 'json',
success: function(data) {
// Add the query to the search field
// This seems only be working if applied in the ajax success function...
// maybe the field is not available before this point
$('#MSearchField').val(ctx.query);

if (ctx.firstUrl) {
if (data.count === 1) {
ctx.resultSummary.innerHTML = ReadtheDocsSearch.searchResultsText[1];
} else if (data.count > 1) {
ctx.resultSummary.innerHTML = ReadtheDocsSearch.searchResultsText[2].replace(/\$num/, data.count);
} else {
ctx.resultSummary.innerHTML = ReadtheDocsSearch.searchResultsText[0];
}
ctx.firstUrl = false;
}

$.each(data.results, function(i, item) {
ReadtheDocsSearch.appendResultItem(ctx.resultList, item);
});
}

fetchResults(url);
}
if (data.next) {
ReadtheDocsSearch.fetchResults(data.next, ctx);
} else {
// Clear the interval when the search is complete
clearInterval(ctx.titleInterval);
ctx.pageTitle.text(ctx.originalTitle);
}
}
});
}

static appendResultItem(resultList, item) {
Expand Down
Loading