function generateHTMLForNotificationsList()

in geode-pulse/src/main/webapp/scripts/pulsescript/common.js [476:670]


function generateHTMLForNotificationsList(notificationList, recordCount){

  var errorAlertsList = notificationList.errors;
  var severeAlertsList = notificationList.severe;
  var warningAlertsList = notificationList.warnings;
  var infoAlertsList = notificationList.info;

  var allListHTML = "";
  var allCount = 1;

  if ($("#allAlertScrollPane").hasClass("hide-scroll-pane"))
    $("#allAlertScrollPane").removeClass("hide-scroll-pane");

  if (severeAlertsList != null && severeAlertsList != undefined) {

    if ($("#severeAlertScrollPane").hasClass("hide-scroll-pane"))
      $("#severeAlertScrollPane").removeClass("hide-scroll-pane");
    document.getElementById("severeTotalCount").innerHTML = severeAlertsList.length
        .toString();
    // update global count
    numTotalSeverAlerts = severeAlertsList.length;
    var severeListHTML = "";
    var severeCount = 1;

    for ( var i = numTotalSeverAlerts - 1; i >= 0; i--) {
      if (severeCount <= recordCount) {
        severeListHTML = severeListHTML
            + generateNotificationAlerts(severeAlertsList[i], "severe");
        severeCount++;
        //severAlerts[severAlerts.length] = severeAlertsList[i];
      }
      if (allCount <= recordCount) {
        allCount++;
        allListHTML = severeListHTML;
      }
    }
    document.getElementById("severeList").innerHTML = severeListHTML;

  } else {
    numTotalSeverAlerts = 0;
    document.getElementById("severeTotalCount").innerHTML = numTotalSeverAlerts;
  }

  if (errorAlertsList != null && errorAlertsList != undefined) {

    if ($("#errorAlertScrollPane").hasClass("hide-scroll-pane"))
      $("#errorAlertScrollPane").removeClass("hide-scroll-pane");
    document.getElementById("errorTotalCount").innerHTML = errorAlertsList.length;
    // update global count
    numTotalErrorAlerts = errorAlertsList.length;
    var errorListHTML = "";
    var errorCount = 1;
    for ( var i = numTotalErrorAlerts - 1; i >= 0; i--) {
      if (errorCount <= recordCount) {
        errorListHTML = errorListHTML
            + generateNotificationAlerts(errorAlertsList[i], "error");
        //errorAlerts[errorAlerts.length] = errorAlertsList[i];
        errorCount++;
      }
      if (allCount <= recordCount) {
        allCount++;
        allListHTML = allListHTML
            + generateNotificationAlerts(errorAlertsList[i], "error");
      }

    }
    document.getElementById("errorList").innerHTML = errorListHTML;

  } else {
    numTotalErrorAlerts = 0;
    document.getElementById("errorTotalCount").innerHTML = numTotalErrorAlerts;
  }

  if (warningAlertsList != null && warningAlertsList != undefined) {

    if ($("#warningAlertScrollPane").hasClass("hide-scroll-pane"))
      $("#warningAlertScrollPane").removeClass("hide-scroll-pane");
    document.getElementById("warningTotalCount").innerHTML = warningAlertsList.length;
    // update global count
    numTotalWarningAlerts = warningAlertsList.length;
    var warningListHTML = "";
    var warningCount = 1;
    for ( var i = numTotalWarningAlerts - 1; i >= 0; i--) {
      if (warningCount <= recordCount) {
        warningListHTML = warningListHTML
            + generateNotificationAlerts(warningAlertsList[i], "warning");
        //warningAlerts[warningAlerts.length] = warningAlertsList[i];
        warningCount++;
      }
      if (allCount <= recordCount) {
        allCount++;
        allListHTML = allListHTML
            + generateNotificationAlerts(warningAlertsList[i], "warning");
      }
    }
    document.getElementById("warningList").innerHTML = warningListHTML;

  } else {
    numTotalWarningAlerts = 0;
    document.getElementById("warningTotalCount").innerHTML = numTotalWarningAlerts;
  }

  if (infoAlertsList != null && infoAlertsList != undefined) {

    // update global count
    numTotalInfoAlerts = infoAlertsList.length;
    var infoCount = 1;
    for ( var i = numTotalInfoAlerts - 1; i >= 0; i--) {
      if (infoCount <= recordCount) {
        infoCount++;
      }
      if (allCount <= recordCount) {
        allCount++;
        allListHTML = allListHTML
            + generateNotificationAlerts(infoAlertsList[i], "info");
      }
    }
  } else {
    numTotalInfoAlerts = 0;
  }

  // Show/hide alert count on top ribbon
  displayAlertCounts();

  // start : for all alerts tab
  var allAlertCount = numTotalSeverAlerts + numTotalErrorAlerts
      + numTotalWarningAlerts + numTotalInfoAlerts;
  document.getElementById("allAlertCount").innerHTML = allAlertCount.toString();
  // Display Load More only when number of alerts > 100
  if (allAlertCount > 100) {
    $('#containerLoadMoreAlertsLink').show();
  } else {
    $('#containerLoadMoreAlertsLink').hide();
  }

  /*var allAlertHTML = "";

  allAlertHTML = allAlertHTML + document.getElementById("severeList").innerHTML;

  allAlertHTML = allAlertHTML + document.getElementById("errorList").innerHTML;

  allAlertHTML = allAlertHTML + document.getElementById("warningList").innerHTML;*/

  document.getElementById("allAlertList").innerHTML = allListHTML;

  // end : for all alerts tab

  if (severAlerts.length > 0) { // Severe
    if ($("#allAlertScrollPane").hasClass("hide-scroll-pane"))
      $("#allAlertScrollPane").removeClass("hide-scroll-pane");
    $('#clusterStatusText').html("Severe");
    $("#clusterStatusIcon").addClass("severeStatus");
  } else if (errorAlerts.length > 0) { // Error
    if ($("#allAlertScrollPane").hasClass("hide-scroll-pane"))
      $("#allAlertScrollPane").removeClass("hide-scroll-pane");
    $('#clusterStatusText').html("Error");
    $("#clusterStatusIcon").addClass("errorStatus");
  } else if (warningAlerts.length > 0) { // Warning
    if ($("#allAlertScrollPane").hasClass("hide-scroll-pane"))
      $("#allAlertScrollPane").removeClass("hide-scroll-pane");
    $('#clusterStatusText').html("Warning");
    $("#clusterStatusIcon").addClass("warningStatus");
  } else { // Normal
    $('#clusterStatusText').html("Normal");
    $("#clusterStatusIcon").addClass("normalStatus");
  }
  $('.scroll-pane').jScrollPane();

  // tooltip
  $("#allAlertScrollPane .jspPane").scroll(function() {

  });
  
  // $(".tip_trigger").moveIntoView();
  $(".tip_trigger").each(function() {
    $(this).hover(function() {
      var tooltip = $(this).find('.tooltip');

      tooltip.show(100); // Show tooltip
      var p = $(this);
      var offset = p.offset();

      var t = offset.top - $(window).scrollTop();
      // var l = position.left;
      $(tooltip).css("top", t);
      $(tooltip).find('.tooltipcontent').css("height", 100);
      $(tooltip).find('.tooltipcontent').jScrollPane();
      // setTimeout($(this).show(), 500);
    }, function() {
      var tooltip = $(this).find('.tooltip');
      tooltip.hide(); // Hide tooltip

    });
  });
}