Extract templates, replace pagination format

This commit is contained in:
Cohee
2025-05-01 17:46:02 +03:00
parent e4d389a5b6
commit a089727591
5 changed files with 33 additions and 46 deletions

View File

@ -0,0 +1,7 @@
<div class="text_block empty_block">
<i class="fa-solid {{icon}} fa-4x"></i>
<h1>{{text}}</h1>
<p data-i18n="There are no items to display.">
There are no items to display.
</p>
</div>

View File

@ -0,0 +1,6 @@
<div class="text_block hidden_block">
<small>
<p>{{text}}</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>

View File

@ -5,9 +5,9 @@ import { textgenerationwebui_settings as textgen_settings, textgen_types } from
import { tokenizers } from './tokenizers.js';
import { renderTemplateAsync } from './templates.js';
import { POPUP_TYPE, callGenericPopup } from './popup.js';
import { t, translate } from './i18n.js';
import { t } from './i18n.js';
import { accountStorage } from './util/AccountStorage.js';
import { localizePagination } from './utils.js';
import { localizePagination, PAGINATION_TEMPLATE } from './utils.js';
let mancerModels = [];
let togetherModels = [];
@ -362,18 +362,7 @@ export async function loadFeatherlessModels(data) {
showSizeChanger: false,
prevText: '<',
nextText: '>',
formatNavigator: function (currentPage, totalPage) {
let translated_of;
try {
translated_of = translate('pagination_of');
if (translated_of == 'pagination_of') {
translated_of = 'of';
}
} catch (e) {
translated_of = 'of';
}
return (currentPage - 1) * perPage + 1 + ' - ' + currentPage * perPage + ` ${translated_of} ` + totalPage * perPage;
},
formatNavigator: PAGINATION_TEMPLATE,
showNavigator: true,
callback: function (modelsOnPage, pagination) {
modelCardBlock.innerHTML = '';

View File

@ -18,21 +18,8 @@ import { getCurrentLocale, t, translate } from './i18n.js';
/**
* Function returning pagination status string template.
* @type {function}
*/
export const PAGINATION_TEMPLATE = function() {
let translated_of;
try {
translated_of = translate('pagination_of');
if (translated_of == 'pagination_of') {
translated_of = 'of';
}
} catch (e) {
console.error(e);
translated_of = 'of';
}
return `<%= rangeStart %>-<%= rangeEnd %> ${translated_of} <%= totalNumber %>`;
};
export const PAGINATION_TEMPLATE = '<%= rangeStart %>-<%= rangeEnd %> .. <%= totalNumber %>';
export const localizePagination = function(container) {
let options = container.find('option');