mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-10 04:40:27 -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) {
|
function searchDirEntriesFromPrefix(prefix) {
|
||||||
if (selectedArchive !== null && selectedArchive.isReady()) {
|
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 {
|
} else {
|
||||||
$('#searchingArticles').hide();
|
$('#searchingArticles').hide();
|
||||||
// We have to remove the focus from the search field,
|
// 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 {Array.<DirEntry>} dirEntryArray
|
||||||
* @param {Integer} maxArticles
|
* @param {Integer} maxArticles
|
||||||
*/
|
*/
|
||||||
function populateListOfArticles(dirEntryArray, maxArticles) {
|
function populateListOfArticles(dirEntryArray) {
|
||||||
var articleListHeaderMessageDiv = $('#articleListHeaderMessage');
|
var articleListHeaderMessageDiv = $('#articleListHeaderMessage');
|
||||||
var nbDirEntry = 0;
|
var nbDirEntry = dirEntryArray ? dirEntryArray.length : 0;
|
||||||
if (dirEntryArray) {
|
|
||||||
nbDirEntry = dirEntryArray.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
var message;
|
var message;
|
||||||
if (maxArticles >= 0 && nbDirEntry >= maxArticles) {
|
if (nbDirEntry >= MAX_SEARCH_RESULT_SIZE) {
|
||||||
message = maxArticles + " first articles below (refine your search).";
|
message = "First " + MAX_SEARCH_RESULT_SIZE + " articles below (refine your search):";
|
||||||
} else {
|
} else {
|
||||||
message = nbDirEntry + " articles found.";
|
message = nbDirEntry + " articles found:";
|
||||||
}
|
}
|
||||||
if (nbDirEntry === 0) {
|
if (nbDirEntry === 0) {
|
||||||
message = "No articles found.";
|
message = "No articles found.";
|
||||||
@ -1660,12 +1656,11 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
|||||||
|
|
||||||
articleListHeaderMessageDiv.html(message);
|
articleListHeaderMessageDiv.html(message);
|
||||||
|
|
||||||
|
|
||||||
var articleListDiv = $('#articleList');
|
var articleListDiv = $('#articleList');
|
||||||
var articleListDivHtml = "";
|
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];
|
var dirEntry = dirEntryArray[i];
|
||||||
|
|
||||||
articleListDivHtml += "<a href='#' dirEntryId='" + dirEntry.toStringId().replace(/'/g, "'") +
|
articleListDivHtml += "<a href='#' dirEntryId='" + dirEntry.toStringId().replace(/'/g, "'") +
|
||||||
"' class='list-group-item'>" + dirEntry.title + "</a>";
|
"' class='list-group-item'>" + dirEntry.title + "</a>";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user