mirror of
https://github.com/hack-chat/main.git
synced 2024-03-22 13:20:33 +08:00
Bugfix for @mentions
This commit is contained in:
parent
60c23cb52d
commit
a3b9a6abda
|
@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
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);
|
||||
}
|
||||
},
|
||||
|
||||
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');
|
||||
}
|
||||
|
|
|
@ -65,6 +65,9 @@ ul li {
|
|||
.message, .refmessage {
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
.refmessage {
|
||||
font-weight: bold;
|
||||
}
|
||||
.nick {
|
||||
float: left;
|
||||
width: 16em;
|
||||
|
|
Loading…
Reference in New Issue
Block a user