stuff
This commit is contained in:
parent
3e6e92df27
commit
5882330cbd
|
@ -43,9 +43,9 @@ var ChatAliases = (_ => {
|
||||||
file: {value:false, description:"Handle the replacevalue as a filepath"}
|
file: {value:false, description:"Handle the replacevalue as a filepath"}
|
||||||
},
|
},
|
||||||
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 contextMenu 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"}
|
||||||
|
@ -85,7 +85,7 @@ var ChatAliases = (_ => {
|
||||||
value: amounts[key]
|
value: amounts[key]
|
||||||
}));
|
}));
|
||||||
innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelInner, {
|
innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelInner, {
|
||||||
title: "Automatically replace Aliases in:",
|
title: "Automatically replace aliases in:",
|
||||||
first: innerItems.length == 0,
|
first: innerItems.length == 0,
|
||||||
last: true,
|
last: true,
|
||||||
children: subInnerItems
|
children: subInnerItems
|
||||||
|
@ -97,13 +97,13 @@ var ChatAliases = (_ => {
|
||||||
}));
|
}));
|
||||||
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,
|
||||||
dividertop: true,
|
dividertop: true,
|
||||||
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 wordvalue and replacevalue:",
|
||||||
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,
|
||||||
|
@ -116,7 +116,7 @@ var ChatAliases = (_ => {
|
||||||
].flat(10).filter(n => n)
|
].flat(10).filter(n => n)
|
||||||
}));
|
}));
|
||||||
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,
|
||||||
dividertop: true,
|
dividertop: true,
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsList, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsList, {
|
||||||
|
@ -171,9 +171,9 @@ var ChatAliases = (_ => {
|
||||||
type: "Button",
|
type: "Button",
|
||||||
className: BDFDB.disCN.marginbottom8,
|
className: BDFDB.disCN.marginbottom8,
|
||||||
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 = {};
|
||||||
BDFDB.DataUtils.remove(this, "words");
|
BDFDB.DataUtils.remove(this, "words");
|
||||||
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
|
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
|
||||||
|
@ -503,28 +503,50 @@ var ChatAliases = (_ => {
|
||||||
}
|
}
|
||||||
|
|
||||||
createInputs (values) {
|
createInputs (values) {
|
||||||
return [{title:"Replace:", type:"", error:"Choose a Wordvalue", valuename:"wordvalue"}, {title:"With:", type:"file", error:"Choose a Replacevalue", valuename:"replacevalue"}].map(inputdata => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
return [
|
||||||
title: inputdata.title,
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
||||||
className: BDFDB.disCN.marginbottom8 + " input-" + inputdata.valuename,
|
title: "Replace:",
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
className: BDFDB.disCN.marginbottom8 + " input-wordvalue",
|
||||||
type: inputdata.type,
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||||
useFilePath: inputdata.type == "file",
|
value: values.wordvalue,
|
||||||
value: values[inputdata.valuename],
|
placeholder: values.wordvalue,
|
||||||
placeholder: values[inputdata.valuename],
|
errorMessage: !values.wordvalue && "Choose a wordvalue" || aliases[values.wordvalue] && "Wordvalue already used, saving will overwrite old alias",
|
||||||
autoFocus: inputdata.valuename == "replacevalue",
|
onChange: (value, instance) => {
|
||||||
errorMessage: !values[inputdata.valuename] && inputdata.error,
|
values.wordvalue = value.trim();
|
||||||
onChange: (value, instance) => {
|
if (!values.wordvalue) instance.props.errorMessage = "Choose a wordvalue";
|
||||||
values[inputdata.valuename] = value.trim();
|
else if (aliases[values.wordvalue]) instance.props.errorMessage = "Wordvalue already used, saving will overwrite old alias";
|
||||||
if (values[inputdata.valuename]) delete instance.props.errorMessage;
|
else delete instance.props.errorMessage;
|
||||||
else instance.props.errorMessage = inputdata.error;
|
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 = !Object.keys(values).every(valuename => values[valuename]);
|
||||||
addButtonIns.props.disabled = !Object.keys(values).every(valuename => values[valuename]);
|
BDFDB.ReactUtils.forceUpdate(addButtonIns);
|
||||||
BDFDB.ReactUtils.forceUpdate(addButtonIns);
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
}),
|
||||||
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
||||||
|
title: "With:",
|
||||||
|
className: BDFDB.disCN.marginbottom8 + " input-replacevalue",
|
||||||
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||||
|
type: "file",
|
||||||
|
useFilePath: true,
|
||||||
|
value: values.replacevalue,
|
||||||
|
placeholder: values.replacevalue,
|
||||||
|
autoFocus: true,
|
||||||
|
errorMessage: !values.replacevalue && "Choose a replacevalue",
|
||||||
|
onChange: (value, instance) => {
|
||||||
|
values.replacevalue = value.trim();
|
||||||
|
if (!values.replacevalue) instance.props.errorMessage = "Choose a replacevalue";
|
||||||
|
else delete instance.props.errorMessage;
|
||||||
|
let addButtonIns = BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:["BDFDB_Modal", "BDFDB_SettingsPanel"], up:true}), {key:"ADDBUTTON"});
|
||||||
|
if (addButtonIns) {
|
||||||
|
addButtonIns.props.disabled = !Object.keys(values).every(valuename => values[valuename]);
|
||||||
|
BDFDB.ReactUtils.forceUpdate(addButtonIns);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}));
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
saveWord (wordvalue, replacevalue, fileselection, aliasConfigs = configs) {
|
saveWord (wordvalue, replacevalue, fileselection, aliasConfigs = configs) {
|
||||||
|
|
|
@ -41,12 +41,11 @@ var ChatFilter = (_ => {
|
||||||
exact: {value:true, description:"Handle the wordvalue as an exact word and not as part of a word"}
|
exact: {value:true, description:"Handle the wordvalue as an exact word and not as part of a word"}
|
||||||
},
|
},
|
||||||
replaces: {
|
replaces: {
|
||||||
blocked: {value:"~~BLOCKED~~", description:"Default Replaceword for blocked Messages:"},
|
blocked: {value:"~~BLOCKED~~", description:"Default replaceword for blocked messages:"},
|
||||||
censored: {value:"$!%&%!&", description:"Default Replaceword for censored Messages:"}
|
censored: {value:"$!%&%!&", description:"Default replaceword for censored messages:"}
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
addContextMenu: {value:true, description:"Add a ContextMenu entry to faster add new blocked/censored Words:"},
|
addContextMenu: {value:true, description:"Add a contextmenu entry to faster add new blocked/censored words:"}
|
||||||
showMessageOnClick: {value:true, description:"Show original Message on Click:"},
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -79,13 +78,13 @@ var ChatFilter = (_ => {
|
||||||
}));
|
}));
|
||||||
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,
|
||||||
dividertop: true,
|
dividertop: true,
|
||||||
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 wordvalue and replacevalue:",
|
||||||
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,
|
||||||
|
@ -98,7 +97,7 @@ var ChatFilter = (_ => {
|
||||||
].flat(10).filter(n => n)
|
].flat(10).filter(n => n)
|
||||||
}));
|
}));
|
||||||
for (let rtype in replaces) if (!BDFDB.ObjectUtils.isEmpty(words[rtype])) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
for (let rtype in replaces) if (!BDFDB.ObjectUtils.isEmpty(words[rtype])) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||||
title: `Added ${rtype} Words`,
|
title: `Added ${rtype} words`,
|
||||||
collapseStates: collapseStates,
|
collapseStates: collapseStates,
|
||||||
dividertop: true,
|
dividertop: true,
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsList, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsList, {
|
||||||
|
@ -153,9 +152,9 @@ var ChatFilter = (_ => {
|
||||||
type: "Button",
|
type: "Button",
|
||||||
className: BDFDB.disCN.marginbottom8,
|
className: BDFDB.disCN.marginbottom8,
|
||||||
color: BDFDB.LibraryComponents.Button.Colors.RED,
|
color: BDFDB.LibraryComponents.Button.Colors.RED,
|
||||||
label: `Remove all ${rtype} Words`,
|
label: `Remove all ${rtype} words`,
|
||||||
onClick: _ => {
|
onClick: _ => {
|
||||||
BDFDB.ModalUtils.confirm(this, `Are you sure you want to remove all ${rtype} Words?`, _ => {
|
BDFDB.ModalUtils.confirm(this, `Are you sure you want to remove all ${rtype} words?`, _ => {
|
||||||
words[rtype] = {};
|
words[rtype] = {};
|
||||||
BDFDB.DataUtils.remove(this, "words", rtype);
|
BDFDB.DataUtils.remove(this, "words", rtype);
|
||||||
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
|
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
|
||||||
|
@ -393,31 +392,56 @@ var ChatFilter = (_ => {
|
||||||
}
|
}
|
||||||
|
|
||||||
createInputs (values) {
|
createInputs (values) {
|
||||||
return [{title:"Block/Censor:", error:"Choose a Wordvalue", valuename:"wordvalue"}, {title:"With:", valuename:"replacevalue"}].map(inputdata => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
return [
|
||||||
title: inputdata.title,
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
||||||
className: BDFDB.disCN.marginbottom8 + " input-" + inputdata.valuename,
|
title: "Block/Censor:",
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
className: BDFDB.disCN.marginbottom8 + " input-wordvalue",
|
||||||
value: values[inputdata.valuename],
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||||
placeholder: values[inputdata.valuename],
|
key: "WORDVALUE",
|
||||||
autoFocus: inputdata.valuename == "replacevalue",
|
value: values.wordvalue,
|
||||||
errorMessage: !values[inputdata.valuename] && inputdata.error,
|
placeholder: values.wordvalue,
|
||||||
|
errorMessage: !values.wordvalue && "Choose a wordvalue" || words[values.choice][values.wordvalue] && `Wordvalue already used, saving will overwrite old ${values.choice} word`,
|
||||||
|
onChange: (value, instance) => {
|
||||||
|
values.wordvalue = value.trim();
|
||||||
|
if (!values.wordvalue) instance.props.errorMessage = "Choose a wordvalue";
|
||||||
|
else if (words[values.choice][values.wordvalue]) instance.props.errorMessage = `Wordvalue already used, saving will overwrite old ${values.choice} word`;
|
||||||
|
else delete instance.props.errorMessage;
|
||||||
|
let addButtonIns = BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:["BDFDB_Modal", "BDFDB_SettingsPanel"], up:true}), {key:"ADDBUTTON"});
|
||||||
|
if (addButtonIns) {
|
||||||
|
addButtonIns.props.disabled = !values.wordvalue;
|
||||||
|
BDFDB.ReactUtils.forceUpdate(addButtonIns);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
||||||
|
title: "With:",
|
||||||
|
className: BDFDB.disCN.marginbottom8 + " input-replacevalue",
|
||||||
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||||
|
value: values.replacevalue,
|
||||||
|
placeholder: values.replacevalue,
|
||||||
|
autoFocus: true,
|
||||||
|
onChange: (value, instance) => {
|
||||||
|
values.replacevalue = value.trim();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.RadioGroup, {
|
||||||
|
className: BDFDB.disCN.marginbottom8,
|
||||||
|
value: values.choice,
|
||||||
|
options: [{value:"blocked", name:"Block"}, {value:"censored", name:"Censor"}],
|
||||||
onChange: (value, instance) => {
|
onChange: (value, instance) => {
|
||||||
values[inputdata.valuename] = value.trim();
|
values.choice = value.value;
|
||||||
if (values[inputdata.valuename]) delete instance.props.errorMessage;
|
let wordvalueInputIns = BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:["BDFDB_Modal", "BDFDB_SettingsPanel"], up:true}), {key:"WORDVALUE"});
|
||||||
else instance.props.errorMessage = inputdata.error;
|
if (wordvalueInputIns) {
|
||||||
let addbuttonins = BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:["BDFDB_Modal", "BDFDB_SettingsPanel"], up:true}), {key:"ADDBUTTON"});
|
if (!values.wordvalue) wordvalueInputIns.props.errorMessage = "Choose a wordvalue";
|
||||||
if (addbuttonins) {
|
else if (words[values.choice][values.wordvalue]) wordvalueInputIns.props.errorMessage = `Wordvalue already used, saving will overwrite old ${values.choice} word`;
|
||||||
addbuttonins.props.disabled = !values.wordvalue;
|
else delete wordvalueInputIns.props.errorMessage;
|
||||||
BDFDB.ReactUtils.forceUpdate(addbuttonins);
|
BDFDB.ReactUtils.forceUpdate(wordvalueInputIns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.RadioGroup, {
|
];
|
||||||
className: BDFDB.disCN.marginbottom8,
|
|
||||||
value: values.choice,
|
|
||||||
options: [{value:"blocked", name:"Block"}, {value:"censored", name:"Censor"}],
|
|
||||||
onChange: value => {values.choice = value.value;}
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
saveWord (values, wordConfigs = configs) {
|
saveWord (values, wordConfigs = configs) {
|
||||||
|
|
Loading…
Reference in New Issue