From cd24de3c2ed05c54230faebc16dee08dc2b606fd Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Thu, 24 Aug 2023 21:59:26 +0300 Subject: [PATCH] Reformat code. --- public/scripts/extensions/assets/index.js | 161 +++++++++++----------- public/scripts/extensions/audio/index.js | 159 +++++++++++---------- server.js | 65 ++++----- 3 files changed, 188 insertions(+), 197 deletions(-) diff --git a/public/scripts/extensions/assets/index.js b/public/scripts/extensions/assets/index.js index a12b43f49..2e730147e 100644 --- a/public/scripts/extensions/assets/index.js +++ b/public/scripts/extensions/assets/index.js @@ -4,13 +4,11 @@ TODO: */ //const DEBUG_TONY_SAMA_FORK_MODE = false -import { saveSettingsDebounced, getRequestHeaders, callPopup } from "../../../script.js"; -import { getContext, getApiUrl, extension_settings, doExtrasFetch, ModuleWorkerWrapper, modules } from "../../extensions.js"; +import { getRequestHeaders, callPopup } from "../../../script.js"; export { MODULE_NAME }; const MODULE_NAME = 'Assets'; const DEBUG_PREFIX = " "; -const UPDATE_INTERVAL = 1000; let ASSETS_JSON_URL = "https://raw.githubusercontent.com/SillyTavern/SillyTavern-Content/main/index.json" const extensionName = "assets"; @@ -30,83 +28,83 @@ const defaultSettings = { } function downloadAssetsList(url) { - updateCurrentAssets().then(function(){ - fetch(url) - .then(response => response.json()) - .then(json => { - - availableAssets = {}; - $("#assets_menu").empty(); + updateCurrentAssets().then(function () { + fetch(url) + .then(response => response.json()) + .then(json => { - console.debug(DEBUG_PREFIX,"Received assets dictionary", json); + availableAssets = {}; + $("#assets_menu").empty(); - 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, "Received assets dictionary", json); - console.debug(DEBUG_PREFIX,"Updated available assets to",availableAssets); + for (const i of json) { + //console.log(DEBUG_PREFIX,i) + if (availableAssets[i["type"]] === undefined) + availableAssets[i["type"]] = []; - for (const assetType in availableAssets) { - let assetTypeMenu = $('
', {id:"assets_audio_ambient_div", class:"assets-list-div"}); - assetTypeMenu.append(`

${assetType}

`) - for (const i in availableAssets[assetType]) { - const asset = availableAssets[assetType][i]; - const elemId = `assets_install_${assetType}_${i}`; - let element = $('