mirror of
https://github.com/thelounge/thelounge
synced 2024-11-27 14:30:57 +00:00
Merge pull request #425 from thelounge/yamanickill/custom-highlights
Add custom highlights
This commit is contained in:
commit
0de9f61e8d
2 changed files with 29 additions and 2 deletions
|
@ -273,6 +273,14 @@
|
|||
Enable notification for all messages
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12">
|
||||
<label class="opt">
|
||||
<label for="highlights" class="sr-only">Custom highlights (comma-separated keywords)</label>
|
||||
<input type="text" id="highlights" name="highlights" class="input" placeholder="Custom highlights (comma-separated keywords)">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<% if (!public) { %>
|
||||
<div id="change-password">
|
||||
<form action="" method="post">
|
||||
|
|
|
@ -224,6 +224,12 @@ $(function() {
|
|||
var chan = chat.find(target);
|
||||
var msg;
|
||||
|
||||
if (highlights.some(function(h) {
|
||||
return data.msg.text.indexOf(h) > -1;
|
||||
})) {
|
||||
data.msg.highlight = true;
|
||||
}
|
||||
|
||||
if ([
|
||||
"invite",
|
||||
"join",
|
||||
|
@ -466,12 +472,15 @@ $(function() {
|
|||
}
|
||||
settings.find("#user-specified-css-input").val(options[i]);
|
||||
continue;
|
||||
}
|
||||
if (options[i]) {
|
||||
} else if (i === "highlights") {
|
||||
settings.find("input[name=" + i + "]").val(options[i]);
|
||||
} else if (options[i]) {
|
||||
settings.find("input[name=" + i + "]").prop("checked", true);
|
||||
}
|
||||
}
|
||||
|
||||
var highlights = [];
|
||||
|
||||
settings.on("change", "input, textarea", function() {
|
||||
var self = $(this);
|
||||
var name = self.attr("name");
|
||||
|
@ -501,6 +510,16 @@ $(function() {
|
|||
if (name === "userStyles") {
|
||||
$(document.head).find("#user-specified-css").html(options[name]);
|
||||
}
|
||||
if (name === "highlights") {
|
||||
var highlightString = options[name];
|
||||
highlights = highlightString.split(",").map(function(h) {
|
||||
return h.trim();
|
||||
}).filter(function(h) {
|
||||
// Ensure we don't have empty string in the list of highlights
|
||||
// otherwise, users get notifications for everything
|
||||
return h !== "";
|
||||
});
|
||||
}
|
||||
}).find("input")
|
||||
.trigger("change");
|
||||
|
||||
|
|
Loading…
Reference in a new issue