From 7027a2cf9b4575534307387614e930626d189a60 Mon Sep 17 00:00:00 2001 From: Simon Vermeersch Date: Sun, 15 Jan 2017 13:43:00 +0100 Subject: [PATCH] Implemented the notification popup option --- .../static/webclient/js/webclient_gui.js | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/evennia/web/webclient/static/webclient/js/webclient_gui.js b/evennia/web/webclient/static/webclient/js/webclient_gui.js index cbe543a67..84b4addb5 100644 --- a/evennia/web/webclient/static/webclient/js/webclient_gui.js +++ b/evennia/web/webclient/static/webclient/js/webclient_gui.js @@ -349,27 +349,24 @@ function onNewLine(text, originator) { favico.badge(unread); document.title = "(" + unread + ") " + originalTitle; - //// TODO: Following code adds a full notification popup. It - //// works fine but should be possible to turn off if a player - //// wants to (pending webclient config pane). - //// - //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" - // } - // - // var n = new Notification(title, options); - // n.onclick = function(e) { - // e.preventDefault(); - // window.focus(); - // this.close(); - // // } - // } - //}) + 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" + } + + var n = new Notification(title, options); + n.onclick = function(e) { + e.preventDefault(); + window.focus(); + this.close(); + } + } + }); + } } }