mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Simplify search logic with css classes
This commit is contained in:
@ -1250,15 +1250,14 @@ function applyFavFilter(enabled) {
|
|||||||
const selector = ['#rm_print_characters_block .character_select', '#rm_print_characters_block .group_select'].join(',');
|
const selector = ['#rm_print_characters_block .character_select', '#rm_print_characters_block .group_select'].join(',');
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
$(selector).each(function () {
|
$(selector).each(function () {
|
||||||
if ($(this).children(".flex-container").children(".ch_fav").length !== 0) {
|
if ($(this).find(".ch_fav").length !== 0) {
|
||||||
$(this).children(".flex-container").children(".ch_fav").val().toLowerCase().includes(true)
|
const shouldBeDisplayed = $(this).find(".ch_fav").val().toLowerCase().includes(true);
|
||||||
? $(this).show()
|
$(this).toggleClass('hiddenByFav', !shouldBeDisplayed);
|
||||||
: $(this).hide();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$(selector).show();
|
$(selector).removeClass('hiddenByFav');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3939,17 +3938,9 @@ $(document).ready(function () {
|
|||||||
$("#character_search_bar").on("input", function () {
|
$("#character_search_bar").on("input", function () {
|
||||||
const selector = ['#rm_print_characters_block .character_select', '#rm_print_characters_block .group_select'].join(',');
|
const selector = ['#rm_print_characters_block .character_select', '#rm_print_characters_block .group_select'].join(',');
|
||||||
const searchValue = $(this).val().trim().toLowerCase();
|
const searchValue = $(this).val().trim().toLowerCase();
|
||||||
const selectedTagId = $('#rm_tag_filter .tag.selected').attr('id');
|
|
||||||
|
|
||||||
if (!searchValue) {
|
if (!searchValue) {
|
||||||
$(selector).each(function () {
|
$(selector).removeClass('hiddenBySearch');
|
||||||
if (selectedTagId && !isElementTagged(this, selectedTagId)) {
|
|
||||||
$(this).hide();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$(this).show();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
$(selector).each(function () {
|
$(selector).each(function () {
|
||||||
const isValidSearch = $(this)
|
const isValidSearch = $(this)
|
||||||
@ -3958,23 +3949,9 @@ $(document).ready(function () {
|
|||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.includes(searchValue);
|
.includes(searchValue);
|
||||||
|
|
||||||
if (isValidSearch) {
|
$(this).toggleClass('hiddenBySearch', !isValidSearch);
|
||||||
if (selectedTagId && !isElementTagged(this, selectedTagId)) {
|
|
||||||
$(this).hide();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$(this).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$(this).hide();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedTagId) {
|
|
||||||
applyFilterToList(selectedTagId)
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#filter_by_fav").click(function () {
|
$("#filter_by_fav").click(function () {
|
||||||
|
@ -3060,7 +3060,7 @@ a {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hiddenByTag {
|
.hiddenByTag, .hiddenByFav, .hiddenBySearch {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user