diff --git a/js/glowingbear.js b/js/glowingbear.js index 43f100f..2f10ca6 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -1023,25 +1023,28 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', title += buffer.shortName; title += buffer.fullName.replace(/irc.([^\.]+)\..+/, " ($1)"); - var notification = new Notification(title, { - body: body, - icon: 'assets/img/favicon.png' - }); + // Chrome for Android doesn't know this + if (typeof Notification !== 'undefined') { + var notification = new Notification(title, { + body: body, + icon: 'assets/img/favicon.png' + }); - // Cancel notification automatically - var timeout = 15*1000; - notification.onshow = function() { - setTimeout(function() { - notification.close(); - }, timeout); - }; + // Cancel notification automatically + var timeout = 15*1000; + notification.onshow = function() { + setTimeout(function() { + notification.close(); + }, timeout); + }; - // Click takes the user to the buffer - notification.onclick = function() { - models.setActiveBuffer(buffer.id); - window.focus(); - notification.close(); - }; + // Click takes the user to the buffer + notification.onclick = function() { + models.setActiveBuffer(buffer.id); + window.focus(); + notification.close(); + }; + } if ($scope.soundnotification) { // TODO fill in a sound file @@ -1049,6 +1052,13 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', var soundHTML = ''; document.getElementById("soundNotification").innerHTML = soundHTML; } + + if (navigator.notification !== undefined) { + console.log('vibrating!'); + navigator.notification.vibrate(500); + } else { + console.log('no notification api :(', navigator.notification); + } }; $scope.hasUnread = function(buffer) {