From 6189a2cda360e606594c4bab8c9c2ce508a327fd Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Wed, 2 Dec 2020 20:57:32 +0100 Subject: [PATCH] Update ThemeSettings.plugin.js --- Plugins/ThemeSettings/ThemeSettings.plugin.js | 88 +++++++++---------- 1 file changed, 43 insertions(+), 45 deletions(-) diff --git a/Plugins/ThemeSettings/ThemeSettings.plugin.js b/Plugins/ThemeSettings/ThemeSettings.plugin.js index 33206881a6..e78cb62940 100644 --- a/Plugins/ThemeSettings/ThemeSettings.plugin.js +++ b/Plugins/ThemeSettings/ThemeSettings.plugin.js @@ -14,12 +14,12 @@ module.exports = (_ => { "info": { "name": "ThemeSettings", "author": "DevilBro", - "version": "1.2.8", + "version": "1.2.9", "description": "Allow you to change Theme Variables within BetterDiscord. Adds a Settings button (similar to Plugins) to customizable Themes in your Themes Page" }, "changeLog": { "fixed": { - "BD Beta": "Works with BD beta" + "Works again": "Yes" } } }; @@ -176,54 +176,52 @@ module.exports = (_ => { } createThemeVarInputs (theme, vars) { - let props = { - children: _ => { - let settingsItems = []; - for (let varStr of vars) { - varStr = varStr.split(":"); - let varName = varStr.shift().trim(); - varStr = varStr.join(":").split(/;[^A-z0-9]|\/\*/); - let varValue = varStr.shift().trim(); - if (varValue) { - let childType = "text", childMode = ""; - let isColor = BDFDB.ColorUtils.getType(varValue); - let isComp = !isColor && /^[0-9 ]+,[0-9 ]+,[0-9 ]+$/g.test(varValue); - if (isColor || isComp) { - childType = "color"; - childMode = isComp && "comp"; - } - else { - let isUrlFile = /url\(.+\)/gi.test(varValue); - let isFile = !isUrlFile && /(http(s)?):\/\/[(www\.)?a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/.test(varValue); - if (isFile || isUrlFile) { - childType = "file"; - childMode = isUrlFile && "url"; - } - } - let varDescription = varStr.join("").replace(/\*\/|\/\*/g, "").replace(/:/g, ": ").replace(/: \//g, ":/").replace(/--/g, " --").replace(/\( --/g, "(--").trim(); - settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, { - type: "TextInput", - margin: 20, - dividerBottom: vars[vars.length-1] != varStr, - childProps: { - type: childType, - mode: childMode, - filter: childType == "file" && "image" - }, - label: varName[0].toUpperCase() + varName.slice(1), - note: varDescription && varDescription.indexOf("*") == 0 ? varDescription.slice(1) : varDescription, - basis: "70%", - varName: varName, - value: varValue, - placeholder: varValue - })); + let settingsItems = []; + for (let varStr of vars) { + varStr = varStr.split(":"); + let varName = varStr.shift().trim(); + varStr = varStr.join(":").split(/;[^A-z0-9]|\/\*/); + let varValue = varStr.shift().trim(); + if (varValue) { + let childType = "text", childMode = ""; + let isColor = BDFDB.ColorUtils.getType(varValue); + let isComp = !isColor && /^[0-9 ]+,[0-9 ]+,[0-9 ]+$/g.test(varValue); + if (isColor || isComp) { + childType = "color"; + childMode = isComp && "comp"; + } + else { + let isUrlFile = /url\(.+\)/gi.test(varValue); + let isFile = !isUrlFile && /(http(s)?):\/\/[(www\.)?a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/.test(varValue); + if (isFile || isUrlFile) { + childType = "file"; + childMode = isUrlFile && "url"; } } - return settingsItems; + let varDescription = varStr.join("").replace(/\*\/|\/\*/g, "").replace(/:/g, ": ").replace(/: \//g, ":/").replace(/--/g, " --").replace(/\( --/g, "(--").trim(); + settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, { + type: "TextInput", + margin: 20, + dividerBottom: vars[vars.length-1] != varStr, + childProps: { + type: childType, + mode: childMode, + filter: childType == "file" && "image" + }, + label: varName[0].toUpperCase() + varName.slice(1), + note: varDescription && varDescription.indexOf("*") == 0 ? varDescription.slice(1) : varDescription, + basis: "70%", + varName: varName, + value: varValue, + placeholder: varValue + })); } }; - return BDFDB.PluginUtils.createSettingsPanel(theme, props); + return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanel, { + addon: theme, + children: settingsItems + }); } }; })(window.BDFDB_Global.PluginUtils.buildPlugin(config));