stuff
This commit is contained in:
parent
ba7a5fc9a2
commit
31a471274d
|
@ -14,12 +14,12 @@ module.exports = (_ => {
|
||||||
"info": {
|
"info": {
|
||||||
"name": "ChatAliases",
|
"name": "ChatAliases",
|
||||||
"author": "DevilBro",
|
"author": "DevilBro",
|
||||||
"version": "2.2.3",
|
"version": "2.2.4",
|
||||||
"description": "Allow the user to configure their own chat-aliases which will automatically be replaced before the message is being sent"
|
"description": "Allow the user to configure their own chat-aliases which will automatically be replaced before the message is being sent"
|
||||||
},
|
},
|
||||||
"changeLog": {
|
"changeLog": {
|
||||||
"fixed": {
|
"fixed": {
|
||||||
"Command List": "Fixed issue where command list and autocomplete menu could be open at the same time on top of each other"
|
"New Aliases": "You can add new Aliases again"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -69,22 +69,22 @@ module.exports = (_ => {
|
||||||
onLoad () {
|
onLoad () {
|
||||||
this.defaults = {
|
this.defaults = {
|
||||||
configs: {
|
configs: {
|
||||||
case: {value: false, description: "Handle the wordvalue case sensitive"},
|
case: {value: false, description: "Handle the Word Value case sensitive"},
|
||||||
exact: {value: true, description: "Handle the wordvalue as an exact word and not as part of a word"},
|
exact: {value: true, description: "Handle the Word Value as an exact Word and not as part of a Word"},
|
||||||
autoc: {value: true, description: "Add this alias in the autocomplete menu (not for RegExp)"},
|
autoc: {value: true, description: "Add this Alias in the Autocomplete Menu (not for RegExp)"},
|
||||||
regex: {value: false, description: "Handle the wordvalue as a RegExp string"},
|
regex: {value: false, description: "Handle the Word Value as a RegExp String"},
|
||||||
file: {value: false, description: "Handle the replacevalue as a filepath"}
|
file: {value: false, description: "Handle the Replacement Value as a File Path"}
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
replaceBeforeSend: {value: true, inner: false, description: "Replace words with your aliases before a message is sent"},
|
replaceBeforeSend: {value: true, inner: false, description: "Replace Words with your Aliases before a Message is sent"},
|
||||||
addContextMenu: {value: true, inner: false, description: "Add a contextmenu entry to faster add new aliases"},
|
addContextMenu: {value: true, inner: false, description: "Add a Context Menu Entry to faster add new Aliases"},
|
||||||
addAutoComplete: {value: true, inner: false, description: "Add an autocomplete-menu for non-RegExp aliases"},
|
addAutoComplete: {value: true, inner: false, description: "Add an Autocomplete Menu for non-RegExp Aliases"},
|
||||||
triggerNormal: {value: true, inner: true, description: "Normal Message Textarea"},
|
triggerNormal: {value: true, inner: true, description: "Normal Message Textarea"},
|
||||||
triggerEdit: {value: true, inner: true, description: "Edit Message Textarea"},
|
triggerEdit: {value: true, inner: true, description: "Edit Message Textarea"},
|
||||||
triggerUpload: {value: true, inner: true, description: "Upload Message Prompt"}
|
triggerUpload: {value: true, inner: true, description: "Upload Message Prompt"}
|
||||||
},
|
},
|
||||||
amounts: {
|
amounts: {
|
||||||
minAliasLength: {value: 2, min: 1, description: "Minimal Character Length to open Autocomplete-Menu: "}
|
minAliasLength: {value: 2, min: 1, description: "Minimal Character Length to open Autocomplete Menu: "}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ module.exports = (_ => {
|
||||||
max: this.defaults.amounts[key].max,
|
max: this.defaults.amounts[key].max,
|
||||||
value: amounts[key]
|
value: amounts[key]
|
||||||
}))).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, {
|
}))).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, {
|
||||||
title: "Automatically replace aliases in:",
|
title: "Automatically replace Aliases in:",
|
||||||
children: Object.keys(settings).map(key => this.defaults.settings[key].inner && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
children: Object.keys(settings).map(key => this.defaults.settings[key].inner && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
type: "Switch",
|
type: "Switch",
|
||||||
plugin: this,
|
plugin: this,
|
||||||
|
@ -259,19 +259,19 @@ module.exports = (_ => {
|
||||||
}))
|
}))
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let values = {wordvalue: "", replacevalue: ""};
|
let values = {wordValue: "", replaceValue: ""};
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||||
title: "Add new alias",
|
title: "Add new Alias",
|
||||||
collapseStates: collapseStates,
|
collapseStates: collapseStates,
|
||||||
children: [
|
children: [
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||||
type: "Button",
|
type: "Button",
|
||||||
label: "Pick a wordvalue and replacevalue:",
|
label: "Pick a Word Value and Replacement Value:",
|
||||||
key: "ADDBUTTON",
|
key: "ADDBUTTON",
|
||||||
disabled: !Object.keys(values).every(valuename => values[valuename]),
|
disabled: !Object.keys(values).every(valuename => values[valuename]),
|
||||||
children: BDFDB.LanguageUtils.LanguageStrings.ADD,
|
children: BDFDB.LanguageUtils.LanguageStrings.ADD,
|
||||||
onClick: _ => {
|
onClick: _ => {
|
||||||
this.saveWord(values.wordvalue, values.replacevalue, settingsPanel.props._node.querySelector(".input-replacevalue input[type='file']"));
|
this.saveWord(values.wordValue, values.replaceValue, settingsPanel.props._node.querySelector(".input-replacevalue input[type='file']"));
|
||||||
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
|
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
@ -280,13 +280,13 @@ module.exports = (_ => {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (!BDFDB.ObjectUtils.isEmpty(aliases)) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
if (!BDFDB.ObjectUtils.isEmpty(aliases)) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||||
title: "Added aliases",
|
title: "Added Aliases",
|
||||||
collapseStates: collapseStates,
|
collapseStates: collapseStates,
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsList, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsList, {
|
||||||
settings: Object.keys(this.defaults.configs),
|
settings: Object.keys(this.defaults.configs),
|
||||||
data: Object.keys(aliases).map((wordvalue, i) => Object.assign({}, aliases[wordvalue], {
|
data: Object.keys(aliases).map((wordValue, i) => Object.assign({}, aliases[wordValue], {
|
||||||
key: wordvalue,
|
key: wordValue,
|
||||||
label: wordvalue
|
label: wordValue
|
||||||
})),
|
})),
|
||||||
renderLabel: data => BDFDB.ReactUtils.createElement("div", {
|
renderLabel: data => BDFDB.ReactUtils.createElement("div", {
|
||||||
style: {width: "100%"},
|
style: {width: "100%"},
|
||||||
|
@ -333,9 +333,9 @@ module.exports = (_ => {
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||||
type: "Button",
|
type: "Button",
|
||||||
color: BDFDB.LibraryComponents.Button.Colors.RED,
|
color: BDFDB.LibraryComponents.Button.Colors.RED,
|
||||||
label: "Remove all added aliases",
|
label: "Remove all added Aliases",
|
||||||
onClick: _ => {
|
onClick: _ => {
|
||||||
BDFDB.ModalUtils.confirm(this, "Are you sure you want to remove all added aliases?", _ => {
|
BDFDB.ModalUtils.confirm(this, "Are you sure you want to remove all added Aliases?", _ => {
|
||||||
aliases = {};
|
aliases = {};
|
||||||
commandAliases = {};
|
commandAliases = {};
|
||||||
BDFDB.DataUtils.remove(this, "words");
|
BDFDB.DataUtils.remove(this, "words");
|
||||||
|
@ -350,16 +350,16 @@ module.exports = (_ => {
|
||||||
title: "Config Guide",
|
title: "Config Guide",
|
||||||
collapseStates: collapseStates,
|
collapseStates: collapseStates,
|
||||||
children: [
|
children: [
|
||||||
"Case: Will replace words while comparing lowercase/uppercase. apple => apple, not APPLE or AppLe",
|
"Case: Will replace Words while comparing lowercase/uppercase. apple => apple, not APPLE or AppLe",
|
||||||
"Not Case: Will replace words while ignoring lowercase/uppercase. apple => apple, APPLE and AppLe",
|
"Not Case: Will replace Words while ignoring lowercase/uppercase. apple => apple, APPLE and AppLe",
|
||||||
"Exact: Will replace words that are exactly the replaceword. apple to pear => applepie stays applepie",
|
"Exact: Will replace Words that are exactly the Replacement Value. apple to pear => applepie stays applepie",
|
||||||
"Not Exact: Will replace words anywhere they appear. apple to pear => applepieapple to pearpiepear",
|
"Not Exact: Will replace Words anywhere they appear. apple to pear => applepieapple to pearpiepear",
|
||||||
"Autoc: Will appear in the Autocomplete Menu (if enabled)",
|
"Autoc: Will appear in the Autocomplete Menu (if enabled)",
|
||||||
[
|
[
|
||||||
"Regex: Will treat the entered wordvalue as a regular expression - ",
|
"Regex: Will treat the entered Word Value as a Regular Expression - ",
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, {href: "https://regexr.com/", children: BDFDB.LanguageUtils.LanguageStrings.HELP + "?"})
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, {href: "https://regexr.com/", children: BDFDB.LanguageUtils.LanguageStrings.HELP + "?"})
|
||||||
],
|
],
|
||||||
"File: If the replacevalue is a filepath it will try to upload the file located at the filepath"
|
"File: If the Replacement Value is a File Path it will try to upload the File located at the File Path"
|
||||||
].map(string => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, {
|
].map(string => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, {
|
||||||
type: BDFDB.LibraryComponents.FormComponents.FormTextTypes.DESCRIPTION,
|
type: BDFDB.LibraryComponents.FormComponents.FormTextTypes.DESCRIPTION,
|
||||||
children: string
|
children: string
|
||||||
|
@ -501,10 +501,10 @@ module.exports = (_ => {
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
openAddModal (wordvalue) {
|
openAddModal (wordValue) {
|
||||||
let values = {
|
let values = {
|
||||||
wordvalue,
|
wordValue,
|
||||||
replacevalue: ""
|
replaceValue: ""
|
||||||
};
|
};
|
||||||
BDFDB.ModalUtils.open(this, {
|
BDFDB.ModalUtils.open(this, {
|
||||||
size: "MEDIUM",
|
size: "MEDIUM",
|
||||||
|
@ -531,7 +531,7 @@ module.exports = (_ => {
|
||||||
let configInput = modal.querySelector(`.input-config${key} ${BDFDB.dotCN.switchinner}`);
|
let configInput = modal.querySelector(`.input-config${key} ${BDFDB.dotCN.switchinner}`);
|
||||||
if (configInput) configs[key] = configInput.checked;
|
if (configInput) configs[key] = configInput.checked;
|
||||||
}
|
}
|
||||||
this.saveWord(values.wordvalue, values.replacevalue, modal.querySelector(".input-replacevalue input[type='file']"), configs);
|
this.saveWord(values.wordValue, values.replaceValue, modal.querySelector(".input-replacevalue input[type='file']"), configs);
|
||||||
this.forceUpdateAll();
|
this.forceUpdateAll();
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
@ -544,13 +544,13 @@ module.exports = (_ => {
|
||||||
title: "Replace:",
|
title: "Replace:",
|
||||||
className: BDFDB.disCN.marginbottom8,
|
className: BDFDB.disCN.marginbottom8,
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||||
value: values.wordvalue,
|
value: values.wordValue,
|
||||||
placeholder: values.wordvalue,
|
placeholder: values.wordValue,
|
||||||
errorMessage: !values.wordvalue && "Choose a wordvalue" || aliases[values.wordvalue] && "Wordvalue already used, saving will overwrite old alias",
|
errorMessage: !values.wordValue && "Choose a Word Value" || aliases[values.wordValue] && "Word Value already used, saving will overwrite old Alias",
|
||||||
onChange: (value, instance) => {
|
onChange: (value, instance) => {
|
||||||
values.wordvalue = value.trim();
|
values.wordValue = value.trim();
|
||||||
if (!values.wordvalue) instance.props.errorMessage = "Choose a wordvalue";
|
if (!values.wordValue) instance.props.errorMessage = "Choose a Word Value";
|
||||||
else if (aliases[values.wordvalue]) instance.props.errorMessage = "Wordvalue already used, saving will overwrite old alias";
|
else if (aliases[values.wordValue]) instance.props.errorMessage = "Word Value already used, saving will overwrite old Alias";
|
||||||
else delete instance.props.errorMessage;
|
else delete instance.props.errorMessage;
|
||||||
let addButtonIns = BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: ["BDFDB_Modal", "BDFDB_SettingsPanel"], up: true}), {key: "ADDBUTTON"});
|
let addButtonIns = BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: ["BDFDB_Modal", "BDFDB_SettingsPanel"], up: true}), {key: "ADDBUTTON"});
|
||||||
if (addButtonIns) {
|
if (addButtonIns) {
|
||||||
|
@ -564,15 +564,16 @@ module.exports = (_ => {
|
||||||
title: "With:",
|
title: "With:",
|
||||||
className: BDFDB.disCN.marginbottom8,
|
className: BDFDB.disCN.marginbottom8,
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||||
|
className: "input-replacevalue",
|
||||||
type: "file",
|
type: "file",
|
||||||
useFilePath: true,
|
useFilePath: true,
|
||||||
value: values.replacevalue,
|
value: values.replaceValue,
|
||||||
placeholder: values.replacevalue,
|
placeholder: values.replaceValue,
|
||||||
autoFocus: true,
|
autoFocus: true,
|
||||||
errorMessage: !values.replacevalue && "Choose a replacevalue",
|
errorMessage: !values.replaceValue && "Choose a Replacement Value",
|
||||||
onChange: (value, instance) => {
|
onChange: (value, instance) => {
|
||||||
values.replacevalue = value.trim();
|
values.replaceValue = value.trim();
|
||||||
if (!values.replacevalue) instance.props.errorMessage = "Choose a replacevalue";
|
if (!values.replaceValue) instance.props.errorMessage = "Choose a Replacement Value";
|
||||||
else delete instance.props.errorMessage;
|
else delete instance.props.errorMessage;
|
||||||
let addButtonIns = BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: ["BDFDB_Modal", "BDFDB_SettingsPanel"], up: true}), {key: "ADDBUTTON"});
|
let addButtonIns = BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: ["BDFDB_Modal", "BDFDB_SettingsPanel"], up: true}), {key: "ADDBUTTON"});
|
||||||
if (addButtonIns) {
|
if (addButtonIns) {
|
||||||
|
@ -585,21 +586,22 @@ module.exports = (_ => {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
saveWord (wordvalue, replacevalue, fileselection, aliasConfigs = configs) {
|
saveWord (wordValue, replaceValue, fileSelection, aliasConfigs = configs) {
|
||||||
if (!wordvalue || !replacevalue || !fileselection) return;
|
console.log(wordValue, replaceValue, fileSelection);
|
||||||
|
if (!wordValue || !replaceValue || !fileSelection) return;
|
||||||
let filedata = null;
|
let filedata = null;
|
||||||
if (fileselection.files && fileselection.files[0] && BDFDB.LibraryRequires.fs.existsSync(replacevalue)) {
|
if (fileSelection.files && fileSelection.files[0] && BDFDB.LibraryRequires.fs.existsSync(replaceValue)) {
|
||||||
filedata = JSON.stringify({
|
filedata = JSON.stringify({
|
||||||
data: BDFDB.LibraryRequires.fs.readFileSync(replacevalue).toString("base64"),
|
data: BDFDB.LibraryRequires.fs.readFileSync(replaceValue).toString("base64"),
|
||||||
name: fileselection.files[0].name,
|
name: fileSelection.files[0].name,
|
||||||
type: fileselection.files[0].type
|
type: fileSelection.files[0].type
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
aliases[wordvalue] = {
|
aliases[wordValue] = {
|
||||||
replace: replacevalue,
|
replace: replaceValue,
|
||||||
filedata: filedata,
|
filedata: filedata,
|
||||||
case: aliasConfigs.case,
|
case: aliasConfigs.case,
|
||||||
exact: wordvalue.indexOf(" ") > -1 ? false : aliasConfigs.exact,
|
exact: wordValue.indexOf(" ") > -1 ? false : aliasConfigs.exact,
|
||||||
autoc: aliasConfigs.regex ? false : aliasConfigs.autoc,
|
autoc: aliasConfigs.regex ? false : aliasConfigs.autoc,
|
||||||
regex: aliasConfigs.regex,
|
regex: aliasConfigs.regex,
|
||||||
file: filedata != null
|
file: filedata != null
|
||||||
|
|
|
@ -77,8 +77,8 @@ module.exports = (_ => {
|
||||||
regex: {value: false, noBlocked: false, description: "Handle the Word Value as a RegExp String"}
|
regex: {value: false, noBlocked: false, description: "Handle the Word Value as a RegExp String"}
|
||||||
},
|
},
|
||||||
replaces: {
|
replaces: {
|
||||||
blocked: {value: "~~BLOCKED~~", description: "Default Replacement Word for blocked Messages: "},
|
blocked: {value: "~~BLOCKED~~", description: "Default Replacement Value for blocked Messages: "},
|
||||||
censored: {value: "$!%&%!&", description: "Default Replacement Word for censored Messages: "}
|
censored: {value: "$!%&%!&", description: "Default Replacement Value for censored Messages: "}
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
addContextMenu: {value: true, description: "Add a Context Menu Entry to faster add new blocked/censored Words"},
|
addContextMenu: {value: true, description: "Add a Context Menu Entry to faster add new blocked/censored Words"},
|
||||||
|
@ -147,7 +147,7 @@ module.exports = (_ => {
|
||||||
placeholder: this.defaults.replaces[rType].value
|
placeholder: this.defaults.replaces[rType].value
|
||||||
})))
|
})))
|
||||||
}));
|
}));
|
||||||
let values = {wordvalue: "", replacevalue: "", choice: "blocked"};
|
let values = {wordValue: "", replaceValue: "", choice: "blocked"};
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||||
title: `Add new blocked/censored word`,
|
title: `Add new blocked/censored word`,
|
||||||
collapseStates: collapseStates,
|
collapseStates: collapseStates,
|
||||||
|
@ -171,9 +171,9 @@ module.exports = (_ => {
|
||||||
collapseStates: collapseStates,
|
collapseStates: collapseStates,
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsList, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsList, {
|
||||||
settings: Object.keys(this.defaults.configs).filter(n => !this.defaults.configs[n]["no" + BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(rType)]),
|
settings: Object.keys(this.defaults.configs).filter(n => !this.defaults.configs[n]["no" + BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(rType)]),
|
||||||
data: Object.keys(words[rType]).map(wordvalue => Object.assign({}, words[rType][wordvalue], {
|
data: Object.keys(words[rType]).map(wordValue => Object.assign({}, words[rType][wordValue], {
|
||||||
key: wordvalue,
|
key: wordValue,
|
||||||
label: wordvalue
|
label: wordValue
|
||||||
})),
|
})),
|
||||||
renderLabel: data => BDFDB.ReactUtils.createElement("div", {
|
renderLabel: data => BDFDB.ReactUtils.createElement("div", {
|
||||||
style: {width: "100%"},
|
style: {width: "100%"},
|
||||||
|
@ -240,9 +240,9 @@ module.exports = (_ => {
|
||||||
"Not Exact: Will block/censor all Words containing the selected Word. apple => apple, applepie and pineapple",
|
"Not Exact: Will block/censor all Words containing the selected Word. apple => apple, applepie and pineapple",
|
||||||
"Segment: Will only replace the caught segment in the censored Word. apple with peach => applepie => peachpie",
|
"Segment: Will only replace the caught segment in the censored Word. apple with peach => applepie => peachpie",
|
||||||
"Not Segment: Will replae the whole censored Word. apple with peach => applepie => peach",
|
"Not Segment: Will replae the whole censored Word. apple with peach => applepie => peach",
|
||||||
"Empty: Ignores the default/choosen Replacement Word and removes the Word/Message instead.",
|
"Empty: Ignores the default/choosen Replacement Value and removes the Word/Message instead.",
|
||||||
[
|
[
|
||||||
"Regex: Will treat the entered wordvalue as a regular expression. ",
|
"Regex: Will treat the entered Word Value as a Regular Expression. ",
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, {href: "https://regexr.com/", children: BDFDB.LanguageUtils.LanguageStrings.HELP + "?"})
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, {href: "https://regexr.com/", children: BDFDB.LanguageUtils.LanguageStrings.HELP + "?"})
|
||||||
],
|
],
|
||||||
].map(string => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, {
|
].map(string => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, {
|
||||||
|
@ -506,8 +506,8 @@ module.exports = (_ => {
|
||||||
return new RegExp(BDFDB.StringUtils.htmlEscape(config.exact ? "^" + escapedWord + "$" : escapedWord), `${config.case ? "" : "i"}${config.exact ? "" : "g"}`);
|
return new RegExp(BDFDB.StringUtils.htmlEscape(config.exact ? "^" + escapedWord + "$" : escapedWord), `${config.case ? "" : "i"}${config.exact ? "" : "g"}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
openAddModal (wordvalue) {
|
openAddModal (wordValue) {
|
||||||
let values = {wordvalue, replacevalue: "", choice: "blocked"};
|
let values = {wordValue, replaceValue: "", choice: "blocked"};
|
||||||
BDFDB.ModalUtils.open(this, {
|
BDFDB.ModalUtils.open(this, {
|
||||||
size: "MEDIUM",
|
size: "MEDIUM",
|
||||||
header: BDFDB.LanguageUtils.LibraryStringsFormat("add_to", "ChatFilter"),
|
header: BDFDB.LanguageUtils.LibraryStringsFormat("add_to", "ChatFilter"),
|
||||||
|
@ -523,7 +523,7 @@ module.exports = (_ => {
|
||||||
].flat(10).filter(n => n),
|
].flat(10).filter(n => n),
|
||||||
buttons: [{
|
buttons: [{
|
||||||
key: "ADDBUTTON",
|
key: "ADDBUTTON",
|
||||||
disabled: !values.wordvalue,
|
disabled: !values.wordValue,
|
||||||
contents: BDFDB.LanguageUtils.LanguageStrings.ADD,
|
contents: BDFDB.LanguageUtils.LanguageStrings.ADD,
|
||||||
color: "BRAND",
|
color: "BRAND",
|
||||||
close: true,
|
close: true,
|
||||||
|
@ -547,17 +547,17 @@ module.exports = (_ => {
|
||||||
className: BDFDB.disCN.marginbottom8,
|
className: BDFDB.disCN.marginbottom8,
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||||
key: "WORDVALUE",
|
key: "WORDVALUE",
|
||||||
value: values.wordvalue,
|
value: values.wordValue,
|
||||||
placeholder: values.wordvalue,
|
placeholder: values.wordValue,
|
||||||
errorMessage: !values.wordvalue && "Choose a Word Value" || words[values.choice][values.wordvalue] && `Word Value already used, saving will overwrite old ${values.choice} Word`,
|
errorMessage: !values.wordValue && "Choose a Word Value" || words[values.choice][values.wordValue] && `Word Value already used, saving will overwrite old ${values.choice} Word`,
|
||||||
onChange: (value, instance) => {
|
onChange: (value, instance) => {
|
||||||
values.wordvalue = value.trim();
|
values.wordValue = value.trim();
|
||||||
if (!values.wordvalue) instance.props.errorMessage = "Choose a Word Value";
|
if (!values.wordValue) instance.props.errorMessage = "Choose a Word Value";
|
||||||
else if (words[values.choice][values.wordvalue]) instance.props.errorMessage = `Word Value already used, saving will overwrite old ${values.choice} word`;
|
else if (words[values.choice][values.wordValue]) instance.props.errorMessage = `Word Value already used, saving will overwrite old ${values.choice} word`;
|
||||||
else delete instance.props.errorMessage;
|
else delete instance.props.errorMessage;
|
||||||
let addButtonIns = BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: ["BDFDB_Modal", "BDFDB_SettingsPanel"], up: true}), {key: "ADDBUTTON"});
|
let addButtonIns = BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: ["BDFDB_Modal", "BDFDB_SettingsPanel"], up: true}), {key: "ADDBUTTON"});
|
||||||
if (addButtonIns) {
|
if (addButtonIns) {
|
||||||
addButtonIns.props.disabled = !values.wordvalue;
|
addButtonIns.props.disabled = !values.wordValue;
|
||||||
BDFDB.ReactUtils.forceUpdate(addButtonIns);
|
BDFDB.ReactUtils.forceUpdate(addButtonIns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -567,11 +567,11 @@ module.exports = (_ => {
|
||||||
title: "With:",
|
title: "With:",
|
||||||
className: BDFDB.disCN.marginbottom8,
|
className: BDFDB.disCN.marginbottom8,
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||||
value: values.replacevalue,
|
value: values.replaceValue,
|
||||||
placeholder: values.replacevalue,
|
placeholder: values.replaceValue,
|
||||||
autoFocus: true,
|
autoFocus: true,
|
||||||
onChange: (value, instance) => {
|
onChange: (value, instance) => {
|
||||||
values.replacevalue = value.trim();
|
values.replaceValue = value.trim();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
|
@ -581,12 +581,12 @@ module.exports = (_ => {
|
||||||
options: [{value: "blocked", name: "Block"}, {value: "censored", name: "Censor"}],
|
options: [{value: "blocked", name: "Block"}, {value: "censored", name: "Censor"}],
|
||||||
onChange: (value, instance) => {
|
onChange: (value, instance) => {
|
||||||
values.choice = value.value;
|
values.choice = value.value;
|
||||||
let wordvalueInputIns = BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: ["BDFDB_Modal", "BDFDB_SettingsPanel"], up: true}), {key: "WORDVALUE"});
|
let wordValueInputIns = BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: ["BDFDB_Modal", "BDFDB_SettingsPanel"], up: true}), {key: "WORDVALUE"});
|
||||||
if (wordvalueInputIns) {
|
if (wordValueInputIns) {
|
||||||
if (!values.wordvalue) wordvalueInputIns.props.errorMessage = "Choose a Word Value";
|
if (!values.wordValue) wordValueInputIns.props.errorMessage = "Choose a Word Value";
|
||||||
else if (words[values.choice][values.wordvalue]) wordvalueInputIns.props.errorMessage = `Word Value already used, saving will overwrite old ${values.choice} Word`;
|
else if (words[values.choice][values.wordValue]) wordValueInputIns.props.errorMessage = `Word Value already used, saving will overwrite old ${values.choice} Word`;
|
||||||
else delete wordvalueInputIns.props.errorMessage;
|
else delete wordValueInputIns.props.errorMessage;
|
||||||
BDFDB.ReactUtils.forceUpdate(wordvalueInputIns);
|
BDFDB.ReactUtils.forceUpdate(wordValueInputIns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -594,15 +594,15 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
|
|
||||||
saveWord (values, wordConfigs = configs) {
|
saveWord (values, wordConfigs = configs) {
|
||||||
if (!values.wordvalue || !values.choice) return;
|
if (!values.wordValue || !values.choice) return;
|
||||||
values.wordvalue = values.wordvalue.trim();
|
values.wordValue = values.wordValue.trim();
|
||||||
values.replacevalue = values.replacevalue.trim();
|
values.replaceValue = values.replaceValue.trim();
|
||||||
if (!BDFDB.ObjectUtils.is(words[values.choice])) words[values.choice] = {};
|
if (!BDFDB.ObjectUtils.is(words[values.choice])) words[values.choice] = {};
|
||||||
words[values.choice][values.wordvalue] = {
|
words[values.choice][values.wordValue] = {
|
||||||
replace: values.replacevalue,
|
replace: values.replaceValue,
|
||||||
empty: wordConfigs.empty,
|
empty: wordConfigs.empty,
|
||||||
case: wordConfigs.case,
|
case: wordConfigs.case,
|
||||||
exact: values.wordvalue.indexOf(" ") > -1 ? false : wordConfigs.exact,
|
exact: values.wordValue.indexOf(" ") > -1 ? false : wordConfigs.exact,
|
||||||
regex: false
|
regex: false
|
||||||
};
|
};
|
||||||
BDFDB.DataUtils.save(words, this, "words");
|
BDFDB.DataUtils.save(words, this, "words");
|
||||||
|
|
Loading…
Reference in New Issue