Update CompleteTimestamps.plugin.js

This commit is contained in:
Mirco Wittrien 2018-12-14 12:08:12 +01:00
parent d4932a4a2f
commit 3e2fc091d0
1 changed files with 29 additions and 28 deletions

View File

@ -116,7 +116,6 @@ class CompleteTimestamps {
if (change.removedNodes) { if (change.removedNodes) {
change.removedNodes.forEach((node) => { change.removedNodes.forEach((node) => {
if (this.updateTimestamps && node.tagName && node.getAttribute("layer-id") == "user-settings") { if (this.updateTimestamps && node.tagName && node.getAttribute("layer-id") == "user-settings") {
this.setMaxWidth();
document.querySelectorAll(".complete-timestamp").forEach(timestamp => {timestamp.classList.remove("complete-timestamp");}); document.querySelectorAll(".complete-timestamp").forEach(timestamp => {timestamp.classList.remove("complete-timestamp");});
document.querySelectorAll(".complete-timestamp-divider").forEach(divider => {divider.remove();}); document.querySelectorAll(".complete-timestamp-divider").forEach(divider => {divider.remove();});
document.querySelectorAll("time").forEach(stamp => {this.changeTimestamp(stamp);}) document.querySelectorAll("time").forEach(stamp => {this.changeTimestamp(stamp);})
@ -134,8 +133,6 @@ class CompleteTimestamps {
BDFDB.languages BDFDB.languages
); );
this.setMaxWidth();
$(document) $(document)
.on("mouseenter." + this.getName(), BDFDB.dotCNS.message + BDFDB.dotCN.messagecontent, (e) => { .on("mouseenter." + this.getName(), BDFDB.dotCNS.message + BDFDB.dotCN.messagecontent, (e) => {
if (BDFDB.getData("showOnHover", this, "settings")) { if (BDFDB.getData("showOnHover", this, "settings")) {
@ -265,6 +262,7 @@ class CompleteTimestamps {
if (!stamp.className || stamp.className.toLowerCase().indexOf("timestamp") == -1 || stamp.classList.contains("complete-timestamp")) return; if (!stamp.className || stamp.className.toLowerCase().indexOf("timestamp") == -1 || stamp.classList.contains("complete-timestamp")) return;
let time = stamp.getAttribute("datetime"); let time = stamp.getAttribute("datetime");
if (time) { if (time) {
this.setMaxWidth();
let choice = BDFDB.getData("creationDateLang", this, "choices"); let choice = BDFDB.getData("creationDateLang", this, "choices");
stamp.classList.add("complete-timestamp"); stamp.classList.add("complete-timestamp");
let stampdivider = document.createElement("span"); let stampdivider = document.createElement("span");
@ -351,6 +349,8 @@ class CompleteTimestamps {
} }
setMaxWidth () { setMaxWidth () {
if (this.currentMode != BDFDB.getDiscordMode()) {
this.currentMode = BDFDB.getDiscordMode();
var timestamp = document.querySelector(BDFDB.dotCN.messagetimestampcompact); var timestamp = document.querySelector(BDFDB.dotCN.messagetimestampcompact);
if (timestamp) { if (timestamp) {
var choice = BDFDB.getData("creationDateLang", this, "choices"); var choice = BDFDB.getData("creationDateLang", this, "choices");
@ -379,3 +379,4 @@ class CompleteTimestamps {
} }
} }
} }
}