var notifications = (function () { var exports = {}; var notice_memory = {}; var window_has_focus = true; var asked_permission_already = false; var names; var supports_sound; var unread_pms_favicon = '/static/images/favicon/favicon-pms.png'; var current_favicon; var previous_favicon; var flashing = false; function browser_desktop_notifications_on () { return (window.webkitNotifications && // Firefox on Ubuntu claims to do webkitNotifications but its notifications are terrible $.browser.webkit && // 0 is PERMISSION_ALLOWED window.webkitNotifications.checkPermission() === 0) || // window.bridge is the desktop client (window.bridge !== undefined); } function cancel_notification_object (notification_object) { // We must remove the .onclose so that it does not trigger on .cancel notification_object.onclose = function () {}; notification_object.onclick = function () {}; notification_object.cancel(); } exports.initialize = function () { $(window).focus(function () { window_has_focus = true; _.each(notice_memory, function (notice_mem_entry) { cancel_notification_object(notice_mem_entry.obj); }); notice_memory = {}; // Update many places on the DOM to reflect unread // counts. process_visible_unread_messages(); }).blur(function () { window_has_focus = false; }); if ($.browser.mozilla === true && typeof Notification !== "undefined") { Notification.requestPermission(function () { asked_permission_already = true; }); } if (window.bridge !== undefined) { supports_sound = true; return; } var audio = $("