Fix notifications
This commit is contained in:
parent
4d1aa174a1
commit
0c6c54bc83
@ -12,7 +12,7 @@
|
|||||||
<link rel="stylesheet" href="css/style.css">
|
<link rel="stylesheet" href="css/style.css">
|
||||||
<link id="theme" rel="stylesheet" href="<%=theme%>">
|
<link id="theme" rel="stylesheet" href="<%=theme%>">
|
||||||
|
|
||||||
<link rel="shortcut icon" href="/img/favicon.png">
|
<link rel="shortcut icon" href="/img/logo-32.png">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body class="<%= public ? "public" : "" %>">
|
<body class="<%= public ? "public" : "" %>">
|
||||||
@ -225,6 +225,7 @@
|
|||||||
<script src="js/libs/handlebars/equal.js"></script>
|
<script src="js/libs/handlebars/equal.js"></script>
|
||||||
<script src="js/libs/handlebars/tz.js"></script>
|
<script src="js/libs/handlebars/tz.js"></script>
|
||||||
<script src="js/libs/handlebars/uri.js"></script>
|
<script src="js/libs/handlebars/uri.js"></script>
|
||||||
|
<script src="js/libs/handlebars/users.js"></script>
|
||||||
<script src="js/libs/jquery.js"></script>
|
<script src="js/libs/jquery.js"></script>
|
||||||
<script src="js/libs/jquery/bootstrap.js"></script>
|
<script src="js/libs/jquery/bootstrap.js"></script>
|
||||||
<script src="js/libs/jquery/cookie.js"></script>
|
<script src="js/libs/jquery/cookie.js"></script>
|
||||||
@ -233,14 +234,16 @@
|
|||||||
<script src="js/libs/jquery/stickyscroll.js"></script>
|
<script src="js/libs/jquery/stickyscroll.js"></script>
|
||||||
<script src="js/libs/jquery/tabcomplete.js"></script>
|
<script src="js/libs/jquery/tabcomplete.js"></script>
|
||||||
<script src="js/libs/moment.js"></script>
|
<script src="js/libs/moment.js"></script>
|
||||||
|
<script src="js/libs/notification.js"></script>
|
||||||
<script src="js/libs/socket.io.js"></script>
|
<script src="js/libs/socket.io.js"></script>
|
||||||
<script src="js/libs/string.contains.js"></script>
|
<script src="js/libs/string.contains.js"></script>
|
||||||
<script src="js/libs/uri.js"></script>
|
<script src="js/libs/uri.js"></script>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<script src="js/libs.min.js"></script>
|
<script src="js/libs.min.js"></script>
|
||||||
|
<% } %>
|
||||||
|
|
||||||
<script src="js/shout.templates.js"></script>
|
<script src="js/shout.templates.js"></script>
|
||||||
<script src="js/shout.js"></script>
|
<script src="js/shout.js"></script>
|
||||||
<% } %>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -41,7 +41,7 @@ $(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Request notification permissions if we don't already have it
|
// Request notification permissions if we don't already have it
|
||||||
if (Notification.permission !== 'granted') {
|
if (Notification.permission !== "granted") {
|
||||||
Notification.requestPermission();
|
Notification.requestPermission();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,25 +411,24 @@ $(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
chat.on("msg", ".messages", function(e, target, msg) {
|
chat.on("msg", ".messages", function(e, target, msg) {
|
||||||
var btn = sidebar.find(".chan[data-target=" + target + "]:not(.active)");
|
var button = sidebar.find(".chan[data-target=" + target + "]");
|
||||||
var query = btn.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 || query) {
|
if (highlight || isQuery) {
|
||||||
pop.play();
|
pop.play();
|
||||||
if (!document.hasFocus() || !$(target).hasClass("active")) {
|
if (!document.hasFocus() || !$(target).hasClass("active")) {
|
||||||
favico.badge("!");
|
favico.badge("!");
|
||||||
if (Notification.permission === 'granted') {
|
if (Notification.permission === "granted") {
|
||||||
var n = new Notification( msg.from + ' - ' + btn.data('title'), {
|
var n = new Notification(msg.from + " says:", {
|
||||||
body: msg.text,
|
body: msg.text.trim(),
|
||||||
icon: '/img/favicon.png'
|
icon: ""
|
||||||
} );
|
} );
|
||||||
n.onclick = function() {
|
n.onclick = function() {
|
||||||
window.focus();
|
window.focus();
|
||||||
btn.click();
|
button.click();
|
||||||
this.close();
|
this.close();
|
||||||
};
|
};
|
||||||
// Close notification after 5s
|
|
||||||
window.setTimeout(function() {
|
window.setTimeout(function() {
|
||||||
n.close();
|
n.close();
|
||||||
}, 5 * 1000);
|
}, 5 * 1000);
|
||||||
@ -437,7 +436,8 @@ $(function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (btn.length === 0) {
|
button = button.filter(":not(.active)");
|
||||||
|
if (button.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,12 +451,12 @@ $(function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var badge = btn.find(".badge");
|
var badge = button.find(".badge");
|
||||||
if (badge.length !== 0) {
|
if (badge.length !== 0) {
|
||||||
var i = (badge.data("count") || 0) + 1;
|
var i = (badge.data("count") || 0) + 1;
|
||||||
badge.data("count", i);
|
badge.data("count", i);
|
||||||
badge.html(i > 999 ? (i / 1000).toFixed(1) + "k" : i);
|
badge.html(i > 999 ? (i / 1000).toFixed(1) + "k" : i);
|
||||||
if (highlight || query) {
|
if (highlight || isQuery) {
|
||||||
badge.addClass("highlight");
|
badge.addClass("highlight");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user