diff --git a/public/script.js b/public/script.js index b071e7e34..960ed5c55 100644 --- a/public/script.js +++ b/public/script.js @@ -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 = ` -
- -

${texts[roll]}

-

` + t`There are no items to display.` + `

-
`; + 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 = ` -
- -

` + (hidden > 1 ? t`${hidden} characters hidden.` : t`${hidden} character hidden.`) + `

-
-
-
`; +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')); diff --git a/public/scripts/templates/emptyBlock.html b/public/scripts/templates/emptyBlock.html new file mode 100644 index 000000000..3ff057acd --- /dev/null +++ b/public/scripts/templates/emptyBlock.html @@ -0,0 +1,7 @@ +
+ +

{{text}}

+

+ There are no items to display. +

+
diff --git a/public/scripts/templates/hiddenBlock.html b/public/scripts/templates/hiddenBlock.html new file mode 100644 index 000000000..6b1d84406 --- /dev/null +++ b/public/scripts/templates/hiddenBlock.html @@ -0,0 +1,6 @@ +
+ +

{{text}}

+
+
+
diff --git a/public/scripts/textgen-models.js b/public/scripts/textgen-models.js index dc1a1e644..a607d87b9 100644 --- a/public/scripts/textgen-models.js +++ b/public/scripts/textgen-models.js @@ -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 = ''; diff --git a/public/scripts/utils.js b/public/scripts/utils.js index a12492aa4..c760b9f97 100644 --- a/public/scripts/utils.js +++ b/public/scripts/utils.js @@ -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');