<commit_before>$(function() {

  var syncAlertBanner = function() {
    $.getJSON("/portal/system-alerts/banner", function(json, xhr) {
      renderBannerAlerts(json);
    });
  };

  var clearBannerAlerts = function() {
    $(".system-alert-banner").remove();
  };

  var hasAlertBeenDismissed = function(alertId) {
    var dismissedIds = [];
    if ($.cookie("system-alert-banners-dismissed") != null) {
      dismissedIds = $.cookie("system-alert-banners-dismissed").split(",");
    }
    return dismissedIds.indexOf(alertId) >= 0
  };

  var markAlertAsDismissed = function(alertId) {
    if ($.cookie("system-alert-banners-dismissed") != null) {
      var ids = $.cookie("system-alert-banners-dismissed");
      $.cookie("system-alert-banners-dismissed", ids + "," + alertId, { path: "/" });
    } else {
      $.cookie("system-alert-banners-dismissed", alertId, { path: "/" });
    };
  };

  var handleBannerAlertClose = function($alert) {
    markAlertAsDismissed($alert.attr("id"));
    $alert.remove();
  };

  var renderBannerAlerts = function(alerts) {
    if (alerts.length == 0) {
      return clearBannerAlerts();
    }

    var activeAlertIds = [];

    // ensure all active alerts are rendered
    $.each(alerts, function(i, alert) {
      var alertId = "bannerAlert"+alert.id;

      if (!hasAlertBeenDismissed(alertId)) {
        activeAlertIds.push(alertId);

        if ($("#"+alertId).length == 0) {
            var $alert = $($("#systemAlertsBannerTemplate").html()).attr("id", alertId);
            $alert.find(".system-alert-banner-message").html(alert.message);
            $(document.body).prepend($alert);
        }
      }
    });
<commit_msg>CLASSES-1587 animate the display and hiding of the system banner messages to soften when the message is inserted in the page (avoids a flicker)<commit_after>$(function() {

  var syncAlertBanner = function() {
    $.getJSON("/portal/system-alerts/banner", function(json, xhr) {
      renderBannerAlerts(json);
    });
  };

  var clearBannerAlerts = function() {
    $(".system-alert-banner").remove();
  };

  var hasAlertBeenDismissed = function(alertId) {
    var dismissedIds = [];
    if ($.cookie("system-alert-banners-dismissed") != null) {
      dismissedIds = $.cookie("system-alert-banners-dismissed").split(",");
    }
    return dismissedIds.indexOf(alertId) >= 0
  };

  var markAlertAsDismissed = function(alertId) {
    if ($.cookie("system-alert-banners-dismissed") != null) {
      var ids = $.cookie("system-alert-banners-dismissed");
      $.cookie("system-alert-banners-dismissed", ids + "," + alertId, { path: "/" });
    } else {
      $.cookie("system-alert-banners-dismissed", alertId, { path: "/" });
    };
  };

  var handleBannerAlertClose = function($alert) {
    markAlertAsDismissed($alert.attr("id"));
    $alert.slideUp(function() {
      $alert.remove();
    });
  };

  var renderBannerAlerts = function(alerts) {
    if (alerts.length == 0) {
      return clearBannerAlerts();
    }

    var activeAlertIds = [];

    // ensure all active alerts are rendered
    $.each(alerts, function(i, alert) {
      var alertId = "bannerAlert"+alert.id;

      if (!hasAlertBeenDismissed(alertId)) {
        activeAlertIds.push(alertId);

        if ($("#"+alertId).length == 0) {
            var $alert = $($("#systemAlertsBannerTemplate").html()).attr("id", alertId);
            $alert.find(".system-alert-banner-message").html(alert.message);
            $alert.hide();
            $(document.body).prepend($alert);
            $alert.slideDown();
        }
      }
    });

{'fraction_non_alphanumeric': 0.17566433566433567, 'fraction_numerical': 0.002797202797202797, 'mean_word_length': 3.00447928331467, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4739735', 'n_tokens_mistral': 1162, 'n_tokens_neox': 1119, 'n_words': 188}