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,14 +133,42 @@ 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;
notice.ondisplay = function() { if(webkitNotifications.createHTMLNotification)
// 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. notice = webkitNotifications.createHTMLNotification(_browser_notify);
window.setTimeout( function() { }
xajax_doXMLHTTP("notifications.notifications_ajax.confirm_message", _id); else if (webkitNotifications.createNotification)
}, 2000); {
}; // Pull the subject of the messasge, if possible
notice.show(); 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() {
// 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.
window.setTimeout( function() {
xajax_doXMLHTTP("notifications.notifications_ajax.confirm_message", _id);
}, 2000);
};
notice.show();
}
} }
} }