Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Split favicon badge and desktop notifications settings #645

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,14 @@ <h2>Notifications</h2>
</div>
<div class="col-sm-12">
<label class="opt">
<input id="badge" type="checkbox" name="badge">
Enable badge
<input type="checkbox" name="badge">
Enable favicon badge
</label>
</div>
<div class="col-sm-12">
<label class="opt">
<input id="desktopNotifications" type="checkbox" name="desktopNotifications">
Desktop notifications
</label>
</div>
<div class="col-sm-12">
Expand Down
9 changes: 6 additions & 3 deletions client/js/shout.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ $(function() {
var settings = $("#settings");
var options = $.extend({
badge: false,
desktopNotifications: false,
colors: false,
join: true,
links: true,
Expand Down Expand Up @@ -453,7 +454,7 @@ $(function() {
}).find("input")
.trigger("change");

$("#badge").on("change", function() {
$("#desktopNotifications").on("change", function() {
var self = $(this);
if (self.prop("checked")) {
if (Notification.permission !== "granted") {
Expand Down Expand Up @@ -652,8 +653,10 @@ $(function() {
if (settings.notification) {
pop.play();
}
favico.badge("!");
if (settings.badge && Notification.permission === "granted") {
if (settings.badge) {
favico.badge("!");
}
if (settings.desktopNotifications && Notification.permission === "granted") {
var notify = new Notification(msg.from + " says:", {
body: msg.text.trim(),
icon: "/img/logo-64.png",
Expand Down