mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Extract templates, replace pagination format
This commit is contained in:
@ -1426,30 +1426,26 @@ function getBackBlock() {
|
||||
return template;
|
||||
}
|
||||
|
||||
function getEmptyBlock() {
|
||||
async function getEmptyBlock() {
|
||||
const icons = ['fa-dragon', 'fa-otter', 'fa-kiwi-bird', 'fa-crow', 'fa-frog'];
|
||||
const texts = [t`Here be dragons`, t`Otterly empty`, t`Kiwibunga`, t`Pump-a-Rum`, t`Croak it`];
|
||||
const roll = new Date().getMinutes() % icons.length;
|
||||
const emptyBlock = `
|
||||
<div class="text_block empty_block">
|
||||
<i class="fa-solid ${icons[roll]} fa-4x"></i>
|
||||
<h1>${texts[roll]}</h1>
|
||||
<p>` + t`There are no items to display.` + `</p>
|
||||
</div>`;
|
||||
const params = {
|
||||
text: texts[roll],
|
||||
icon: icons[roll],
|
||||
};
|
||||
const emptyBlock = await renderTemplateAsync('emptyBlock', params);
|
||||
return $(emptyBlock);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} hidden Number of hidden characters
|
||||
*/
|
||||
function getHiddenBlock(hidden) {
|
||||
const hiddenBlock = `
|
||||
<div class="text_block hidden_block">
|
||||
<small>
|
||||
<p>` + (hidden > 1 ? t`${hidden} characters hidden.` : t`${hidden} character hidden.`) + `</p>
|
||||
<div class="fa-solid fa-circle-info opacity50p" data-i18n="[title]Characters and groups hidden by filters or closed folders" title="Characters and groups hidden by filters or closed folders"></div>
|
||||
</small>
|
||||
</div>`;
|
||||
async function getHiddenBlock(hidden) {
|
||||
const params = {
|
||||
text: (hidden > 1 ? t`${hidden} characters hidden.` : t`${hidden} character hidden.`),
|
||||
};
|
||||
const hiddenBlock = await renderTemplateAsync('hiddenBlock', params);
|
||||
return $(hiddenBlock);
|
||||
}
|
||||
|
||||
@ -1542,13 +1538,14 @@ export async function printCharacters(fullRefresh = false) {
|
||||
nextText: '>',
|
||||
formatNavigator: PAGINATION_TEMPLATE,
|
||||
showNavigator: true,
|
||||
callback: function (/** @type {Entity[]} */ data) {
|
||||
callback: async function (/** @type {Entity[]} */ data) {
|
||||
$(listId).empty();
|
||||
if (power_user.bogus_folders && isBogusFolderOpen()) {
|
||||
$(listId).append(getBackBlock());
|
||||
}
|
||||
if (!data.length) {
|
||||
$(listId).append(getEmptyBlock());
|
||||
const emptyBlock = await getEmptyBlock();
|
||||
$(listId).append(emptyBlock);
|
||||
}
|
||||
let displayCount = 0;
|
||||
for (const i of data) {
|
||||
@ -1569,7 +1566,8 @@ export async function printCharacters(fullRefresh = false) {
|
||||
|
||||
const hidden = (characters.length + groups.length) - displayCount;
|
||||
if (hidden > 0 && entitiesFilter.hasAnyFilter()) {
|
||||
$(listId).append(getHiddenBlock(hidden));
|
||||
const hiddenBlock = await getHiddenBlock(hidden);
|
||||
$(listId).append(hiddenBlock);
|
||||
}
|
||||
localizePagination($('#rm_print_characters_pagination'));
|
||||
|
||||
|
Reference in New Issue
Block a user