From 5c71423eed116420d431064c9a12a81d50104558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20L=C3=B3pez=20Brante?= Date: Tue, 26 Jan 2016 06:02:02 -0300 Subject: [PATCH] Enable the use of UWP (Windows 10) toasts --- js/notifications.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/js/notifications.js b/js/notifications.js index 3242ce0..0f79a15 100644 --- a/js/notifications.js +++ b/js/notifications.js @@ -45,7 +45,28 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', fu tag: 'gb-highlight-vib' }); }); + } else if (typeof Windows !== 'undefined' && typeof Windows.UI !== 'undefined' && typeof Windows.UI.Notifications !== 'undefined') { + + var winNotifications = Windows.UI.Notifications; + var toastNotifier = winNotifications.ToastNotificationManager.createToastNotifier(); + var template = winNotifications.ToastTemplateType.toastText02; + var toastXml = winNotifications.ToastNotificationManager.getTemplateContent(template); + var toastTextElements = toastXml.getElementsByTagName("text"); + + toastTextElements[0].appendChild(toastXml.createTextNode(title)); + toastTextElements[1].appendChild(toastXml.createTextNode(body)); + + var toast = new winNotifications.ToastNotification(toastXml); + + toast.onactivated = function() { + models.setActiveBuffer(buffer.id); + window.focus(); + }; + + toastNotifier.show(toast); + } else { + var notification = new Notification(title, { body: body, icon: 'assets/img/favicon.png' @@ -74,7 +95,9 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', fu notification.onclose = function() { delete notifications[this.id]; }; + } + };