aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authormarzavec <admin@marzavec.com>2019-06-04 22:27:15 +0200
committerGitHub <noreply@github.com>2019-06-04 22:27:15 +0200
commit831a4968f46dc2e6c35083b7f1f350e926c60525 (patch)
tree6245d589fe2518d41a4f41f634062047dc3ed4da /client
parentCreate FUNDING.yml (diff)
parentBugfix for @mentions (diff)
downloadhackchat-831a4968f46dc2e6c35083b7f1f350e926c60525.tar.gz
hackchat-831a4968f46dc2e6c35083b7f1f350e926c60525.zip
Merge pull request #67 from Roslot/master
Semi-bugfix for @mentions
Diffstat (limited to 'client')
-rw-r--r--client/client.js29
-rw-r--r--client/style.css3
2 files changed, 12 insertions, 20 deletions
diff --git a/client/client.js b/client/client.js
index f2b0632..2f33dc6 100644
--- a/client/client.js
+++ b/client/client.js
@@ -264,33 +264,16 @@ var COMMANDS = {
if (ignoredUsers.indexOf(args.nick) >= 0) {
return;
}
-
- if (args.text.toLowerCase().includes("@" + myNick.toLowerCase().split("#")[0])) {
- notify(args);
- pushMessage(args);
- // Indicate the message which was just added via style
- document.getElementById("messages").lastChild.style.fontWeight = "bold"
- } else {
- pushMessage(args);
- }
+ pushMessage(args);
},
info: function (args) {
args.nick = '*';
-
- if (args.from != null && (args.type.toLowerCase() == "whisper" || args.type.toLowerCase() == "invite")) {
- notify(args);
- pushMessage(args);
- // Make the message bold to stand out as a @mention
- document.getElementById("messages").lastChild.style.fontWeight = "bold"
- } else {
- pushMessage(args);
- }
+ pushMessage(args);
},
warn: function (args) {
args.nick = '!';
- notify(args);
pushMessage(args);
},
@@ -331,8 +314,14 @@ function pushMessage(args) {
// Message container
var messageEl = document.createElement('div');
- if (typeof (myNick) === 'string' && args.text.includes('@' + myNick.split('#')[0] + ' ')) {
+ if (
+ typeof (myNick) === 'string' && (
+ args.text.match(new RegExp('@' + myNick.split('#')[0], "gi")) ||
+ ((args.type === "whisper" || args.type === "invite") && args.from)
+ )
+ ) {
messageEl.classList.add('refmessage');
+ notify(args);
} else {
messageEl.classList.add('message');
}
diff --git a/client/style.css b/client/style.css
index ca8abcf..7ec7ac1 100644
--- a/client/style.css
+++ b/client/style.css
@@ -65,6 +65,9 @@ ul li {
.message, .refmessage {
padding-bottom: 1em;
}
+.refmessage {
+ font-weight: bold;
+}
.nick {
float: left;
width: 16em;