Try and fallback from HTML to plain text to match spec - removed HTML notifications

This commit is contained in:
Nathan Gray 2012-11-05 18:32:54 +00:00
parent 2218fd8956
commit 20ab9041cf

View File

@ -133,7 +133,34 @@ function append_notification_message(_id, _message, _browser_notify) {
// Notification API // Notification API
if(_browser_notify) if(_browser_notify)
{ {
var notice = webkitNotifications.createHTMLNotification(_browser_notify); var notice;
if(webkitNotifications.createHTMLNotification)
{
notice = webkitNotifications.createHTMLNotification(_browser_notify);
}
else if (webkitNotifications.createNotification)
{
// Pull the subject of the messasge, if possible
var message = /<b>(.*?)<\/b>/.exec(_message);
if(message && message[1])
{
_message = message[1];
}
else
{
_message = _message.replace(/<(?:.|\n)*?>/gm, '');
}
notice = webkitNotifications.createNotification('', "Egroupware",_message);
// When they click, bring up the popup for full info
notice.onclick = function() {
window.focus();
egwpopup_display();
this.close();
}
}
if(notice)
{
notice.ondisplay = function() { notice.ondisplay = function() {
// Confirm when user gets to see it - no close needed // Confirm when user gets to see it - no close needed
// Wait a bit to let it load first, or it might not be there when requested. // Wait a bit to let it load first, or it might not be there when requested.
@ -143,4 +170,5 @@ function append_notification_message(_id, _message, _browser_notify) {
}; };
notice.show(); notice.show();
} }
}
} }