This commit is contained in:
Mirco Wittrien 2022-09-06 19:55:02 +02:00
parent 08084ad25b
commit 23837c350c
2 changed files with 153 additions and 177 deletions

View File

@ -3528,7 +3528,6 @@
"time": "Време",
"timezone": "Часова зона",
"to": "Да се",
"toast_plugin_force_updated": "{{var0}} се актуализира автоматично, тъй като версията ви беше много остаряла",
"toast_plugin_loaded": "{{var0}} е зареден",
"toast_plugin_started": "{{var0}} започна",
"toast_plugin_stopped": "{{var0}} спря",
@ -3595,7 +3594,6 @@
"time": "Čas",
"timezone": "Časové pásmo",
"to": "Na",
"toast_plugin_force_updated": "Verze {{var0}} byla automaticky aktualizována, protože vaše verze je silně zastaralá",
"toast_plugin_loaded": "{{var0}} byl načten",
"toast_plugin_started": "Byla spuštěna aplikace {{var0}}",
"toast_plugin_stopped": "Aplikace {{var0}} byla zastavena",
@ -3662,7 +3660,6 @@
"time": "Tid",
"timezone": "Tidszone",
"to": "Til",
"toast_plugin_force_updated": "{{var0}} blev automatisk opdateret, fordi din version var meget forældet",
"toast_plugin_loaded": "{{var0}} er indlæst",
"toast_plugin_started": "{{var0}} er startet",
"toast_plugin_stopped": "{{var0}} er stoppet",
@ -3729,7 +3726,6 @@
"time": "Zeit",
"timezone": "Zeitzone",
"to": "Zu",
"toast_plugin_force_updated": "{{var0}} wurde automatisch aktualisiert, da deine Version stark veraltet war",
"toast_plugin_loaded": "{{var0}} wurde geladen",
"toast_plugin_started": "{{var0}} wurde gestartet",
"toast_plugin_stopped": "{{var0}} wurde gestoppt",
@ -3796,7 +3792,6 @@
"time": "Χρόνος",
"timezone": "Ζώνη ώρας",
"to": "Προς το",
"toast_plugin_force_updated": "Το {{var0}} ενημερώθηκε αυτόματα επειδή η έκδοσή σας ήταν πολύ παλιά",
"toast_plugin_loaded": "Το {{var0}} έχει φορτωθεί",
"toast_plugin_started": "Το {{var0}} έχει ξεκινήσει",
"toast_plugin_stopped": "Το {{var0}} έχει σταματήσει",
@ -3863,7 +3858,6 @@
"time": "Hora",
"timezone": "Zona horaria",
"to": "A",
"toast_plugin_force_updated": "{{var0}} se actualizó automáticamente porque su versión estaba muy desactualizada",
"toast_plugin_loaded": "Se cargó {{var0}}",
"toast_plugin_started": "{{var0}} ha comenzado",
"toast_plugin_stopped": "{{var0}} se detuvo",
@ -3930,7 +3924,6 @@
"time": "Aika",
"timezone": "Aikavyöhyke",
"to": "Vastaanottaja",
"toast_plugin_force_updated": "{{var0}} päivitettiin automaattisesti, koska versiosi oli vanhentunut",
"toast_plugin_loaded": "{{var0}} on ladattu",
"toast_plugin_started": "{{var0}} on alkanut",
"toast_plugin_stopped": "{{var0}} on pysähtynyt",
@ -3997,7 +3990,6 @@
"time": "Temps",
"timezone": "Fuseau horaire",
"to": "À",
"toast_plugin_force_updated": "{{var0}} a été automatiquement mis à jour car votre version était très obsolète",
"toast_plugin_loaded": "{{var0}} a été chargé",
"toast_plugin_started": "{{var0}} a commencé",
"toast_plugin_stopped": "{{var0}} s'est arrêté",
@ -4064,7 +4056,6 @@
"time": "समय",
"timezone": "समय क्षेत्र",
"to": "सेवा",
"toast_plugin_force_updated": "{{var0}} अपने आप अपडेट हो गया क्योंकि आपका संस्करण काफी पुराना हो गया है",
"toast_plugin_loaded": "{{var0}} लोड कर दिया गया है",
"toast_plugin_started": "{{var0}} शुरू कर दिया गया है",
"toast_plugin_stopped": "{{var0}} रोक दिया गया है",
@ -4131,7 +4122,6 @@
"time": "Vrijeme",
"timezone": "Vremenska zona",
"to": "Do",
"toast_plugin_force_updated": "{{var0}} je automatski ažuriran jer je vaša verzija bila vrlo zastarjela",
"toast_plugin_loaded": "Učitana je {{var0}}",
"toast_plugin_started": "{{var0}} je započeo",
"toast_plugin_stopped": "{{var0}} je zaustavljen",
@ -4198,7 +4188,6 @@
"time": "Idő",
"timezone": "Időzóna",
"to": "Erre",
"toast_plugin_force_updated": "A {{var0}} automatikusan frissült, mert a verziója nagyon elavult",
"toast_plugin_loaded": "{{var0}} betöltve",
"toast_plugin_started": "A {{var0}} elindult",
"toast_plugin_stopped": "A {{var0}} leállt",
@ -4265,7 +4254,6 @@
"time": "Tempo",
"timezone": "Fuso orario",
"to": "Per",
"toast_plugin_force_updated": "{{var0}} è stato aggiornato automaticamente perché la tua versione era molto obsoleta",
"toast_plugin_loaded": "{{var0}} è stato caricato",
"toast_plugin_started": "{{var0}} è iniziato",
"toast_plugin_stopped": "{{var0}} si è fermato",
@ -4332,7 +4320,6 @@
"time": "時間",
"timezone": "タイムゾーン",
"to": "に",
"toast_plugin_force_updated": "バージョンが非常に古くなったため、 {{var0}} は自動的に更新されました",
"toast_plugin_loaded": "{{var0}} が読み込まれました",
"toast_plugin_started": "{{var0}} が開始されました",
"toast_plugin_stopped": "{{var0}} が停止しました",
@ -4399,7 +4386,6 @@
"time": "시각",
"timezone": "시간대",
"to": "에",
"toast_plugin_force_updated": "버전이 매우 오래되어 {{var0}} 이 자동으로 업데이트되었습니다.",
"toast_plugin_loaded": "{{var0}}이(가) 로드되었습니다.",
"toast_plugin_started": "{{var0}}이(가) 시작되었습니다.",
"toast_plugin_stopped": "{{var0}}이(가) 중지되었습니다.",
@ -4466,7 +4452,6 @@
"time": "Laikas",
"timezone": "Laiko zona",
"to": "Į",
"toast_plugin_force_updated": "'{{var0}}' buvo automatiškai atnaujinta, nes jūsų versija buvo labai pasenusi",
"toast_plugin_loaded": "{{var0}} buvo įkelta",
"toast_plugin_started": "{{var0}} prasidėjo",
"toast_plugin_stopped": "{{var0}} sustabdyta",
@ -4533,7 +4518,6 @@
"time": "Tijd",
"timezone": "Tijdzone",
"to": "Naar",
"toast_plugin_force_updated": "{{var0}} is automatisch bijgewerkt omdat uw versie erg verouderd was",
"toast_plugin_loaded": "{{var0}} is geladen",
"toast_plugin_started": "{{var0}} is gestart",
"toast_plugin_stopped": "{{var0}} is gestopt",
@ -4600,7 +4584,6 @@
"time": "Tid",
"timezone": "Tidssone",
"to": "Til",
"toast_plugin_force_updated": "{{var0}} ble automatisk oppdatert fordi versjonen din var veldig utdatert",
"toast_plugin_loaded": "{{var0}} er lastet inn",
"toast_plugin_started": "{{var0}} har startet",
"toast_plugin_stopped": "{{var0}} har stoppet",
@ -4667,7 +4650,6 @@
"time": "Czas",
"timezone": "Strefa czasowa",
"to": "Do",
"toast_plugin_force_updated": "{{var0}} został automatycznie zaktualizowany, ponieważ Twoja wersja była bardzo nieaktualna",
"toast_plugin_loaded": "Załadowano {{var0}}",
"toast_plugin_started": "Rozpoczęto {{var0}}",
"toast_plugin_stopped": "{{var0}} został zatrzymany",
@ -4734,7 +4716,6 @@
"time": "Tempo",
"timezone": "Fuso horário",
"to": "Para",
"toast_plugin_force_updated": "{{var0}} foi atualizado automaticamente porque sua versão estava muito desatualizada",
"toast_plugin_loaded": "{{var0}} foi carregado",
"toast_plugin_started": "{{var0}} começou",
"toast_plugin_stopped": "{{var0}} parou",
@ -4801,7 +4782,6 @@
"time": "Timp",
"timezone": "Fus orar",
"to": "La",
"toast_plugin_force_updated": "{{var0}} a fost actualizat automat deoarece versiunea dvs. a fost foarte depășită",
"toast_plugin_loaded": "{{var0}} a fost încărcat",
"toast_plugin_started": "{{var0}} a început",
"toast_plugin_stopped": "{{var0}} s-a oprit",
@ -4868,7 +4848,6 @@
"time": "Время",
"timezone": "Часовой пояс",
"to": "В",
"toast_plugin_force_updated": "Было произведено автообновление {{var0}}, так как ваша версия сильно устарела",
"toast_plugin_loaded": "{{var0}} загружен",
"toast_plugin_started": "{{var0}} запущен",
"toast_plugin_stopped": "{{var0}} остановлен",
@ -4935,7 +4914,6 @@
"time": "Tid",
"timezone": "Tidszon",
"to": "Till",
"toast_plugin_force_updated": "{{var0}} uppdaterades automatiskt eftersom din version var mycket föråldrad",
"toast_plugin_loaded": "{{var0}} har laddats",
"toast_plugin_started": "{{var0}} har startat",
"toast_plugin_stopped": "{{var0}} har slutat",
@ -5002,7 +4980,6 @@
"time": "เวลา",
"timezone": "เขตเวลา",
"to": "ถึง",
"toast_plugin_force_updated": "{{var0}} ได้รับการอัปเดตโดยอัตโนมัติเนื่องจากเวอร์ชันของคุณล้าสมัยมาก",
"toast_plugin_loaded": "โหลด {{var0}} แล้ว",
"toast_plugin_started": "{{var0}} เริ่มแล้ว",
"toast_plugin_stopped": "{{var0}} หยุดทำงาน",
@ -5069,7 +5046,6 @@
"time": "Zaman",
"timezone": "Saat dilimi",
"to": "İçin",
"toast_plugin_force_updated": "Sürümünüz çok eski olduğu için {{var0}} otomatik olarak güncellendi",
"toast_plugin_loaded": "{{var0}} yüklendi",
"toast_plugin_started": "{{var0}} başladı",
"toast_plugin_stopped": "{{var0}} durdu",
@ -5136,7 +5112,6 @@
"time": "Час",
"timezone": "Часовий пояс",
"to": "До",
"toast_plugin_force_updated": "{{var0}} було автоматично оновлено, оскільки ваша версія була дуже застарілою",
"toast_plugin_loaded": "{{var0}} завантажено",
"toast_plugin_started": "{{var0}} розпочато",
"toast_plugin_stopped": "{{var0}} зупинено",
@ -5203,7 +5178,6 @@
"time": "Thời gian",
"timezone": "Múi giờ",
"to": "Đến",
"toast_plugin_force_updated": "{{var0}} đã được cập nhật tự động vì phiên bản của bạn đã rất lỗi thời",
"toast_plugin_loaded": "{{var0}} đã được tải",
"toast_plugin_started": "{{var0}} đã bắt đầu",
"toast_plugin_stopped": "{{var0}} đã dừng",
@ -5270,7 +5244,6 @@
"time": "时间",
"timezone": "时区",
"to": "至",
"toast_plugin_force_updated": "{{var0}} 已自动更新,因为您的版本已过时",
"toast_plugin_loaded": "{{var0}} 已加载",
"toast_plugin_started": "{{var0}} 已开始",
"toast_plugin_stopped": "{{var0}} 已停止",
@ -5337,7 +5310,6 @@
"time": "時間",
"timezone": "時區",
"to": "至",
"toast_plugin_force_updated": "{{var0}} 已自動更新,因為您的版本已過時",
"toast_plugin_loaded": "{{var0}} 已加載",
"toast_plugin_started": "{{var0}} 已開始",
"toast_plugin_stopped": "{{var0}} 已停止",
@ -5404,7 +5376,6 @@
"time": "Time",
"timezone": "Timezone",
"to": "To",
"toast_plugin_force_updated": "{{var0}} was automatically updated because your Version is heavily outdated",
"toast_plugin_loaded": "{{var0}} has been loaded",
"toast_plugin_started": "{{var0}} has been started",
"toast_plugin_stopped": "{{var0}} has been stopped",

View File

@ -2,8 +2,8 @@
* @name ThemeSettings
* @author DevilBro
* @authorId 278543574059057154
* @version 1.3.4
* @description Allows you to change Theme Variables within Discord. Adds a Settings button (similar to Plugins) to customizable Themes in your Themes Page
* @version 1.3.5
* @description Allows you to change Theme Variables within Discord
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
* @patreon https://www.patreon.com/MircoWittrien
@ -14,7 +14,9 @@
module.exports = (_ => {
const changeLog = {
improved: {
"Changed Location": "Due to the new Plugin Guidelines, which forbid changes to BDs Plugin/Themes Pages, the option to change the variables for Themes are now inside the Plugin Settings of 'ThemeSettings'"
}
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
@ -61,42 +63,31 @@ module.exports = (_ => {
return class ThemeSettings extends Plugin {
onLoad () {
dir = BDFDB.BDUtils.getThemesFolder();
this.patchedModules = {
after: {
SettingsView: "componentDidMount"
}
};
}
onStart () {
for (let settingsView of document.querySelectorAll(BDFDB.dotCN.layer + BDFDB.dotCN.settingswindowstandardsidebarview)) this.addListObserver(BDFDB.DOMUtils.getParent(BDFDB.dotCN.layer, settingsView));
BDFDB.ReactUtils.forceUpdate(this);
}
onStop () {
BDFDB.DOMUtils.remove(BDFDB.dotCN._themesettingsbutton);
}
processSettingsView (e) {
this.addListObserver(BDFDB.DOMUtils.getParent(BDFDB.dotCN.layer, e.node));
}
addListObserver (layer) {
if (!layer) return;
BDFDB.ObserverUtils.connect(this, layer, {name: "cardObserver", instance: new MutationObserver(changes => changes.forEach(change => change.addedNodes.forEach(node => {
if (BDFDB.DOMUtils.containsClass(node, BDFDB.disCN._repocard)) this.appendSettingsButton(node);
if (node.nodeType != Node.TEXT_NODE) for (let child of node.querySelectorAll(BDFDB.dotCN._repocard)) this.appendSettingsButton(child);
})))}, {childList: true, subtree: true});
for (let child of layer.querySelectorAll(BDFDB.dotCN._repocard)) this.appendSettingsButton(child);
this.css = `
${BDFDB.dotCN._themesettingsgrid} {
display: grid;
grid-template-columns: 50% auto;
}
${BDFDB.dotCN._themesettingscard} {
display: flex;
align-items: center;
padding: 10px;
}
${BDFDB.dotCN._themesettingscardname} {
flex: 1 1 auto;
margin-right: 10px;
}
`;
}
appendSettingsButton (card) {
if (card.querySelector(BDFDB.dotCN._themesettingsbutton)) return;
let addon = BDFDB.ObjectUtils.get(BDFDB.ReactUtils.getInstance(card), "return.stateNode.props.addon");
if (addon && !addon.plugin && !addon.instance && addon.css) {
let css = addon.css.replace(/\r/g, "");
onStart () {}
onStop () {}
getSettingsPanel () {
let themes = window.BdApi && BdApi.Themes && BdApi.Themes.getAll && BdApi.Themes.getAll().map(theme => {
let css = theme.css.replace(/\r/g, "");
let imports = css.split("\n@import url(").splice(1).map(n => [n.split(");")[0], true]).concat(css.split("\n/* @import url(").splice(1).map(n => [n.split("); */")[0], false]));
let vars = css.split(":root");
if (vars.length > 1) {
@ -109,117 +100,131 @@ module.exports = (_ => {
}
else vars = [];
if (imports.length || vars.length) {
let footerControls = card.querySelector(BDFDB.dotCNS._repofooter + BDFDB.dotCN._repocontrols);
let settingsButton = document.createElement("button");
settingsButton.className = BDFDB.DOMUtils.formatClassName(BDFDB.disCN._repobutton, BDFDB.disCN._repocontrolsbutton, BDFDB.disCN._themesettingsbutton);
settingsButton.appendChild(BDFDB.DOMUtils.create(`<svg viewBox="0 0 20 20" style="width: 20px; height: 20px;"><path fill="none" d="M0 0h20v20H0V0z"></path><path d="M15.95 10.78c.03-.25.05-.51.05-.78s-.02-.53-.06-.78l1.69-1.32c.15-.12.19-.34.1-.51l-1.6-2.77c-.1-.18-.31-.24-.49-.18l-1.99.8c-.42-.32-.86-.58-1.35-.78L12 2.34c-.03-.2-.2-.34-.4-.34H8.4c-.2 0-.36.14-.39.34l-.3 2.12c-.49.2-.94.47-1.35.78l-1.99-.8c-.18-.07-.39 0-.49.18l-1.6 2.77c-.1.18-.06.39.1.51l1.69 1.32c-.04.25-.07.52-.07.78s.02.53.06.78L2.37 12.1c-.15.12-.19.34-.1.51l1.6 2.77c.1.18.31.24.49.18l1.99-.8c.42.32.86.58 1.35.78l.3 2.12c.04.2.2.34.4.34h3.2c.2 0 .37-.14.39-.34l.3-2.12c.49-.2.94-.47 1.35-.78l1.99.8c.18.07.39 0 .49-.18l1.6-2.77c.1-.18.06-.39-.1-.51l-1.67-1.32zM10 13c-1.65 0-3-1.35-3-3s1.35-3 3-3 3 1.35 3 3-1.35 3-3 3z"></path></svg>`));
footerControls.insertBefore(settingsButton, footerControls.firstElementChild);
settingsButton.addEventListener("click", _ => {
let importInstances = {}, inputInstances = {};
BDFDB.ModalUtils.open(this, {
header: `${addon.name} ${BDFDB.LanguageUtils.LanguageStrings.SETTINGS}`,
subHeader: "",
className: BDFDB.disCN._repomodal,
headerClassName: BDFDB.disCN._repomodalheader,
contentClassName: BDFDB.disCN._repomodalsettings,
footerClassName: BDFDB.disCN._repomodalfooter,
size: "MEDIUM",
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanel, {
addon: addon,
children: _ => {
let settingsItems = [];
let varInputs = [];
for (let i in vars) {
let varStr = vars[i].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();
varInputs.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "TextInput",
margin: 8,
childProps: {
type: childType,
mode: childMode,
filter: childType == "file" && "image",
ref: instance => {if (instance) inputInstances[i] = instance;}
},
label: varName.split("-").map(BDFDB.LibraryModules.StringUtils.upperCaseFirstChar).join(" "),
note: varDescription && varDescription.indexOf("*") == 0 ? varDescription.slice(1) : varDescription,
basis: "70%",
name: varName,
value: varValue,
oldValue: varValue,
defaultValue: varValue,
placeholder: varValue
}));
}
};
if (imports.length) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, {
title: "Imports:",
dividerBottom: varInputs.length,
children: imports.map((impo, i) => {
let name = impo[0].split("/").pop().replace(/"/g, "");
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Switch",
margin: 8,
childProps: {ref: instance => {if (instance) importInstances[i] = instance;}},
label: name[0].toUpperCase() + name.slice(1),
note: impo[0].replace(/"/g, ""),
name: impo[0],
value: impo[1],
oldValue: impo[1].toString(),
defaultValue: impo[1].toString()
});
})
}));
if (varInputs.length) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, {
title: "Variables:",
children: varInputs
}));
return settingsItems;
}
if (imports.length || vars.length) return {data: theme, imports, vars};
}).filter(n => n);
return themes && themes.length && BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN._themesettingsgrid,
children: themes.map(theme => BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN._themesettingscard,
children: [
BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN._themesettingscardname,
children: theme.data.name
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
size: BDFDB.LibraryComponents.Button.Sizes.SMALL,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
children: [
BDFDB.ReactUtils.createElement("div", {
children: "Edit"
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.marginleft4,
name: BDFDB.LibraryComponents.SvgIcon.Names.PENCIL
})
]
}),
buttons: [{
contents: BDFDB.LanguageUtils.LanguageStrings.SAVE,
color: "BRAND",
onClick: _ => this.updateTheme(addon, {imports: importInstances, inputs: inputInstances}, false)
}, {
contents: BDFDB.LanguageUtils.LanguageStrings.RESET,
look: "LINK",
onClick: _ => this.updateTheme(addon, {imports: importInstances, inputs: inputInstances}, true)
}]
});
});
settingsButton.addEventListener("mouseenter", _ => {
BDFDB.TooltipUtils.create(settingsButton, BDFDB.LanguageUtils.LanguageStrings.SETTINGS);
});
}
}
onClick: _ => {
let importInstances = {}, inputInstances = {};
BDFDB.ModalUtils.open(this, {
header: `${theme.data.name} ${BDFDB.LanguageUtils.LanguageStrings.SETTINGS}`,
subHeader: "",
size: "MEDIUM",
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanel, {
addon: theme.data,
children: _ => {
let settingsItems = [];
let varInputs = [];
for (let i in theme.vars) {
let varStr = theme.vars[i].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();
varInputs.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "TextInput",
margin: 8,
childProps: {
type: childType,
mode: childMode,
filter: childType == "file" && "image",
ref: instance => {if (instance) inputInstances[i] = instance;}
},
label: varName.split("-").map(BDFDB.LibraryModules.StringUtils.upperCaseFirstChar).join(" "),
note: varDescription && varDescription.indexOf("*") == 0 ? varDescription.slice(1) : varDescription,
basis: "70%",
name: varName,
value: varValue,
oldValue: varValue,
defaultValue: varValue,
placeholder: varValue
}));
}
};
if (theme.imports.length) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, {
title: "Imports:",
dividerBottom: varInputs.length,
children: theme.imports.map((impo, i) => {
let name = impo[0].split("/").pop().replace(/"/g, "");
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Switch",
margin: 8,
childProps: {ref: instance => {if (instance) importInstances[i] = instance;}},
label: name[0].toUpperCase() + name.slice(1),
note: impo[0].replace(/"/g, ""),
name: impo[0],
value: impo[1],
oldValue: impo[1].toString(),
defaultValue: impo[1].toString()
});
})
}));
if (varInputs.length) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, {
title: "Variables:",
children: varInputs
}));
return settingsItems;
}
}),
buttons: [{
contents: BDFDB.LanguageUtils.LanguageStrings.SAVE,
color: "BRAND",
onClick: _ => this.updateTheme(theme.data, {imports: importInstances, inputs: inputInstances}, false)
}, {
contents: BDFDB.LanguageUtils.LanguageStrings.RESET,
look: "LINK",
onClick: _ => this.updateTheme(theme.data, {imports: importInstances, inputs: inputInstances}, true)
}]
});
}
})
]
}))
});
}
updateTheme (addon, instances, reset) {
let path = BDFDB.LibraryRequires.path.join(dir, addon.filename);
updateTheme (theme, instances, reset) {
let path = BDFDB.LibraryRequires.path.join(dir, theme.filename);
let css = BDFDB.LibraryRequires.fs.readFileSync(path).toString();
if (css) {
let amount = 0;
@ -253,11 +258,11 @@ module.exports = (_ => {
if (amount > 0) {
BDFDB.ReactUtils.forceUpdate(BDFDB.ObjectUtils.toArray(instances.imports), BDFDB.ObjectUtils.toArray(instances.inputs));
BDFDB.LibraryRequires.fs.writeFileSync(path, css);
BDFDB.NotificationUtils.toast(`Updated ${amount} Variable${amount == 1 ? "" : "s"} in '${addon.filename}'`, {type: "success"});
BDFDB.NotificationUtils.toast(`Updated ${amount} Variable${amount == 1 ? "" : "s"} in '${theme.filename}'`, {type: "success"});
}
else BDFDB.NotificationUtils.toast(`There are no changed Variables to be updated in '${addon.filename}'`, {type: "warning"});
else BDFDB.NotificationUtils.toast(`There are no changed Variables to be updated in '${theme.filename}'`, {type: "warning"});
}
else BDFDB.NotificationUtils.toast(`Could not find Theme File '${addon.filename}'`, {type: "danger"});
else BDFDB.NotificationUtils.toast(`Could not find Theme File '${theme.filename}'`, {type: "danger"});
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(changeLog));