<commit_before>$unreadCount = $('<span id="unread-notifications-count"></span>');


var Notification = {

  setup: function() {
    if ($('#notifications').length > 0) {
      $.ajax({
        url: "/api/notifications.json",
        dataType: "JSON",
        method: "GET",
        success: Notification.render
      });
    }

    $('#notifications').click(Notification.markAsRead);
  },

  render: function(data) {
    console.log(data);
    var itemContent, imageTag;

    var items = $.map(data, function(notification) {
      switch(notification.type) {
        case "post":
          itemContent = notification.actor + " " + notification.action + " " + notification.type;
          break;
        case "user":
          itemContent = notification.actor + " " + notification.action;
          break;
        case "response":
          itemContent = notification.actor + " " + notification.action + " " + notification.type
          break;
      }
      imageTag = '<img width="35" class="avatar-image" src="' + notification.actor_avatar + '"/>';

      return '<li><a href="' + notification.url + '">' + imageTag + itemContent + '</br><small>' + notification.time_ago + '</small></a></li>';
    });

    if (items.length > 0) {
      $('#notification-items').html(items.join(' '));
      $unreadCount.text(items.length);
      $('#bell').after($unreadCount);
      $('#bell').hide();
      $('#notifications').addClass('active');
    } else {
      $('#notification-items').html("<li><a>No notifications yet</a></li>");
    }
  },

  markAsRead: function() {
    $.ajax({
      url: '/api/notifications/mark_as_read',
      method: 'POST',
      dataType: 'JSON',
      success: function() {
        $('#bell').show();
        $('#notifications').removeClass('active');
        $unreadCount.hide();
      }
    });
  }
}


$(document).ready( Notification.setup );
$(document).on( 'page:load', Notification.setup );
<commit_msg>Minor change in markup for notification dropdown<commit_after>$unreadCount = $('<span id="unread-notifications-count"></span>');


var Notification = {

  setup: function() {
    if ($('#notifications').length > 0) {
      $.ajax({
        url: "/api/notifications.json",
        dataType: "JSON",
        method: "GET",
        success: Notification.render
      });
    }

    $('#notifications').click(Notification.markAsRead);
  },

  render: function(data) {
    console.log(data);
    var itemContent, imageTag;

    var items = $.map(data, function(notification) {
      switch(notification.type) {
        case "post":
          itemContent = notification.actor + " " + notification.action + " " + notification.type;
          break;
        case "user":
          itemContent = notification.actor + " " + notification.action;
          break;
        case "response":
          itemContent = notification.actor + " " + notification.action + " " + notification.type
          break;
      }
      imageTag = '<img width="35" class="avatar-image" src="' + notification.actor_avatar + '"/>';

      return '<li><a href="' + notification.url + '">' + imageTag + '<div>' + itemContent + '</br><small>' + notification.time_ago + '</small></div></a></li>';
    });

    if (items.length > 0) {
      $('#notification-items').html(items.join(' '));
      $unreadCount.text(items.length);
      $('#bell').after($unreadCount);
      $('#bell').hide();
      $('#notifications').addClass('active');
    } else {
      $('#notification-items').html("<li><a>No notifications yet</a></li>");
    }
  },

  markAsRead: function() {
    $.ajax({
      url: '/api/notifications/mark_as_read',
      method: 'POST',
      dataType: 'JSON',
      success: function() {
        $('#bell').show();
        $('#notifications').removeClass('active');
        $unreadCount.hide();
      }
    });
  }
}


$(document).ready( Notification.setup );
$(document).on( 'page:load', Notification.setup );

{'fraction_non_alphanumeric': 0.194125159642401, 'fraction_numerical': 0.0020434227330779057, 'mean_word_length': 2.6598130841121495, 'pattern_counts': {'":': 6, '<': 33, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3418385', 'n_tokens_mistral': 1162, 'n_tokens_neox': 1137, 'n_words': 201}