var notifications = (function () {
var exports = {};
var notice_memory = {};
var window_has_focus = true;
var asked_permission_already = false;
var names;
var supports_sound;
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);
}
exports.initialize = function () {
names = page_params.fullname.toLowerCase().split(" ");
names.push(page_params.email.split("@")[0].toLowerCase());
names.push("all");
names.push("everyone");
names.push("" + page_params.fullname.toLowerCase() + "");
$(window).focus(function () {
window_has_focus = true;
exports.update_title_count();
$.each(notice_memory, function (index, notice_mem_entry) {
notice_mem_entry.obj.cancel();
});
process_visible_unread_messages();
}).blur(function () {
window_has_focus = false;
}).mouseover(function () {
exports.update_title_count();
});
if (!window.webkitNotifications) {
return;
}
$(document).click(function () {
if (!page_params.desktop_notifications_enabled || asked_permission_already) {
return;
}
if (window.webkitNotifications.checkPermission() !== 0) { // 0 is PERMISSION_ALLOWED
window.webkitNotifications.requestPermission(function () {});
asked_permission_already = true;
}
});
var audio = $("