Skip to content

Commit

Permalink
Fixes #1399 Search result limit set to 100. + translation lines.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
MatthieuLP committed May 6, 2021
1 parent c38ceb9 commit 0996526
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
14 changes: 11 additions & 3 deletions admin/themes/default/template/cat_search.tpl
Expand Up @@ -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"];
Expand All @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion language/en_UK/admin.lang.php
Expand Up @@ -1166,4 +1166,5 @@
$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';
3 changes: 2 additions & 1 deletion language/fr_FR/admin.lang.php
Expand Up @@ -1168,4 +1168,5 @@
$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';

0 comments on commit 0996526

Please sign in to comment.