Fixes #1399 Search result limit set to 100. + translation lines.

Variable to limit the number of results is set to 100.
Added some translation lines to notice the user that he has ti refine the search.
One translation line corrected because it was in french in the uk_UK file
This commit is contained in:
Matthieu Leproux
2021-05-06 12:33:50 +02:00
parent c38ceb9b7f
commit 0996526e4b
3 changed files with 15 additions and 5 deletions

View File

@@ -12,8 +12,12 @@ var data = {json_encode($data_cat)};
// Numeric array of all categories
var categories = Object.values(data);
const RESULT_LIMIT = 100;
var str_albums_found = '{"<b>%d</b> albums found"|translate}';
var str_album_found = '{"<b>1</b> album found"|translate}';
var str_result_limit = '{"<b>%d+</b> albums found, try to refine the search"|translate}';
{literal}
var editLink = "admin.php?page=album-";
var colors = ["icon-red", "icon-blue", "icon-yellow", "icon-purple", "icon-green"];
@@ -39,14 +43,18 @@ function updateSearch () {
nbResult = 0;
categories.forEach((c) => {
if (c[0].toString().toLowerCase().search(string.toLowerCase()) != -1) {
if (c[0].toString().toLowerCase().search(string.toLowerCase()) != -1 && nbResult < RESULT_LIMIT) {
addAlbumResult(c);
nbResult++;
}
})
if (nbResult != 1) {
$('.search-album-num-result').html(str_albums_found.replace('%d', nbResult));
if (nbResult >= RESULT_LIMIT) {
$('.search-album-num-result').html(str_result_limit.replace('%d', nbResult));
} else {
$('.search-album-num-result').html(str_albums_found.replace('%d', nbResult));
}
} else {
$('.search-album-num-result').html(str_album_found);
}
@@ -104,7 +112,7 @@ function getHtmlPath (cat) {
return html
}
// Make the results appear one after one
// Make the results appear one after one [and limit results to 100]
function resultAppear(result) {
result.fadeIn();
if (result.next().length != 0) {

View File

@@ -1166,4 +1166,5 @@ $lang['Hide sub-albums'] = 'Hide sub-albums';
$lang['Apply an automatic order'] = 'Apply an automatic order';
$lang['Root'] = 'Root';
$lang['Apply to direct sub-albums'] = 'Apply to direct sub-albums';
$lang['Apply to the whole hierarchy'] = 'Appliquer à toute l\'arborescence';
$lang['Apply to the whole hierarchy'] = 'Apply to the whole hierarchy';
$lang['<b>%d+</b> albums found, try to refine the search'] = '<b>%d+</b> albums found, try to refine the search';

View File

@@ -1168,4 +1168,5 @@ $lang['Hide sub-albums'] = 'Cacher les sous-albums';
$lang['Apply an automatic order'] = 'Appliquer un ordre automatique';
$lang['Root'] = 'Racine';
$lang['Apply to direct sub-albums'] = 'Appliquer aux sous-albums';
$lang['Apply to the whole hierarchy'] = 'Appliquer à toute l\'arborescence';
$lang['Apply to the whole hierarchy'] = 'Appliquer à toute l\'arborescence';
$lang['<b>%d+</b> albums found, try to refine the search'] = '<b>%d+</b> albums trouvé, essayez d affiner la recherche';