Merge pull request #425 from thelounge/yamanickill/custom-highlights
Add custom highlights
This commit is contained in:
commit
0de9f61e8d
@ -273,6 +273,14 @@
|
|||||||
Enable notification for all messages
|
Enable notification for all messages
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</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) { %>
|
<% if (!public) { %>
|
||||||
<div id="change-password">
|
<div id="change-password">
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
|
@ -224,6 +224,12 @@ $(function() {
|
|||||||
var chan = chat.find(target);
|
var chan = chat.find(target);
|
||||||
var msg;
|
var msg;
|
||||||
|
|
||||||
|
if (highlights.some(function(h) {
|
||||||
|
return data.msg.text.indexOf(h) > -1;
|
||||||
|
})) {
|
||||||
|
data.msg.highlight = true;
|
||||||
|
}
|
||||||
|
|
||||||
if ([
|
if ([
|
||||||
"invite",
|
"invite",
|
||||||
"join",
|
"join",
|
||||||
@ -466,12 +472,15 @@ $(function() {
|
|||||||
}
|
}
|
||||||
settings.find("#user-specified-css-input").val(options[i]);
|
settings.find("#user-specified-css-input").val(options[i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
} else if (i === "highlights") {
|
||||||
if (options[i]) {
|
settings.find("input[name=" + i + "]").val(options[i]);
|
||||||
|
} else if (options[i]) {
|
||||||
settings.find("input[name=" + i + "]").prop("checked", true);
|
settings.find("input[name=" + i + "]").prop("checked", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var highlights = [];
|
||||||
|
|
||||||
settings.on("change", "input, textarea", function() {
|
settings.on("change", "input, textarea", function() {
|
||||||
var self = $(this);
|
var self = $(this);
|
||||||
var name = self.attr("name");
|
var name = self.attr("name");
|
||||||
@ -501,6 +510,16 @@ $(function() {
|
|||||||
if (name === "userStyles") {
|
if (name === "userStyles") {
|
||||||
$(document.head).find("#user-specified-css").html(options[name]);
|
$(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")
|
}).find("input")
|
||||||
.trigger("change");
|
.trigger("change");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user