/* TODO: */ //const DEBUG_TONY_SAMA_FORK_MODE = true import { getRequestHeaders, processDroppedFiles, eventSource, event_types } from '../../../script.js'; import { deleteExtension, extensionNames, getContext, installExtension, renderExtensionTemplateAsync } from '../../extensions.js'; import { POPUP_TYPE, Popup, callGenericPopup } from '../../popup.js'; import { executeSlashCommands } from '../../slash-commands.js'; import { flashHighlight, getStringHash, isValidUrl } from '../../utils.js'; export { MODULE_NAME }; const MODULE_NAME = 'assets'; const DEBUG_PREFIX = ' '; let previewAudio = null; let ASSETS_JSON_URL = 'https://raw.githubusercontent.com/SillyTavern/SillyTavern-Content/main/index.json'; // DBG //if (DEBUG_TONY_SAMA_FORK_MODE) // ASSETS_JSON_URL = "https://raw.githubusercontent.com/Tony-sama/SillyTavern-Content/main/index.json" let availableAssets = {}; let currentAssets = {}; //#############################// // Extension UI and Settings // //#############################// function filterAssets() { const searchValue = String($('#assets_search').val()).toLowerCase().trim(); const typeValue = String($('#assets_type_select').val()); if (typeValue === '') { $('#assets_menu .assets-list-div').show(); $('#assets_menu .assets-list-div h3').show(); } else { $('#assets_menu .assets-list-div h3').hide(); $('#assets_menu .assets-list-div').hide(); $(`#assets_menu .assets-list-div[data-type="${typeValue}"]`).show(); } if (searchValue === '') { $('#assets_menu .asset-block').show(); } else { $('#assets_menu .asset-block').hide(); $('#assets_menu .asset-block').filter(function () { return $(this).text().toLowerCase().includes(searchValue); }).show(); } } const KNOWN_TYPES = { 'extension': 'Extensions', 'character': 'Characters', 'ambient': 'Ambient sounds', 'bgm': 'Background music', 'blip': 'Blip sounds', }; function downloadAssetsList(url) { updateCurrentAssets().then(function () { fetch(url, { cache: 'no-cache' }) .then(response => response.json()) .then(json => { availableAssets = {}; $('#assets_menu').empty(); console.debug(DEBUG_PREFIX, 'Received assets dictionary', json); for (const i of json) { //console.log(DEBUG_PREFIX,i) if (availableAssets[i['type']] === undefined) availableAssets[i['type']] = []; availableAssets[i['type']].push(i); } console.debug(DEBUG_PREFIX, 'Updated available assets to', availableAssets); // First extensions, then everything else const assetTypes = Object.keys(availableAssets).sort((a, b) => (a === 'extension') ? -1 : (b === 'extension') ? 1 : 0); $('#assets_type_select').empty(); $('#assets_search').val(''); $('#assets_type_select').append($('