stuff
This commit is contained in:
parent
449ae30cb7
commit
0971007afe
|
@ -16,13 +16,13 @@ module.exports = (_ => {
|
|||
"info": {
|
||||
"name": "BDFDB",
|
||||
"author": "DevilBro",
|
||||
"version": "1.1.5",
|
||||
"version": "1.1.6",
|
||||
"description": "Give other plugins utility functions"
|
||||
},
|
||||
"rawUrl": "https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js",
|
||||
"changeLog": {
|
||||
"fixed": {
|
||||
"Works ": "Can discord stop messing with the server list, jeez"
|
||||
"BD Beta": "Fixed some issues with BD Beta"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -795,22 +795,41 @@ module.exports = (_ => {
|
|||
}
|
||||
loadingIconWrapper.appendChild(icon);
|
||||
};
|
||||
BDFDB.PluginUtils.createSettingsPanel = function (plugin, children) {
|
||||
plugin = plugin == BDFDB && InternalBDFDB || plugin;
|
||||
if (!BDFDB.ObjectUtils.is(plugin) || !children || (!BDFDB.ReactUtils.isValidElement(children) && !BDFDB.ArrayUtils.is(children))) return;
|
||||
let settingsPanel = BDFDB.DOMUtils.create(`<div class="${plugin.name}-settings ${BDFDB.disCN.settingspanel}"></div>`);
|
||||
BDFDB.ReactUtils.render(BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.SettingsPanel, {
|
||||
key: `${plugin.name}-settingsPanel`,
|
||||
plugin: plugin,
|
||||
title: !isBeta && plugin.name,
|
||||
children: children
|
||||
}), settingsPanel);
|
||||
return settingsPanel;
|
||||
BDFDB.PluginUtils.createSettingsPanel = function (addon, props) {
|
||||
addon = addon == BDFDB && InternalBDFDB || addon;
|
||||
if (!BDFDB.ObjectUtils.is(addon)) return;
|
||||
if (isBeta && BDFDB.ObjectUtils.is(props)) {
|
||||
return BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.SettingsPanel, Object.assign({
|
||||
className: BDFDB.DOMUtils.formatClassName(addon.name && `${addon.name}-settings`, BDFDB.disCN.settingspanel),
|
||||
key: `${addon.name}-settingsPanel`,
|
||||
addon: addon
|
||||
}, props));
|
||||
}
|
||||
else {
|
||||
let children = BDFDB.ReactUtils.isValidElement(props) || BDFDB.ArrayUtils.is(props) ? props : (props && typeof props.children == "function" && props.children());
|
||||
if (!children || (!BDFDB.ReactUtils.isValidElement(children) && !BDFDB.ArrayUtils.is(children))) return;
|
||||
let settingsPanel = BDFDB.DOMUtils.create(`<div class="${addon.name}-settings ${BDFDB.disCN.settingspanel}"></div>`);
|
||||
BDFDB.ReactUtils.render(BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.SettingsPanel, {
|
||||
key: `${addon.name}-settingsPanel`,
|
||||
addon: addon,
|
||||
title: !isBeta && addon.name,
|
||||
collapseStates: props && props.collapseStates,
|
||||
children: children
|
||||
}), settingsPanel);
|
||||
return settingsPanel;
|
||||
}
|
||||
};
|
||||
BDFDB.PluginUtils.refreshSettingsPanel = function (plugin, settingsPanel, ...args) {
|
||||
if (!BDFDB.ObjectUtils.is(plugin) || typeof plugin.getSettingsPanel != "function" || !Node.prototype.isPrototypeOf(settingsPanel) || !settingsPanel.parentElement) return;
|
||||
settingsPanel.parentElement.appendChild(plugin.getSettingsPanel(...args));
|
||||
settingsPanel.remove();
|
||||
if (BDFDB.ObjectUtils.is(plugin)) {
|
||||
if (BDFDB.ReactUtils.isValidElement(settingsPanel)) {
|
||||
settingsPanel.props = Object.assign({}, settingsPanel.props, ...args);
|
||||
BDFDB.ReactUtils.forceUpdate(settingsPanel);
|
||||
}
|
||||
else if (typeof plugin.getSettingsPanel == "function" && Node.prototype.isPrototypeOf(settingsPanel) && settingsPanel.parentElement) {
|
||||
settingsPanel.parentElement.appendChild(plugin.getSettingsPanel(...args));
|
||||
settingsPanel.remove();
|
||||
}
|
||||
}
|
||||
};
|
||||
InternalBDFDB.addSpecialListeners = function (plugin) {
|
||||
plugin = plugin == BDFDB && InternalBDFDB || plugin;
|
||||
|
@ -6305,8 +6324,12 @@ module.exports = (_ => {
|
|||
};
|
||||
|
||||
InternalComponents.LibraryComponents.SettingsPanel = reactInitialized && class BDFDB_SettingsPanel extends LibraryModules.React.Component {
|
||||
componentDidMount() {
|
||||
let panel = BDFDB.ReactUtils.findDOMNode(this);
|
||||
if (panel) this.panel = panel;
|
||||
}
|
||||
componentWillUnmount() {
|
||||
if (BDFDB.ObjectUtils.is(this.props.plugin) && typeof this.props.plugin.onSettingsClosed == "function") this.props.plugin.onSettingsClosed();
|
||||
if (BDFDB.ObjectUtils.is(this.props.addon) && typeof this.props.addon.onSettingsClosed == "function") this.props.addon.onSettingsClosed();
|
||||
}
|
||||
render() {
|
||||
let headerItems = [
|
||||
|
@ -6324,10 +6347,14 @@ module.exports = (_ => {
|
|||
].flat(10).filter(n => n);
|
||||
|
||||
let panelItems = [
|
||||
this.props.children
|
||||
typeof this.props.children == "function" ? (_ => {
|
||||
return this.props.children(this.props.collapseStates);
|
||||
})() : this.props.children
|
||||
].flat(10).filter(n => n);
|
||||
|
||||
if (this.props.addon && this.props.addon.name) this.key = `${this.props.addon.name}-settingsPanel`;
|
||||
return BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.Flex, {
|
||||
className: this.props.className,
|
||||
direction: InternalComponents.LibraryComponents.Flex.Direction.VERTICAL,
|
||||
children: headerItems.length ? ([
|
||||
[
|
||||
|
@ -7779,19 +7806,26 @@ module.exports = (_ => {
|
|||
}
|
||||
|
||||
getSettingsPanel (collapseStates = {}) {
|
||||
let settingsPanel, settingsItems = [];
|
||||
let bdToastSetting = BDFDB.BDUtils.getSettings(BDFDB.BDUtils.settingsIds.showToasts);
|
||||
for (let key in settings) settingsItems.push(BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Switch",
|
||||
plugin: InternalBDFDB,
|
||||
disabled: key == "showToasts" && bdToastSetting,
|
||||
keys: ["settings", key],
|
||||
label: InternalBDFDB.defaults.settings[key].description,
|
||||
note: key == "showToasts" && bdToastSetting && "Disable BBDs general 'Show Toast' setting before disabling this",
|
||||
value: settings[key] || key == "showToasts" && bdToastSetting
|
||||
}));
|
||||
|
||||
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(BDFDB, settingsItems);
|
||||
let settingsPanel;
|
||||
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(BDFDB, {
|
||||
collapseStates: collapseStates,
|
||||
children: _ => {
|
||||
let bdToastSetting = BDFDB.BDUtils.getSettings(BDFDB.BDUtils.settingsIds.showToasts);
|
||||
let settingsItems = [];
|
||||
|
||||
for (let key in settings) settingsItems.push(BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Switch",
|
||||
plugin: InternalBDFDB,
|
||||
disabled: key == "showToasts" && bdToastSetting,
|
||||
keys: ["settings", key],
|
||||
label: InternalBDFDB.defaults.settings[key].description,
|
||||
note: key == "showToasts" && bdToastSetting && "Disable BBDs general 'Show Toast' setting before disabling this",
|
||||
value: settings[key] || key == "showToasts" && bdToastSetting
|
||||
}));
|
||||
|
||||
return settingsItems;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
|
|
@ -14,8 +14,13 @@ module.exports = (_ => {
|
|||
"info": {
|
||||
"name": "ServerDetails",
|
||||
"author": "DevilBro",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"description": "Show details of a server when you hover over the icon in the server list"
|
||||
},
|
||||
"changeLog": {
|
||||
"fixed": {
|
||||
"BD Beta": "Works with BD beta"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -237,172 +242,178 @@ module.exports = (_ => {
|
|||
}
|
||||
|
||||
getSettingsPanel (collapseStates = {}) {
|
||||
let settingsPanel, settingsItems = [];
|
||||
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "Settings",
|
||||
let settingsPanel;
|
||||
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, {
|
||||
collapseStates: collapseStates,
|
||||
children: Object.keys(settings).map(key => this.defaults.settings[key].cat == "settings" && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Switch",
|
||||
plugin: this,
|
||||
keys: ["settings", key],
|
||||
label: this.defaults.settings[key].description,
|
||||
value: settings[key],
|
||||
onChange: (value, instance) => {
|
||||
settings[key] = value;
|
||||
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: "BDFDB_SettingsPanel", up: true}), {name: "BDFDB_Select", all: true, noCopies: true}));
|
||||
}
|
||||
}))
|
||||
}));
|
||||
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "Tooltip Settings",
|
||||
collapseStates: collapseStates,
|
||||
children: [BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormTitle, {
|
||||
className: BDFDB.disCN.marginbottom4,
|
||||
tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H3,
|
||||
children: "Add additional details in the server tooltip for: "
|
||||
})].concat(Object.keys(settings).map(key => this.defaults.settings[key].cat == "tooltip" && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Switch",
|
||||
plugin: this,
|
||||
keys: ["settings", key],
|
||||
label: this.labels[this.defaults.settings[key].description] || BDFDB.LanguageUtils.LanguageStrings[this.defaults.settings[key].description],
|
||||
value: settings[key]
|
||||
}))).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
})).concat(Object.keys(amounts).map(key => this.defaults.amounts[key].cat == "tooltip" && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Slider",
|
||||
plugin: this,
|
||||
keys: ["amounts", key],
|
||||
label: this.defaults.amounts[key].description,
|
||||
basis: "70%",
|
||||
min: this.defaults.amounts[key].min,
|
||||
max: this.defaults.amounts[key].max,
|
||||
digits: this.defaults.amounts[key].digits,
|
||||
markerAmount: 11,
|
||||
onValueRender: value => value + this.defaults.amounts[key].unit,
|
||||
childProps: {type: "number"},
|
||||
value: amounts[key]
|
||||
}))).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
})).concat(Object.keys(colors).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "TextInput",
|
||||
plugin: this,
|
||||
keys: ["colors", key],
|
||||
basis: "70%",
|
||||
label: this.defaults.colors[key].description,
|
||||
value: colors[key],
|
||||
childProps: {type: "color"},
|
||||
placeholder: colors[key]
|
||||
})))
|
||||
}));
|
||||
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "Time Format",
|
||||
collapseStates: collapseStates,
|
||||
children: Object.keys(choices).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Select",
|
||||
plugin: this,
|
||||
keys: ["choices", key],
|
||||
label: this.defaults.choices[key].description,
|
||||
basis: "70%",
|
||||
value: choices[key],
|
||||
options: BDFDB.ObjectUtils.toArray(BDFDB.ObjectUtils.map(languages, (lang, id) => {return {value: id, label: lang.name}})),
|
||||
searchable: true,
|
||||
optionRenderer: lang => {
|
||||
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 0,
|
||||
shrink: 0,
|
||||
basis: "40%",
|
||||
children: lang.label
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 0,
|
||||
shrink: 0,
|
||||
basis: "60%",
|
||||
children: this.getTimestamp(languages[lang.value].id)
|
||||
})
|
||||
]
|
||||
});
|
||||
},
|
||||
valueRenderer: lang => {
|
||||
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 0,
|
||||
shrink: 0,
|
||||
children: lang.label
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 1,
|
||||
shrink: 0,
|
||||
basis: "70%",
|
||||
children: this.getTimestamp(languages[lang.value].id)
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
})).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
})).concat(Object.keys(formats).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "TextInput",
|
||||
plugin: this,
|
||||
keys: ["formats", key],
|
||||
label: this.defaults.formats[key].description,
|
||||
basis: "70%",
|
||||
value: formats[key],
|
||||
onChange: (value, instance) => {
|
||||
formats[key] = value;
|
||||
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: "BDFDB_SettingsPanel", up: true}), {name: "BDFDB_Select", all: true, noCopies: true}));
|
||||
}
|
||||
}))).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
})).concat(Object.keys(amounts).map(key => this.defaults.amounts[key].cat == "format" && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "TextInput",
|
||||
plugin: this,
|
||||
keys: ["amounts", key],
|
||||
label: this.defaults.amounts[key].description,
|
||||
note: this.defaults.amounts[key].note,
|
||||
basis: "20%",
|
||||
min: this.defaults.amounts[key].min,
|
||||
max: this.defaults.amounts[key].max,
|
||||
childProps: {type: "number"},
|
||||
value: amounts[key]
|
||||
}))).filter(n => n)
|
||||
}));
|
||||
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "Placeholder Guide",
|
||||
dividerTop: true,
|
||||
collapseStates: collapseStates,
|
||||
children: [
|
||||
"$hour will be replaced with the hour of the date",
|
||||
"$minute will be replaced with the minutes of the date",
|
||||
"$second will be replaced with the seconds of the date",
|
||||
"$msecond will be replaced with the milliseconds of the date",
|
||||
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
|
||||
"$year will be replaced with the year of the date",
|
||||
"$yearS will be replaced with the year in short form",
|
||||
"$month will be replaced with the month of the date",
|
||||
"$day will be replaced with the day of the date",
|
||||
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
|
||||
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
|
||||
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
|
||||
"$weekdayS will be replaced with the weekday in short format based on the Discord Language",
|
||||
"$daysago will be replaced with a string to tell you how many days ago the event occured. For Example: " + BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", 3)
|
||||
].map(string => {
|
||||
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, {
|
||||
type: BDFDB.LibraryComponents.FormComponents.FormTextTypes.DESCRIPTION,
|
||||
children: string
|
||||
});
|
||||
})
|
||||
}));
|
||||
|
||||
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
|
||||
children: _ => {
|
||||
let settingsItems = [];
|
||||
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "Settings",
|
||||
collapseStates: collapseStates,
|
||||
children: Object.keys(settings).map(key => this.defaults.settings[key].cat == "settings" && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Switch",
|
||||
plugin: this,
|
||||
keys: ["settings", key],
|
||||
label: this.defaults.settings[key].description,
|
||||
value: settings[key],
|
||||
onChange: (value, instance) => {
|
||||
settings[key] = value;
|
||||
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: "BDFDB_SettingsPanel", up: true}), {name: "BDFDB_Select", all: true, noCopies: true}));
|
||||
}
|
||||
}))
|
||||
}));
|
||||
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "Tooltip Settings",
|
||||
collapseStates: collapseStates,
|
||||
children: [BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormTitle, {
|
||||
className: BDFDB.disCN.marginbottom4,
|
||||
tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H3,
|
||||
children: "Add additional details in the server tooltip for: "
|
||||
})].concat(Object.keys(settings).map(key => this.defaults.settings[key].cat == "tooltip" && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Switch",
|
||||
plugin: this,
|
||||
keys: ["settings", key],
|
||||
label: this.labels[this.defaults.settings[key].description] || BDFDB.LanguageUtils.LanguageStrings[this.defaults.settings[key].description],
|
||||
value: settings[key]
|
||||
}))).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
})).concat(Object.keys(amounts).map(key => this.defaults.amounts[key].cat == "tooltip" && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Slider",
|
||||
plugin: this,
|
||||
keys: ["amounts", key],
|
||||
label: this.defaults.amounts[key].description,
|
||||
basis: "70%",
|
||||
min: this.defaults.amounts[key].min,
|
||||
max: this.defaults.amounts[key].max,
|
||||
digits: this.defaults.amounts[key].digits,
|
||||
markerAmount: 11,
|
||||
onValueRender: value => value + this.defaults.amounts[key].unit,
|
||||
childProps: {type: "number"},
|
||||
value: amounts[key]
|
||||
}))).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
})).concat(Object.keys(colors).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "TextInput",
|
||||
plugin: this,
|
||||
keys: ["colors", key],
|
||||
basis: "70%",
|
||||
label: this.defaults.colors[key].description,
|
||||
value: colors[key],
|
||||
childProps: {type: "color"},
|
||||
placeholder: colors[key]
|
||||
})))
|
||||
}));
|
||||
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "Time Format",
|
||||
collapseStates: collapseStates,
|
||||
children: Object.keys(choices).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Select",
|
||||
plugin: this,
|
||||
keys: ["choices", key],
|
||||
label: this.defaults.choices[key].description,
|
||||
basis: "70%",
|
||||
value: choices[key],
|
||||
options: BDFDB.ObjectUtils.toArray(BDFDB.ObjectUtils.map(languages, (lang, id) => {return {value: id, label: lang.name}})),
|
||||
searchable: true,
|
||||
optionRenderer: lang => {
|
||||
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 0,
|
||||
shrink: 0,
|
||||
basis: "40%",
|
||||
children: lang.label
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 0,
|
||||
shrink: 0,
|
||||
basis: "60%",
|
||||
children: this.getTimestamp(languages[lang.value].id)
|
||||
})
|
||||
]
|
||||
});
|
||||
},
|
||||
valueRenderer: lang => {
|
||||
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 0,
|
||||
shrink: 0,
|
||||
children: lang.label
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 1,
|
||||
shrink: 0,
|
||||
basis: "70%",
|
||||
children: this.getTimestamp(languages[lang.value].id)
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
})).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
})).concat(Object.keys(formats).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "TextInput",
|
||||
plugin: this,
|
||||
keys: ["formats", key],
|
||||
label: this.defaults.formats[key].description,
|
||||
basis: "70%",
|
||||
value: formats[key],
|
||||
onChange: (value, instance) => {
|
||||
formats[key] = value;
|
||||
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: "BDFDB_SettingsPanel", up: true}), {name: "BDFDB_Select", all: true, noCopies: true}));
|
||||
}
|
||||
}))).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
})).concat(Object.keys(amounts).map(key => this.defaults.amounts[key].cat == "format" && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "TextInput",
|
||||
plugin: this,
|
||||
keys: ["amounts", key],
|
||||
label: this.defaults.amounts[key].description,
|
||||
note: this.defaults.amounts[key].note,
|
||||
basis: "20%",
|
||||
min: this.defaults.amounts[key].min,
|
||||
max: this.defaults.amounts[key].max,
|
||||
childProps: {type: "number"},
|
||||
value: amounts[key]
|
||||
}))).filter(n => n)
|
||||
}));
|
||||
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "Placeholder Guide",
|
||||
dividerTop: true,
|
||||
collapseStates: collapseStates,
|
||||
children: [
|
||||
"$hour will be replaced with the hour of the date",
|
||||
"$minute will be replaced with the minutes of the date",
|
||||
"$second will be replaced with the seconds of the date",
|
||||
"$msecond will be replaced with the milliseconds of the date",
|
||||
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
|
||||
"$year will be replaced with the year of the date",
|
||||
"$yearS will be replaced with the year in short form",
|
||||
"$month will be replaced with the month of the date",
|
||||
"$day will be replaced with the day of the date",
|
||||
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
|
||||
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
|
||||
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
|
||||
"$weekdayS will be replaced with the weekday in short format based on the Discord Language",
|
||||
"$daysago will be replaced with a string to tell you how many days ago the event occured. For Example: " + BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", 3)
|
||||
].map(string => {
|
||||
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, {
|
||||
type: BDFDB.LibraryComponents.FormComponents.FormTextTypes.DESCRIPTION,
|
||||
children: string
|
||||
});
|
||||
})
|
||||
}));
|
||||
|
||||
return settingsItems;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onSettingsClosed () {
|
||||
|
|
|
@ -14,7 +14,7 @@ module.exports = (_ => {
|
|||
"info": {
|
||||
"name": "ThemeSettings",
|
||||
"author": "DevilBro",
|
||||
"version": "1.2.5",
|
||||
"version": "1.2.6",
|
||||
"description": "Allow you to change Theme Variables within BetterDiscord. Adds a Settings button (similar to Plugins) to customizable Themes in your Themes Page"
|
||||
},
|
||||
"changeLog": {
|
||||
|
@ -98,7 +98,7 @@ module.exports = (_ => {
|
|||
subheader: "",
|
||||
className: BDFDB.disCN._repomodal,
|
||||
size: "MEDIUM",
|
||||
children: BDFDB.ReactUtils.elementToReact(this.createThemeVarInputs(addon, vars)),
|
||||
children: this.createThemeVarInputs(addon, vars),
|
||||
buttons: [{contents: "Update", color: "GREEN", click: modal => {this.updateTheme(modal, addon);}}]
|
||||
});
|
||||
});
|
||||
|
@ -186,48 +186,53 @@ module.exports = (_ => {
|
|||
}
|
||||
|
||||
createThemeVarInputs (theme, vars, 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 props = {
|
||||
children: _ => {
|
||||
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 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 settingsItems;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return BDFDB.PluginUtils.createSettingsPanel(theme, settingsItems);
|
||||
return BDFDB.PluginUtils.createSettingsPanel(theme, isBeta ? props : props.children());
|
||||
}
|
||||
};
|
||||
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
|
||||
|
|
Loading…
Reference in New Issue