Merge pull request #540 from nickel715/patch-446

Implement notifications for all messages
This commit is contained in:
Jérémie Astori 2016-01-10 18:03:32 -05:00
commit ab2dc3e806
2 changed files with 12 additions and 2 deletions

View File

@ -258,6 +258,13 @@
<button id="play">Play sound</button> <button id="play">Play sound</button>
</div> </div>
</div> </div>
<div class="col-sm-12">
<label class="opt">
<input type="checkbox" name="notifyAllMessages">
Enable notification for all messages
</label>
</div>
<div class="col-sm-12"> <div class="col-sm-12">
<h2>About Shout</h2> <h2>About Shout</h2>
</div> </div>

View File

@ -373,6 +373,7 @@ $(function() {
part: true, part: true,
thumbnails: true, thumbnails: true,
quit: true, quit: true,
notifyAllMessages: false,
}, $.cookie("settings")); }, $.cookie("settings"));
for (var i in options) { for (var i in options) {
@ -398,6 +399,7 @@ $(function() {
"nick", "nick",
"part", "part",
"quit", "quit",
"notifyAllMessages",
].indexOf(name) !== -1) { ].indexOf(name) !== -1) {
chat.toggleClass("hide-" + name, !self.prop("checked")); chat.toggleClass("hide-" + name, !self.prop("checked"));
} }
@ -599,9 +601,10 @@ $(function() {
var isQuery = button.hasClass("query"); var isQuery = button.hasClass("query");
var type = msg.type; var type = msg.type;
var highlight = type.contains("highlight"); var highlight = type.contains("highlight");
if (highlight || isQuery) { var message = type.contains("message");
if (!document.hasFocus() || !$(target).hasClass("active")) {
var settings = $.cookie("settings") || {}; var settings = $.cookie("settings") || {};
if (highlight || isQuery || (settings.notifyAllMessages && message)) {
if (!document.hasFocus() || !$(target).hasClass("active")) {
if (settings.notification) { if (settings.notification) {
pop.play(); pop.play();
} }