aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoslot <pines@null.net>2019-05-19 23:11:16 +0200
committerRoslot <pines@null.net>2019-05-19 23:11:16 +0200
commita3b9a6abda5ba9ded94a71a9071359faba228382 (patch)
tree5aa6ac159f09cd83697cf4845d9a0215d0bac2ef
parentUpdate notify.mp3 (diff)
downloadhackchat-a3b9a6abda5ba9ded94a71a9071359faba228382.tar.gz
hackchat-a3b9a6abda5ba9ded94a71a9071359faba228382.zip
Bugfix for @mentions
Diffstat (limited to '')
-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;