stuff
This commit is contained in:
parent
cfe194eed2
commit
0ef0d167c7
103
Plugins/BDFDB.js
103
Plugins/BDFDB.js
|
@ -226,7 +226,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
};
|
||||
BDFDB.PluginUtils.createSettingsPanel = function (plugin, children) {
|
||||
if (!BDFDB.ObjectUtils.is(plugin) || !children || (!BDFDB.ReactUtils.isValidElement(children) && !BDFDB.ArrayUtils.is(children)) || (BDFDB.ArrayUtils.is(children) && !children.length)) return;
|
||||
var settingspanel = BDFDB.DOMUtils.create(`<div class="${plugin.name}-settings BDFDB-settings"></div>`);
|
||||
var settingspanel = BDFDB.DOMUtils.create(`<div class="${plugin.name}-settings ${BDFDB.disCN.settingspanel}"></div>`);
|
||||
BDFDB.ReactUtils.render(BDFDB.ReactUtils.createElement(LibraryComponents.SettingsPanel, {
|
||||
title: plugin.name,
|
||||
children
|
||||
|
@ -1443,7 +1443,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
config.name = config.name && !BDFDB.ArrayUtils.is(config.name) ? Array.of(config.name) : config.name;
|
||||
config.props = config.props && !BDFDB.ArrayUtils.is(config.props) ? Array.of(config.props) : config.props;
|
||||
var depth = -1;
|
||||
var maxdepth = config.depth === undefined ? 15 : config.depth;
|
||||
var maxdepth = config.depth === undefined ? 30 : config.depth;
|
||||
var start = performance.now();
|
||||
var maxtime = config.time === undefined ? 150 : config.time;
|
||||
var whitelist = config.up ? {return:true, sibling:true, _reactInternalFiber:true} : {child:true, sibling:true, _reactInternalFiber:true};
|
||||
|
@ -1501,7 +1501,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
if (!BDFDB.ObjectUtils.is(instance)) return null;
|
||||
instance = instance._reactInternalFiber || instance;
|
||||
var depth = -1;
|
||||
var maxdepth = config.depth === undefined ? 15 : config.depth;
|
||||
var maxdepth = config.depth === undefined ? 30 : config.depth;
|
||||
var start = performance.now();
|
||||
var maxtime = config.time === undefined ? 150 : config.time;
|
||||
var whitelist = {
|
||||
|
@ -3890,6 +3890,12 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
cardInner: "inner-OP_8zd",
|
||||
cardWrapper: "card-rT4Wbb",
|
||||
charCounter: "counter-uAzbKp",
|
||||
collapseContainer: "container-fAVkOf",
|
||||
collapseContainerArrow: "arrow-uglXxc",
|
||||
collapseContainerCollapsed: "container-fAVkOf collapsed-2BUBZm",
|
||||
collapseContainerHeader: "header-2s6x-5",
|
||||
collapseContainerInner: "inner-TkGytd",
|
||||
collapseContainerTitle: "title-ROsJi-",
|
||||
colorPickerSwatches: "swatches",
|
||||
colorPickerSwatchesDisabled: "disabled",
|
||||
colorPickerSwatchSingle: "single-swatch",
|
||||
|
@ -3905,7 +3911,11 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
overflowEllipsis: "ellipsis-qlo9sA",
|
||||
modalHeaderHasSibling: "hasSiblings-fRyjyl",
|
||||
modalTabContent: "tab-content",
|
||||
modalTabContentOpen: "open"
|
||||
modalTabContentOpen: "open",
|
||||
settingsPanel: "settingsPanel-w2ySNR",
|
||||
settingsPanelInner: "settingsInner-zw1xAY",
|
||||
settingsPanelList: "settingsList-eZjkXj",
|
||||
settingsPanelTitle: "title-GTF_8J"
|
||||
};
|
||||
DiscordClassModules.BDrepo = {
|
||||
bdGuild: "bd-guild",
|
||||
|
@ -4437,6 +4447,12 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
checkboxwrapper: ["Checkbox", "checkboxWrapper"],
|
||||
checkboxwrapperdisabled: ["Checkbox", "checkboxWrapperDisabled"],
|
||||
clickable: ["Message", "clickOverride"],
|
||||
collapsecontainer: ["BDFDB", "collapseContainer"],
|
||||
collapsecontainerarrow: ["BDFDB", "collapseContainerArrow"],
|
||||
collapsecontainercollapsed: ["BDFDB", "collapseContainerCollapsed"],
|
||||
collapsecontainerheader: ["BDFDB", "collapseContainerHeader"],
|
||||
collapsecontainerinner: ["BDFDB", "collapseContainerInner"],
|
||||
collapsecontainertitle: ["BDFDB", "collapseContainerTitle"],
|
||||
colorbase: ["TextColor2", "base"],
|
||||
colorerror: ["TextColor", "colorError"],
|
||||
colormuted: ["TextColor", "colorMuted"],
|
||||
|
@ -5224,6 +5240,10 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
settingsitem: ["Item", "item"],
|
||||
settingsitemselected: ["Item", "selected"],
|
||||
settingsitemthemed: ["Item", "themed"],
|
||||
settingspanel: ["BDFDB", "settingsPanel"],
|
||||
settingspanelinner: ["BDFDB", "settingsPanelInner"],
|
||||
settingspanellist: ["BDFDB", "settingsPanelList"],
|
||||
settingspaneltitle: ["BDFDB", "settingsPanelTitle"],
|
||||
settingsseparator: ["Item", "separator"],
|
||||
settingstabbar: ["Friends", "tabBar"],
|
||||
settingstabbarbadge: ["Friends", "badge"],
|
||||
|
@ -5678,10 +5698,49 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
BDFDB.ObjectUtils.delete(props, "parsing", "max", "refClass");
|
||||
return BDFDB.ReactUtils.createElement("div", props);
|
||||
}
|
||||
}: LibraryComponents.CharCounter;
|
||||
} : LibraryComponents.CharCounter;
|
||||
|
||||
LibraryComponents.Clickable = BDFDB.ModuleUtils.findByName("Clickable");
|
||||
|
||||
LibraryComponents.CollapseContainer = reactInitialized ? class BDFDB_CollapseContainer extends LibraryModules.React.Component {
|
||||
render() {
|
||||
return BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.DOMUtils.formatClassName(this.props.collapsed ? BDFDB.disCN.collapsecontainercollapsed : BDFDB.disCN.collapsecontainer, this.props.className),
|
||||
id: this.props.id,
|
||||
children: [
|
||||
this.props.dividertop ? BDFDB.ReactUtils.createElement(LibraryComponents.FormComponents.FormDivider, {
|
||||
className: this.props.mini ? BDFDB.disCN.marginbottom8 : BDFDB.disCN.marginbottom20
|
||||
}) : null,
|
||||
BDFDB.ReactUtils.createElement(LibraryComponents.Flex, {
|
||||
className: BDFDB.disCNS.collapsecontainerheader + BDFDB.disCN.cursorpointer,
|
||||
align: LibraryComponents.Flex.Align.CENTER,
|
||||
onClick: e => {
|
||||
this.props.collapsed = !this.props.collapsed;
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
if (typeof this.props.onClick == "function") this.props.onClick(this.props.collapsed, this);
|
||||
},
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.collapsecontainerarrow
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(LibraryComponents.FormComponents.FormTitle, {
|
||||
tag: LibraryComponents.FormComponents.FormTitle.Tags.H2,
|
||||
className: BDFDB.disCNS.collapsecontainertitle + BDFDB.disCN.cursorpointer,
|
||||
children: this.props.title
|
||||
})
|
||||
]
|
||||
}),
|
||||
!this.props.collapsed ? BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.collapsecontainerinner,
|
||||
children: this.props.children
|
||||
}) : null,
|
||||
this.props.dividerbottom ? BDFDB.ReactUtils.createElement(LibraryComponents.FormComponents.FormDivider, {
|
||||
className: this.props.mini ? BDFDB.disCN.margintop8 : BDFDB.disCN.margintop20
|
||||
}) : null
|
||||
]
|
||||
});
|
||||
}
|
||||
} : LibraryComponents.CollapseContainer;
|
||||
LibraryComponents.ColorSwatches = reactInitialized ? class BDFDB_ColorSwatches extends LibraryModules.React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
@ -6008,12 +6067,12 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
grow: 1,
|
||||
children: [
|
||||
typeof this.props.title == "string" ? BDFDB.ReactUtils.createElement(LibraryComponents.FormComponents.FormTitle, {
|
||||
className: BDFDB.disCNS.marginbottom20 + "BDFDB-settings-title",
|
||||
className: BDFDB.disCNS.marginbottom20 + BDFDB.disCN.settingspaneltitle,
|
||||
tag: LibraryComponents.FormComponents.FormTitle.Tags.H2,
|
||||
children: this.props.title
|
||||
}) : null,
|
||||
BDFDB.ReactUtils.createElement(LibraryComponents.Flex, {
|
||||
className: "BDFDB-settings-inner",
|
||||
className: BDFDB.disCN.settingspanelinner,
|
||||
direction: LibraryComponents.Flex.Direction.VERTICAL,
|
||||
children: this.props.children
|
||||
})
|
||||
|
@ -6036,7 +6095,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
children: this.props.title
|
||||
}) : null,
|
||||
BDFDB.ReactUtils.createElement(LibraryComponents.Flex, {
|
||||
className: "BDFDB-settings-inner-list",
|
||||
className: BDFDB.settingspanellist,
|
||||
direction: LibraryComponents.Flex.Direction.VERTICAL,
|
||||
children: this.props.children
|
||||
}),
|
||||
|
@ -6061,9 +6120,10 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
className: this.props.childClassName,
|
||||
onChange: this.handleChange.bind(this)
|
||||
});
|
||||
BDFDB.ObjectUtils.delete(childprops, "basis", "dividerbottom", "dividertop", "label", "labelchildren", "mini", "note", "type", "childClassName");
|
||||
BDFDB.ObjectUtils.delete(childprops, "id", "basis", "dividerbottom", "dividertop", "label", "labelchildren", "mini", "note", "type", "childClassName");
|
||||
return BDFDB.ReactUtils.createElement(LibraryComponents.Flex, {
|
||||
className: BDFDB.DOMUtils.formatClassName(this.props.className, this.props.disabled ? BDFDB.disCN.disabled : null),
|
||||
id: this.props.id,
|
||||
direction: LibraryComponents.Flex.Direction.VERTICAL,
|
||||
align: LibraryComponents.Flex.Align.STRETCH,
|
||||
children: [
|
||||
|
@ -6725,6 +6785,31 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
|||
BDFDB.DOMUtils.appendLocalStyle("BDFDB", `
|
||||
@import url(https://mwittrien.github.io/BetterDiscordAddons/Themes/BetterDocsBlock.css);
|
||||
|
||||
${BDFDB.dotCN.settingspanelinner} {
|
||||
padding-left: 15px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
${BDFDB.dotCN.settingspanellist} {
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
${BDFDB.dotCN.collapsecontainerinner} {
|
||||
padding-left: 15px;
|
||||
}
|
||||
${BDFDB.dotCNS.settingspanelinner + BDFDB.dotCN.collapsecontainerheader} {
|
||||
margin-left: -16px;
|
||||
}
|
||||
${BDFDB.dotCN.collapsecontainerarrow} {
|
||||
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxOS4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iQ2FscXVlXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSItOTUwIDUzMiAxOCAxOCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAtOTUwIDUzMiAxOCAxODsiIHhtbDpzcGFjZT0icHJlc2VydmUiPg0KPHN0eWxlIHR5cGU9InRleHQvY3NzIj4NCgkuc3Qwe2ZpbGw6bm9uZTt9DQoJLnN0MXtmaWxsOm5vbmU7c3Ryb2tlOiNGRkZGRkY7c3Ryb2tlLXdpZHRoOjEuNTtzdHJva2UtbWl0ZXJsaW1pdDoxMDt9DQo8L3N0eWxlPg0KPHBhdGggY2xhc3M9InN0MCIgZD0iTS05MzIsNTMydjE4aC0xOHYtMThILTkzMnoiLz4NCjxwb2x5bGluZSBjbGFzcz0ic3QxIiBwb2ludHM9Ii05MzYuNiw1MzguOCAtOTQxLDU0My4yIC05NDUuNCw1MzguOCAiLz4NCjwvc3ZnPg0K) center/cover no-repeat;
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
transition: transform .3s ease;
|
||||
transform: rotate(0);
|
||||
}
|
||||
${BDFDB.dotCNS.collapsecontainercollapsed + BDFDB.dotCN.collapsecontainerarrow} {
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
|
||||
${BDFDB.dotCN.overflowellipsis} {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -3,7 +3,7 @@
|
|||
class CompleteTimestamps {
|
||||
getName () {return "CompleteTimestamps";}
|
||||
|
||||
getVersion () {return "1.3.5";}
|
||||
getVersion () {return "1.3.6";}
|
||||
|
||||
getAuthor () {return "DevilBro";}
|
||||
|
||||
|
@ -11,13 +11,13 @@ class CompleteTimestamps {
|
|||
|
||||
constructor () {
|
||||
this.changelog = {
|
||||
"fixed":[["Milliseconds","Milliseconds are now properlly formatted when leading zeros is enabled (9 => 009, 12 => 012)"]]
|
||||
"improved":[["New Library Structure & React","Restructured my Library and switched to React rendering instead of DOM manipulation"]]
|
||||
};
|
||||
|
||||
this.patchModules = {
|
||||
"MessageGroup":["componentDidMount","componentDidUpdate"],
|
||||
"Embed":["componentDidMount","componentDidUpdate"],
|
||||
"StandardSidebarView":"componentWillUnmount"
|
||||
"Message":"render",
|
||||
"MessageContent":"render",
|
||||
"Embed":"render"
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -50,33 +50,108 @@ class CompleteTimestamps {
|
|||
let settings = BDFDB.DataUtils.get(this, "settings");
|
||||
let choices = BDFDB.DataUtils.get(this, "choices");
|
||||
let formats = BDFDB.DataUtils.get(this, "formats");
|
||||
let settingshtml = `<div class="${this.name}-settings BDFDB-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.titlesize18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</div><div class="BDFDB-settings-inner">`;
|
||||
for (let key in settings) {
|
||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</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 ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
|
||||
}
|
||||
for (let key in choices) {
|
||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCN.flexchild}" style="flex: 0 0 30%;">${this.defaults.choices[key].description}</h3>${BDFDB.createSelectMenu(this.createSelectChoice(choices[key]), choices[key], key)}</div>`;
|
||||
}
|
||||
for (let key in formats) {
|
||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCN.flexchild}" style="flex: 0 0 30%;">${this.defaults.formats[key].description}</h3><div class="${BDFDB.disCNS.inputwrapper + BDFDB.disCNS.vertical + BDFDB.disCNS.flex2 + BDFDB.disCN.directioncolumn}" style="flex: 1 1 auto;"><input type="text" option="${key}" value="${formats[key]}" placeholder="${this.defaults.formats[key].value}" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.titlesize16}"></div></div>`;
|
||||
}
|
||||
let infoHidden = BDFDB.DataUtils.load(this, "hideInfo", "hideInfo");
|
||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCNS.cursorpointer} toggle-info" style="flex: 1 1 auto;"><svg class="toggle-infoarrow${infoHidden ? (" " + BDFDB.disCN.directionright) : ""}" width="12" height="12" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="M7 10L12 15 17 10"></path></svg><div class="toggle-infotext" style="flex: 1 1 auto;">Information</div></div>`;
|
||||
settingshtml += `<div class="BDFDB-settings-inner-list info-container" ${infoHidden ? "style='display:none;'" : ""}>`;
|
||||
settingshtml += `<div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$hour will be replaced with the current hour</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$minute will be replaced with the current minutes</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$second will be replaced with the current seconds</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$msecond will be replaced with the current milliseconds</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$timemode will change $hour to a 12h format and will be replaced with AM/PM</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$year will be replaced with the current year</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$month will be replaced with the current month</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$day will be replaced with the current day</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$monthnameL will be replaced with the monthname in long format based on the Discord Language</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$monthnameS will be replaced with the monthname in short format based on the Discord Language</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$weekdayL will be replaced with the weekday in long format based on the Discord Language</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$weekdayS will be replaced with the weekday in short format based on the Discord Language</div>`;
|
||||
settingshtml += `</div></div>`;
|
||||
|
||||
let settingspanel = BDFDB.DOMUtils.create(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".settings-switch", () => {BDFDB.TimeUtils.timeout(() => {this.updateSettingsPanel(settingspanel);})});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "keyup", BDFDB.dotCN.input, () => {this.saveInputs(settingspanel);});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".toggle-info", e => {this.toggleInfo(e.currentTarget);});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {
|
||||
BDFDB.openDropdownMenu(e, this.saveSelectChoice.bind(this), this.createSelectChoice.bind(this), this.languages);
|
||||
});
|
||||
return settingspanel;
|
||||
let settingsitems = [], inneritems = [];
|
||||
|
||||
for (let key in settings) settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
className: BDFDB.disCN.marginbottom8,
|
||||
type: "Switch",
|
||||
plugin: this,
|
||||
keys: ["settings", key],
|
||||
label: this.defaults.settings[key].description,
|
||||
value: settings[key],
|
||||
onChange: (e, instance) => {
|
||||
let selects = BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_SettingsPanel", up:true}), {name:"BDFDB_Select", all:true, noCopies:true, });
|
||||
for (let i in selects) BDFDB.ReactUtils.forceUpdate(selects[i]);
|
||||
}
|
||||
}));
|
||||
|
||||
settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
}));
|
||||
|
||||
for (let key in choices) settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
className: BDFDB.disCN.marginbottom8,
|
||||
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(this.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(this.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(this.languages[lang.value].id)
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
}));
|
||||
|
||||
settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
}));
|
||||
|
||||
for (let key in formats) settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
className: BDFDB.disCN.marginbottom8,
|
||||
type: "TextInput",
|
||||
plugin: this,
|
||||
keys: ["formats", key],
|
||||
label: this.defaults.formats[key].description,
|
||||
basis: "70%",
|
||||
value: formats[key],
|
||||
onChange: (e, instance) => {
|
||||
let selects = BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_SettingsPanel", up:true}), {name:"BDFDB_Select", all:true, noCopies:true, });
|
||||
for (let i in selects) BDFDB.ReactUtils.forceUpdate(selects[i]);
|
||||
}
|
||||
}));
|
||||
|
||||
settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "Placeholder Guide",
|
||||
dividertop: true,
|
||||
collapsed: BDFDB.DataUtils.load(this, "hideInfo", "hideInfo"),
|
||||
children: ["$hour will be replaced with the current hour", "$minute will be replaced with the current minutes", "$second will be replaced with the current seconds", "$msecond will be replaced with the current milliseconds", "$timemode will change $hour to a 12h format and will be replaced with AM/PM", "$year will be replaced with the current year", "$month will be replaced with the current month", "$day will be replaced with the current day", "$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"].map(string => {
|
||||
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, {
|
||||
type: BDFDB.LibraryComponents.FormComponents.FormTextTypes.DESCRIPTION,
|
||||
children: string
|
||||
});
|
||||
}),
|
||||
onClick: collapsed => {
|
||||
BDFDB.DataUtils.save(collapsed, this, "hideInfo", "hideInfo");
|
||||
}
|
||||
}));
|
||||
|
||||
return BDFDB.PluginUtils.createSettingsPanel(this, settingsitems);
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,27 +186,6 @@ class CompleteTimestamps {
|
|||
|
||||
this.languages = Object.assign({"own":{name:"Own",id:"own",integrated:false,dic:false}}, BDFDB.LanguageUtils.languages);
|
||||
|
||||
BDFDB.ListenerUtils.add(this, document, "mouseenter", BDFDB.dotCNS.messagegroup + BDFDB.dotCN.messagecontent, e => {
|
||||
if (BDFDB.DataUtils.get(this, "settings", "showOnHover")) {
|
||||
let message = e.currentTarget;
|
||||
let messagegroup = BDFDB.DOMUtils.getParent(BDFDB.dotCN.messagegroup, message);
|
||||
if (!messagegroup || !messagegroup.tagName) return;
|
||||
let info = this.getMessageData(message, messagegroup);
|
||||
if (!info || !info.timestamp || !info.timestamp._i) return;
|
||||
let choice = BDFDB.DataUtils.get(this, "choices", "creationDateLang");
|
||||
BDFDB.TooltipUtils.create(message, this.getTimestamp(this.languages[choice].id, info.timestamp._i), {type:"left", selector:"completetimestamp-tooltip"});
|
||||
}
|
||||
});
|
||||
BDFDB.ListenerUtils.add(this, document, "mouseenter", BDFDB.dotCNS.messagegroup + BDFDB.dotCN.messageedited, e => {
|
||||
if (BDFDB.DataUtils.get(this, "settings", "changeForEdit")) {
|
||||
let marker = e.currentTarget;
|
||||
let time = marker.getAttribute("datetime");
|
||||
if (!time) return;
|
||||
let choice = BDFDB.DataUtils.get(this, "choices", "creationDateLang");
|
||||
BDFDB.TooltipUtils.create(marker, this.getTimestamp(this.languages[choice].id, time), {type:"top", selector:"completetimestampedit-tooltip"});
|
||||
}
|
||||
});
|
||||
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||
}
|
||||
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
|
||||
|
@ -141,12 +195,11 @@ class CompleteTimestamps {
|
|||
stop () {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
this.stopping = true;
|
||||
|
||||
BDFDB.DOMUtils.remove(".complete-timestamp-divider");
|
||||
BDFDB.DOMUtils.removeClassFromDOM("complete-timestamp");
|
||||
|
||||
|
||||
BDFDB.DOMUtils.removeLocalStyle(this.name + "CompactCorrection");
|
||||
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||
|
||||
BDFDB.PluginUtils.clear(this);
|
||||
}
|
||||
}
|
||||
|
@ -154,21 +207,83 @@ class CompleteTimestamps {
|
|||
|
||||
// begin of own functions
|
||||
|
||||
saveInputs (settingspanel) {
|
||||
let formats = {};
|
||||
for (let input of settingspanel.querySelectorAll(BDFDB.dotCN.input)) {
|
||||
formats[input.getAttribute("option")] = input.value;
|
||||
onSettingsClosed (instance, wrapper, returnvalue) {
|
||||
if (this.SettingsUpdated) {
|
||||
delete this.SettingsUpdated;
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||
}
|
||||
BDFDB.DataUtils.save(formats, this, "formats");
|
||||
this.updateSettingsPanel(settingspanel);
|
||||
}
|
||||
|
||||
updateSettingsPanel (settingspanel) {
|
||||
let choices = BDFDB.DataUtils.get(this, "choices");
|
||||
for (let key in choices) {
|
||||
settingspanel.querySelector(`${BDFDB.dotCN.select}[type='${key}'] .languageTimestamp`).innerText = this.getTimestamp(this.languages[choices[key]].id);
|
||||
processMessage (e) {
|
||||
if (!this.stopping && !e.instance.props.isCompact) {
|
||||
let settings = BDFDB.DataUtils.get(this, "settings");
|
||||
if (settings.showInChat) this.injectTimestamp(e.returnvalue, e.instance.props);
|
||||
if (settings.showOnHover) {
|
||||
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["className", BDFDB.disCN.messagecontent]]});
|
||||
if (index > -1) {
|
||||
let content = children[index];
|
||||
children[index] = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
||||
text: this.getTimestamp(this.languages[BDFDB.DataUtils.get(this, "choices", "creationDateLang")].id, e.instance.props.message.timestamp._i),
|
||||
tooltipConfig: {
|
||||
type: "left"
|
||||
},
|
||||
children: content
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
this.SettingsUpdated = true;
|
||||
}
|
||||
|
||||
processMessageContent (e) {
|
||||
if (!this.stopping && typeof e.returnvalue.props.children == "function") {
|
||||
let settings = BDFDB.DataUtils.get(this, "settings");
|
||||
let renderChildren = e.returnvalue.props.children;
|
||||
e.returnvalue.props.children = () => {
|
||||
let renderedChildren = renderChildren(e.instance);
|
||||
if (e.instance.props.isCompact && settings.showInChat) this.injectTimestamp(renderedChildren, e.instance.props);
|
||||
if (settings.changeForEdit) this.injectEditStamp(renderedChildren, e.instance.props);
|
||||
return renderedChildren;
|
||||
};
|
||||
BDFDB.TimeUtils.timeout(this.setMaxWidth.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
processEmbed (e) {
|
||||
if (e.instance.props.embed.timestamp && BDFDB.DataUtils.get(this, "settings", "showInEmbed")) {
|
||||
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["className", BDFDB.disCN.embedfootertext]]});
|
||||
if (index > -1 && BDFDB.ArrayUtils.is(children[index].props.children)) children[index].props.children.splice(children[index].props.children.length - 1, 1, this.getTimestamp(this.languages[BDFDB.DataUtils.get(this, "choices", "creationDateLang")].id, e.instance.props.embed.timestamp._i));
|
||||
}
|
||||
}
|
||||
|
||||
injectTimestamp (parent, props) {
|
||||
let [children, index] = BDFDB.ReactUtils.findChildren(parent, {name: "MessageTimestamp"});
|
||||
if (index > -1) children.splice(index, 1, BDFDB.ReactUtils.createElement("time", {
|
||||
className: BDFDB.DOMUtils.formatClassName(props.backgroundOpacity ? BDFDB.disCN["message" + props.backgroundOpacity + "backgroundopacity"] : null, !(props.isEditing || props.isHeader) ? BDFDB.disCN.messagetimestampvisibleonhover : null, props.isCompact ? (props.isMentioned ? BDFDB.disCN.messagetimestampcompactismentioned : BDFDB.disCN.messagetimestampcompact) : BDFDB.disCN.messagetimestampcozy),
|
||||
dateTime: props.message.timestamp,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement("i", {
|
||||
className: BDFDB.disCN.messagetimestampseparatorleft,
|
||||
children: props.isCompact ? "[" : " ["
|
||||
}),
|
||||
this.getTimestamp(this.languages[BDFDB.DataUtils.get(this, "choices", "creationDateLang")].id, props.message.timestamp._i),
|
||||
BDFDB.ReactUtils.createElement("i", {
|
||||
className: BDFDB.disCN.messagetimestampseparatorright,
|
||||
children: props.isCompact ? "] " : "]"
|
||||
})
|
||||
]
|
||||
}));
|
||||
}
|
||||
|
||||
injectEditStamp (parent, props) {
|
||||
let [children, index] = BDFDB.ReactUtils.findChildren(parent, {name: "SuffixEdited"});
|
||||
if (index > -1) children.splice(index, 1, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
||||
text: this.getTimestamp(this.languages[BDFDB.DataUtils.get(this, "choices", "creationDateLang")].id, props.message.editedTimestamp._i),
|
||||
children: BDFDB.ReactUtils.createElement("time", {
|
||||
className: BDFDB.disCN.messageedited,
|
||||
dateTime: props.message.editedTimestamp,
|
||||
children: `(${BDFDB.LanguageStrings.MESSAGE_EDITED.toLowerCase()})`
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
toggleInfo (ele) {
|
||||
|
@ -177,37 +292,7 @@ class CompleteTimestamps {
|
|||
BDFDB.DataUtils.save(BDFDB.DOMUtils.isHidden(ele.nextElementSibling), this, "hideInfo", "hideInfo");
|
||||
}
|
||||
|
||||
saveSelectChoice (selectWrap, type, choice) {
|
||||
if (type && choice) {
|
||||
selectWrap.querySelector(".languageName").innerText = this.languages[choice].name;
|
||||
selectWrap.querySelector(".languageTimestamp").innerText = this.getTimestamp(this.languages[choice].id);
|
||||
BDFDB.DataUtils.save(choice, this, "choices", type);
|
||||
}
|
||||
}
|
||||
|
||||
createSelectChoice (choice) {
|
||||
return `<div class="${BDFDB.disCNS.title + BDFDB.disCNS.medium + BDFDB.disCNS.primary + BDFDB.disCNS.weightnormal + BDFDB.disCN.cursorpointer} languageName" style="flex: 1 1 42%; padding: 0;">${this.languages[choice].name}</div><div class="${BDFDB.disCNS.title + BDFDB.disCNS.medium + BDFDB.disCNS.primary + BDFDB.disCNS.weightlight + BDFDB.disCN.cursorpointer} languageTimestamp" style="flex: 1 1 58%; padding: 0;">${this.getTimestamp(this.languages[choice].id)}</div>`;
|
||||
}
|
||||
|
||||
processMessageGroup (instance, wrapper, returnvalue) {
|
||||
if (BDFDB.DataUtils.get(this, "settings", "showInChat")) for (let stamp of wrapper.querySelectorAll("time[datetime]")) this.changeTimestamp(stamp);
|
||||
}
|
||||
|
||||
processEmbed (instance, wrapper, returnvalue) {
|
||||
let embed = BDFDB.ReactUtils.getValue(instance, "props.embed");
|
||||
let footer = wrapper.querySelector(BDFDB.dotCN.embedfootertext);
|
||||
if (footer && embed && embed.timestamp && BDFDB.DataUtils.get(this, "settings", "showInEmbed")) {
|
||||
footer.lastChild.textContent = this.getTimestamp(this.languages[BDFDB.DataUtils.get(this, "choices", "creationDateLang")].id, embed.timestamp._i);
|
||||
}
|
||||
}
|
||||
|
||||
processStandardSidebarView (instance, wrapper, returnvalue) {
|
||||
if (this.SettingsUpdated) {
|
||||
delete this.SettingsUpdated;
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||
}
|
||||
}
|
||||
|
||||
// REMOVE
|
||||
changeTimestamp (stamp) {
|
||||
if (!stamp.className || stamp.className.toLowerCase().indexOf("timestamp") == -1 || BDFDB.DOMUtils.containsClass(stamp, "complete-timestamp")) return;
|
||||
let time = stamp.getAttribute("datetime");
|
||||
|
@ -219,14 +304,6 @@ class CompleteTimestamps {
|
|||
}
|
||||
}
|
||||
|
||||
getMessageData (div, messagegroup) {
|
||||
let pos = Array.from(messagegroup.querySelectorAll("." + div.className.replace(/ /g, "."))).indexOf(div);
|
||||
let instance = BDFDB.ReactUtils.getInstance(messagegroup);
|
||||
if (!instance) return;
|
||||
let info = instance.return.stateNode.props.messages;
|
||||
return info && pos > -1 ? info[pos] : null;
|
||||
}
|
||||
|
||||
getTimestamp (languageid, time) {
|
||||
let timeobj = time ? time : new Date();
|
||||
if (typeof time == "string") timeobj = new Date(time);
|
||||
|
@ -268,7 +345,7 @@ class CompleteTimestamps {
|
|||
}
|
||||
|
||||
cutOffSeconds (timestring) {
|
||||
return timestring.replace(/(.*):(.*):(.{2})(.*)/, "$1:$2$4");
|
||||
return timestring.replace(/(.{1,2}:.{1,2}):.{1,2}(.*)/, "$1$2").replace(/(.{1,2}\..{1,2})\..{1,2}(.*)/, "$1$2").replace(/(.{1,2} h .{1,2} min) .{1,2} s(.*)/, "$1$2");
|
||||
}
|
||||
|
||||
addLeadingZeros (timestring) {
|
||||
|
@ -299,8 +376,11 @@ class CompleteTimestamps {
|
|||
width: ${width + 2}px !important;
|
||||
}
|
||||
${BDFDB.dotCN.messagemarkupiscompact} {
|
||||
margin-left: ${width}px !important;
|
||||
text-indent: -${width}px !important;
|
||||
margin-left: calc(${width}px + 4ch) !important;
|
||||
text-indent: calc(-${width}px - 4ch) !important;
|
||||
}
|
||||
${BDFDB.dotCN.messagemarkupiscompact} > label {
|
||||
margin-left: calc(${width}px + 4ch) !important;
|
||||
}
|
||||
${BDFDB.dotCN.messageaccessorycompact} {
|
||||
padding-left: ${width}px !important;
|
||||
|
|
Loading…
Reference in New Issue