Update MessageUtilities.plugin.js

This commit is contained in:
Mirco Wittrien 2019-02-01 12:34:20 +01:00
parent 6a03adec53
commit 8f47e73a20
1 changed files with 15 additions and 5 deletions

View File

@ -3,7 +3,7 @@
class MessageUtilities {
getName () {return "MessageUtilities";}
getVersion () {return "1.4.5";}
getVersion () {return "1.4.6";}
getAuthor () {return "DevilBro";}
@ -11,7 +11,8 @@ class MessageUtilities {
initConstructor () {
this.changelog = {
"improved":[["Event Handling","Setting a keybinding to a native keycombo will now stop the native event. Meaning you can now use combos like Click + Alt without natively marking messages as unread"]]
"added":[["Reveal All Spoilers","Added support for the new Plugin 'RevealAllSpoilersOption'"]],
"fixed":[["Enable/Disabled","Fixed the bug where enabling/disabling a keycombo option wouldn't be saved in the config"]]
};
this.bindings = {};
@ -36,7 +37,8 @@ class MessageUtilities {
"__Note_Message": {value:false},
"__Translate_Message": {value:false},
"__Quote_Message": {value:false},
"__Citate_Message": {value:false}
"__Citate_Message": {value:false},
"__Reveal_Spoilers": {value:false}
},
bindings: {
"Edit_Message": {name:"Edit Message", func:this.doEdit, value:{click:1, key1:0, key2:0}},
@ -46,7 +48,8 @@ class MessageUtilities {
"__Note_Message": {name:"Note Message (Pesonal Pins)", func:this.doNote, value:{click:0, key1:16, key2:0}, plugin:"PersonalPins"},
"__Translate_Message": {name:"Translate Message (Google Translate Option)", func:this.doTranslate, value:{click:0, key1:20, key2:0}, plugin:"GoogleTranslateOption"},
"__Quote_Message": {name:"Quote Message (Quoter)", func:this.doQuote, value:{click:0, key1:113, key2:0}, plugin:"Quoter"},
"__Citate_Message": {name:"Quote Message (Citador)", func:this.doCitate, value:{click:0, key1:114, key2:0}, plugin:"Citador"}
"__Citate_Message": {name:"Quote Message (Citador)", func:this.doCitate, value:{click:0, key1:114, key2:0}, plugin:"Citador"},
"__Reveal_Spoilers": {name:"Reveal All Spoilers (RevealAllSpoilersOption)", func:this.doReveal, value:{click:0, key1:115, key2:0}, plugin:"RevealAllSpoilersOption"}
}
};
}
@ -61,7 +64,7 @@ class MessageUtilities {
}
for (let action in bindings) {
if (!this.defaults.bindings[action].plugin || BDFDB.isPluginEnabled(this.defaults.bindings[action].plugin)) {
settingshtml += `<div class="${action}-key-settings"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.bindings[action].name}:</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="${action}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}"${settings[action] ? " checked" : ""}></div></div><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;">`;
settingshtml += `<div class="${action}-key-settings"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.bindings[action].name}:</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${action}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[action] ? " checked" : ""}></div></div><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;">`;
for (let click of this.clicks) {
settingshtml += `<div class="${BDFDB.disCN.flexchild}" style="flex: 1 1 20%;"><h5 class="${BDFDB.disCNS.h5 + BDFDB.disCNS.title + BDFDB.disCNS.size12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.h5defaultmargin + BDFDB.disCN.marginbottom4}">${click}:</h5><div class="${BDFDB.disCN.selectwrap}"><div type="${action}" option="${click}" value="${bindings[action][click]}" class="${BDFDB.disCNS.select + BDFDB.disCNS.selectsingle + BDFDB.disCN.selecthasvalue}"><div class="${BDFDB.disCN.selectcontrol}"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignbaseline + BDFDB.disCNS.nowrap + BDFDB.disCN.selectvalue}" style="flex: 1 1 auto;"><div class="${BDFDB.disCNS.title + BDFDB.disCNS.medium + BDFDB.disCNS.size16 + BDFDB.disCNS.height20 + BDFDB.disCNS.primary + BDFDB.disCN.weightnormal}" style="padding:0;">${this.clickMap[bindings[action][click]]}</div></div><span class="${BDFDB.disCN.selectarrowzone}"><span class="${BDFDB.disCN.selectarrow}"></span></span></div></div></div></div>`;
}
@ -338,6 +341,12 @@ class MessageUtilities {
}
}
doReveal ({messagediv, pos, message}) {
if (BDFDB.isPluginEnabled(this.defaults.bindings.__Reveal_Spoilers.plugin)) {
bdplugins[this.defaults.bindings.__Reveal_Spoilers.plugin].plugin.revealAllSpoilers(messagediv);
}
}
onKeyDown (e, key, name) {
if (!this.isEventFired(name)) {
this.fireEvent(name);
@ -356,6 +365,7 @@ class MessageUtilities {
let str = "";
if (BDFDB.getData(action, this, "settings")) {
let binding = BDFDB.getData(action, this, "bindings");
console.log(action, binding);
if (binding) for (let type in binding) {
let typename = type.indexOf("click") == 0 ? this.clickMap[binding[type]] : this.keyboardMap[binding[type]];
if (typename && typename != "NONE") str += typename + "+";