$(function(){
    var fetch_notifications = function(){
        console.log('polling...');
        var $notification_bell = $('#notification_bell');
        $.get($notification_bell.data('url'), function(response){
                update_notifications(response);
            }, "json")
            .fail(function(){
                console.log("Error fetching notifications from server");
            });
        setTimeout(fetch_notifications, $notification_bell.data('poll-interval'));
    };

    var update_notifications = function(response_data){
        var $notification_badge = $('#notification_badge');
        var number_notifications = response_data;
        var current_val = $notification_badge.text();
        if(number_notifications == 0){
            $notification_badge.text('');
        }else if(number_notifications != current_val){
            $('#notification_badge').animateCss('swing');
            $notification_badge.text(number_notifications);
        }
    };

    fetch_notifications();
});

@@ -138,24 +138,72 @@
 ion_bell');%0A
+        if($notification_bell.data('url'))%7B%0A    
         $.ge
@@ -272,16 +272,20 @@
         
+    
 update_n
@@ -320,16 +320,20 @@
         
+ 
+   
 %7D, %22json
@@ -335,16 +335,20 @@
 %22json%22)%0A
+    
         
@@ -377,32 +377,36 @@
                 
+   
+ 
 console.log(%22Err
@@ -446,16 +446,20 @@
 rver%22);%0A
+    
         
@@ -474,16 +474,20 @@
         
+    
 setTimeo
@@ -553,16 +553,27 @@
 val'));%0A
+        %7D%0A%0A
     %7D;%0A%0A

fix infinite loop bug when notification ajax url not yet present