Update CompleteTimestamps.plugin.js

This commit is contained in:
Mirco Wittrien 2019-11-14 14:42:54 +01:00
parent 09e600735b
commit 554d13f566
1 changed files with 30 additions and 38 deletions

View File

@ -3,7 +3,7 @@
class CompleteTimestamps { class CompleteTimestamps {
getName () {return "CompleteTimestamps";} getName () {return "CompleteTimestamps";}
getVersion () {return "1.3.6";} getVersion () {return "1.3.7";}
getAuthor () {return "DevilBro";} getAuthor () {return "DevilBro";}
@ -11,13 +11,14 @@ class CompleteTimestamps {
constructor () { constructor () {
this.changelog = { this.changelog = {
"fixed":[["Arabic Usernames","Fixed issue where arabic usernames would break timestamps that contain a space"]],
"improved":[["New Library Structure & React","Restructured my Library and switched to React rendering instead of DOM manipulation"]] "improved":[["New Library Structure & React","Restructured my Library and switched to React rendering instead of DOM manipulation"]]
}; };
this.patchModules = { this.patchModules = {
"Message":"render", Message: "render",
"MessageContent":"render", MessageContent: "render",
"Embed":"render" Embed: "render"
}; };
} }
@ -50,7 +51,7 @@ class CompleteTimestamps {
let settings = BDFDB.DataUtils.get(this, "settings"); let settings = BDFDB.DataUtils.get(this, "settings");
let choices = BDFDB.DataUtils.get(this, "choices"); let choices = BDFDB.DataUtils.get(this, "choices");
let formats = BDFDB.DataUtils.get(this, "formats"); let formats = BDFDB.DataUtils.get(this, "formats");
let settingsitems = [], inneritems = []; let settingsitems = [];
for (let key in settings) settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, { for (let key in settings) settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8, className: BDFDB.disCN.marginbottom8,
@ -255,21 +256,30 @@ class CompleteTimestamps {
injectTimestamp (parent, props) { injectTimestamp (parent, props) {
let [children, index] = BDFDB.ReactUtils.findChildren(parent, {name: "MessageTimestamp"}); let [children, index] = BDFDB.ReactUtils.findChildren(parent, {name: "MessageTimestamp"});
if (index > -1) children.splice(index, 1, BDFDB.ReactUtils.createElement("time", { if (index > -1) {
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), if (!props.isCompact) children.splice(index++, 0, BDFDB.ReactUtils.createElement("span", {
dateTime: props.message.timestamp, children: "ARABIC-FIX",
children: [ style: {
BDFDB.ReactUtils.createElement("i", { fontSize: 0,
className: BDFDB.disCN.messagetimestampseparatorleft, visibility: "hidden"
children: props.isCompact ? "[" : " [" }
}), }));
this.getTimestamp(this.languages[BDFDB.DataUtils.get(this, "choices", "creationDateLang")].id, props.message.timestamp._i), children.splice(index, 1, BDFDB.ReactUtils.createElement("time", {
BDFDB.ReactUtils.createElement("i", { 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),
className: BDFDB.disCN.messagetimestampseparatorright, dateTime: props.message.timestamp,
children: props.isCompact ? "] " : "]" 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) { injectEditStamp (parent, props) {
@ -284,24 +294,6 @@ class CompleteTimestamps {
})); }));
} }
toggleInfo (ele) {
BDFDB.DOMUtils.toggleClass(ele.querySelector("svg"), BDFDB.disCN.directionright);
BDFDB.DOMUtils.toggle(ele.nextElementSibling);
BDFDB.DataUtils.save(BDFDB.DOMUtils.isHidden(ele.nextElementSibling), this, "hideInfo", "hideInfo");
}
// REMOVE
changeTimestamp (stamp) {
if (!stamp.className || stamp.className.toLowerCase().indexOf("timestamp") == -1 || BDFDB.DOMUtils.containsClass(stamp, "complete-timestamp")) return;
let time = stamp.getAttribute("datetime");
if (time) {
this.setMaxWidth();
BDFDB.DOMUtils.addClass(stamp, "complete-timestamp");
stamp.parentElement.insertBefore(BDFDB.DOMUtils.create(`<span class="complete-timestamp-divider arabic-fix" style="display: inline !important; height: 0 !important; width: 0 !important; font-size: 0 !important; user-select: none !important;">ARABIC FIX</span>`), stamp);
BDFDB.DOMUtils.setText(stamp, this.getTimestamp(this.languages[BDFDB.DataUtils.get(this, "choices", "creationDateLang")].id, time));
}
}
getTimestamp (languageid, time) { getTimestamp (languageid, time) {
let timeobj = time ? time : new Date(); let timeobj = time ? time : new Date();
if (typeof time == "string") timeobj = new Date(time); if (typeof time == "string") timeobj = new Date(time);