From e2f3a85dbdd1f54626399601e2ba0f84e4b5afba Mon Sep 17 00:00:00 2001 From: Jeff Arnold Date: Tue, 12 Feb 2013 00:15:42 -0500 Subject: [PATCH] Clean up the notification code (imported from commit 5bd811ba40b3f535d474ac53e22fd16816f9bac6) --- zephyr/static/js/notifications.js | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/zephyr/static/js/notifications.js b/zephyr/static/js/notifications.js index f838a88632..90423e8ca9 100644 --- a/zephyr/static/js/notifications.js +++ b/zephyr/static/js/notifications.js @@ -18,14 +18,7 @@ function browser_desktop_notifications_on () { exports.initialize = function () { names = fullname.toLowerCase().split(" "); - var username = email.split("@")[0].toLowerCase(); - // If the username is part of the user's full name, then don't add it - // to names because we don't send notifications to ambiguous names - // that could refer to multiple people in the domain. - // (We later add to names all of the names from the domain) - if (names.indexOf(username) === -1) { - names.push(username); - } + names.push(email.split("@")[0].toLowerCase()); $(window).focus(function () { window_has_focus = true; @@ -133,8 +126,7 @@ function process_desktop_notification(message) { function speaking_at_me(message) { var content_lc = $('
').html(message.content).text().toLowerCase(); - var match_so_far = false; - var indexof, after_name, after_atname; + var found_match = false, indexof, after_name, after_atname; var punctuation = /[\.,-\/#!$%\^&\*;:{}=\-_`~()\+\?\[\]\s]/; if (domain === "mit.edu") { @@ -158,17 +150,12 @@ function speaking_at_me(message) { after_name.match(punctuation) !== null) || (indexof > 0 && content_lc.charAt(indexof-1) === "@" && after_name.match(punctuation) !== null)) { - if (match_so_far) { - match_so_far = false; + found_match = true; return false; - } - else { - match_so_far = true; - } } }); - return match_so_far; + return found_match; } exports.received_messages = function (messages) {