fix Notification not being available crash
This commit is contained in:
parent
4b9db9570c
commit
5ecaa9daca
1 changed files with 24 additions and 21 deletions
|
|
@ -369,28 +369,29 @@ function onNewLine(text, originator) {
|
||||||
unread++;
|
unread++;
|
||||||
favico.badge(unread);
|
favico.badge(unread);
|
||||||
document.title = "(" + unread + ") " + originalTitle;
|
document.title = "(" + unread + ") " + originalTitle;
|
||||||
|
if ("Notification" in window){
|
||||||
|
if (("notification_popup" in options) && (options["notification_popup"])) {
|
||||||
|
Notification.requestPermission().then(function(result) {
|
||||||
|
if(result === "granted") {
|
||||||
|
var title = originalTitle === "" ? "Evennia" : originalTitle;
|
||||||
|
var options = {
|
||||||
|
body: text.replace(/(<([^>]+)>)/ig,""),
|
||||||
|
icon: "/static/website/images/evennia_logo.png"
|
||||||
|
}
|
||||||
|
|
||||||
if (("notification_popup" in options) && (options["notification_popup"])) {
|
var n = new Notification(title, options);
|
||||||
Notification.requestPermission().then(function(result) {
|
n.onclick = function(e) {
|
||||||
if(result === "granted") {
|
e.preventDefault();
|
||||||
var title = originalTitle === "" ? "Evennia" : originalTitle;
|
window.focus();
|
||||||
var options = {
|
this.close();
|
||||||
body: text.replace(/(<([^>]+)>)/ig,""),
|
}
|
||||||
icon: "/static/website/images/evennia_logo.png"
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
var n = new Notification(title, options);
|
}
|
||||||
n.onclick = function(e) {
|
if (("notification_sound" in options) && (options["notification_sound"])) {
|
||||||
e.preventDefault();
|
var audio = new Audio("/static/webclient/media/notification.wav");
|
||||||
window.focus();
|
audio.play();
|
||||||
this.close();
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (("notification_sound" in options) && (options["notification_sound"])) {
|
|
||||||
var audio = new Audio("/static/webclient/media/notification.wav");
|
|
||||||
audio.play();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -427,7 +428,9 @@ function doStartDragDialog(event) {
|
||||||
// Event when client finishes loading
|
// Event when client finishes loading
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
Notification.requestPermission();
|
if ("Notification" in window) {
|
||||||
|
Notification.requestPermission();
|
||||||
|
}
|
||||||
|
|
||||||
favico = new Favico({
|
favico = new Favico({
|
||||||
animation: 'none'
|
animation: 'none'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue