- if(e.text().search('→') == 0) {
- var notification = new Notification(document.title, {
- body: e.text().replace('→ ',''),
- icon: e.attr('photo')
- });
-
- // TODO (yet unsupported by most browsers):
- // Implement notification.onclick()
-
- // notifyMarkAll();
- }
+ var notification_id = e.attr('href').match(/\d+$/)[0];
+ if (notification_lastitem!== null && notification_id!=notification_lastitem) {
+ if (notification_first_id===0) notification_first_id = notification_id;
+ if (getNotificationPermission()==="granted") {
+ var notification = new Notification(document.title, {
+ body: e.text().replace('→ ','').format(e.attr('name')),
+ icon: e.attr('photo'),
+ });
+ // close notification after 5 secs.
+ // see https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API/Using_the_Notifications_API#Closing_notifications
+ setTimeout(notification.close.bind(notification), 5000);
+
+ notification.addEventListener("click", function(ev){
+ window.location = ev.target.data;
+ });
+ }
+ }
+ if (notification_id == notification_lastitem) {
+ if (notification_first_id===0) notification_first_id = notification_id;
+ notification_lastitem = null;
+ }
+
+