mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-07 19:24:56 -04:00
Fix article search messages
Former-commit-id: 09c7876e62222d3a017272ff7a4e103b11c1c5df [formerly 9712cae5383a9d42c323ada1e306f5ce44c514e3] Former-commit-id: 6234669e864111e75db441299edb5affededcf64
This commit is contained in:
parent
242334509f
commit
e42a552d43
@ -1624,7 +1624,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
||||
*/
|
||||
function searchDirEntriesFromPrefix(prefix) {
|
||||
if (selectedArchive !== null && selectedArchive.isReady()) {
|
||||
selectedArchive.findDirEntriesWithPrefix(prefix.trim(), MAX_SEARCH_RESULT_SIZE, populateListOfArticles);
|
||||
selectedArchive.findDirEntriesWithPrefix(prefix.trim(), MAX_SEARCH_RESULT_SIZE + 1, populateListOfArticles);
|
||||
} else {
|
||||
$('#searchingArticles').hide();
|
||||
// We have to remove the focus from the search field,
|
||||
@ -1641,18 +1641,14 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
||||
* @param {Array.<DirEntry>} dirEntryArray
|
||||
* @param {Integer} maxArticles
|
||||
*/
|
||||
function populateListOfArticles(dirEntryArray, maxArticles) {
|
||||
function populateListOfArticles(dirEntryArray) {
|
||||
var articleListHeaderMessageDiv = $('#articleListHeaderMessage');
|
||||
var nbDirEntry = 0;
|
||||
if (dirEntryArray) {
|
||||
nbDirEntry = dirEntryArray.length;
|
||||
}
|
||||
|
||||
var nbDirEntry = dirEntryArray ? dirEntryArray.length : 0;
|
||||
var message;
|
||||
if (maxArticles >= 0 && nbDirEntry >= maxArticles) {
|
||||
message = maxArticles + " first articles below (refine your search).";
|
||||
if (nbDirEntry >= MAX_SEARCH_RESULT_SIZE) {
|
||||
message = "First " + MAX_SEARCH_RESULT_SIZE + " articles below (refine your search):";
|
||||
} else {
|
||||
message = nbDirEntry + " articles found.";
|
||||
message = nbDirEntry + " articles found:";
|
||||
}
|
||||
if (nbDirEntry === 0) {
|
||||
message = "No articles found.";
|
||||
@ -1660,12 +1656,11 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
||||
|
||||
articleListHeaderMessageDiv.html(message);
|
||||
|
||||
|
||||
var articleListDiv = $('#articleList');
|
||||
var articleListDivHtml = "";
|
||||
for (var i = 0; i < dirEntryArray.length; i++) {
|
||||
var listLength = dirEntryArray.length < MAX_SEARCH_RESULT_SIZE ? dirEntryArray.length : MAX_SEARCH_RESULT_SIZE;
|
||||
for (var i = 0; i < listLength; i++) {
|
||||
var dirEntry = dirEntryArray[i];
|
||||
|
||||
articleListDivHtml += "<a href='#' dirEntryId='" + dirEntry.toStringId().replace(/'/g, "'") +
|
||||
"' class='list-group-item'>" + dirEntry.title + "</a>";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user