/* TODO: */ //const DEBUG_TONY_SAMA_FORK_MODE = true import { getRequestHeaders, callPopup } from "../../../script.js"; import { deleteExtension, extensionNames, installExtension, renderExtensionTemplate } from "../../extensions.js"; import { 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" const extensionName = "assets"; const extensionFolderPath = `scripts/extensions/${extensionName}`; // 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 // //#############################// const defaultSettings = { } 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); for (const assetType of assetTypes) { let assetTypeMenu = $('
', { id: "assets_audio_ambient_div", class: "assets-list-div" }); assetTypeMenu.append(`

${assetType}

`) if (assetType == 'extension') { assetTypeMenu.append(`
To download extensions from this page, you need to have Git installed.
`); } for (const i in availableAssets[assetType]) { const asset = availableAssets[assetType][i]; const elemId = `assets_install_${assetType}_${i}`; let element = $('