<commit_before>(function ($) {
  // register namespace
  $.extend(true, window, {
    "cadc": {
      "vot": {
        "Viewer": Viewer,
        "CHECKBOX_SELECTOR_COLUMN_ID": "_checkbox_selector",
        "datatype": {
          "NUMERIC": "NUMERIC",
          "STRING": "STRING",
          "DATETIME": "DATETIME"
        },
        "DEFAULT_CELL_PADDING_PX": 8,
        "events": {
          "onSort": new jQuery.Event("cadcVOTV:onSort"),
          "onColumnOrderReset": new jQuery.Event("cadcVOTV:onColumnOrderReset")
        }
      }
    }
  });

  /**
   * Create a VOView object.  This is here to package everything together.
   *
   * @param targetNodeSelector  The target node selector to place the this.
   * @param options             The options object.
   * editable: true/false,
   * enableAddRow: true/false,
   * showHeaderRow: true/false,
   * enableCellNavigation: true/false,
   * asyncEditorLoading: true/false,
   * forceFitColumns: true/false,
   * explicitInitialization: true/false,
   * topPanelHeight: Number,
   * headerRowHeight: Number,
   * showTopPanel: true,
   * sortColumn: Start Date
   * sortDir: asc/desc
   * @constructor
   */
  function Viewer(targetNodeSelector, options)
  {
    var _self = this;
    var $_lengthFinder = $("#lengthFinder")
        || $("<div id='lengthFinder'></div>").appendTo($(document.body));
    this.dataView = new Slick.Data.DataView({ inlineFilters: true });
    this.grid = null;
    this.columnManager = options.columnManager ? options.columnManager : {};
    this.rowManager = options.rowManager ? options.rowManager : {};

    this.columns = [];
    // displayColumns: columns that are actually in the Grid.
    this.displayColumns = options.displayColumns ? options.displayColumns : [];
    this.resizedColumns = {};  // Columns the user has resized.
    this.columnFilters = options.columnFilters ? options.columnFilters : {};
    this.updatedColumnSelects = {};
    this.targetNodeSelector = targetNodeSelector;
    this.columnOptions = options.columnOptions ? options.columnOptions : {};
    this.options = options;
    this.options.forceFitColumns = options.columnManager
        ? options.columnManager.forceFitColumns
        : false;

    // This is the TableData for a VOTable.  Will be set on load.
    this.longestValues = {};

    this.sortcol = options.sortColumn;
    this.sortAsc = options.sortDir == "asc";

    /**
     * @param input  Object representing the input.
     *
     * One of xmlDOM or json or url is required.
     *
     * input.xmlDOM = The XML DOM Object
     * input.json = The JSON Object
     * input.csv = The CSV text
     * input.url = The URL of the input.  The Content-Type will dictate how to
     *             build it.  This is the only way to stream CSV.
     * @param completeCallback  Callback function when complete.
     * @param errorCallBack     Callback function with jqXHR, status, message
     *                    (Conforms to jQuery error callback for $.ajax calls).
     */
    function build(input, completeCallback, errorCallBack)
    {
      new cadc.vot.Builder(options.maxRowLimit,
                           input, 
                           function (voTableBuilder)
                           {
                             var hasDisplayColumns =
                                 (_self.displayColumns
                                     && (_self.displayColumns.length > 0));

                             // Set up to stream.
                             if (input.url)
                             {
                               var inputFields =
                                   input.tableMetadata.getFields();
                               
                               // TODO: Only add the spinner if the max rows option
                               // has been enabled
                               
                               // add a spinner to the header bar to indicate
                               // streaming has begun
                               var gridHeaderIcon = $("#grid-header-icon");
                               if (gridHeaderIcon)
                               {
                                 gridHeaderIcon.attr("src", "/cadcVOTV/images/PleaseWait-small.gif");
                               }

                               /*
                                * We need to refresh columns twice; once to
                                * display something while the data is streaming,
                                * and again to update the column widths based
                                * on data.
                                *
                                * jenkinsd 2013.12.20
                                */
                               if (!hasDisplayColumns)
                               {
                                 refreshColumns(inputFields);
                               }

                               voTableBuilder.subscribe(cadc.vot.onDataLoadComplete,
                                                        function(event, args)
                               {
                                 setLongestValues(args.longestValues);
                                 resetColumnWidths();
                                 var gridHeaderIcon = $("#grid-header-icon");
                                 if (gridHeaderIcon)
                                 {
                                   if (options.maxRowLimit > getDataView().getPagingInfo().totalRows)
                                   {
                                     gridHeaderIcon.prop("src", "/cadcVOTV/images/transparent-20.png");
                                   }
                                   else
                                   {
                                     gridHeaderIcon.prop("src", "/cadcVOTV/images/warning.gif");
                                   }
                                 }
                               });

                               clearRows();

                               // Setup the Grid and DataView to be loaded.
                               _self.init();

                               voTableBuilder.subscribe(cadc.vot.onPageAddStart,
                                                        function(event)
                                                        {
                                                          getDataView().beginUpdate();
                                                        });
                                                        
                               voTableBuilder.subscribe(cadc.vot.onPageAddEnd,
                                                        function(event)
                                                        {
                                                          getDataView().endUpdate();

                                                          // Sorting as data loads.  Not sure if this is a good idea or not.
                                                          // jenkinsd 2014.05.09
                                                          // WebRT 53730
                                                          //<commit_msg>Story 1572. Added code so that the spinner and warning icon logic is executed only when paging is off.<commit_after>(function ($) {
  // register namespace
  $.extend(true, window, {
    "cadc": {
      "vot": {
        "Viewer": Viewer,
        "CHECKBOX_SELECTOR_COLUMN_ID": "_checkbox_selector",
        "datatype": {
          "NUMERIC": "NUMERIC",
          "STRING": "STRING",
          "DATETIME": "DATETIME"
        },
        "DEFAULT_CELL_PADDING_PX": 8,
        "events": {
          "onSort": new jQuery.Event("cadcVOTV:onSort"),
          "onColumnOrderReset": new jQuery.Event("cadcVOTV:onColumnOrderReset")
        }
      }
    }
  });

  /**
   * Create a VOView object.  This is here to package everything together.
   *
   * @param targetNodeSelector  The target node selector to place the this.
   * @param options             The options object.
   * editable: true/false,
   * enableAddRow: true/false,
   * showHeaderRow: true/false,
   * enableCellNavigation: true/false,
   * asyncEditorLoading: true/false,
   * forceFitColumns: true/false,
   * explicitInitialization: true/false,
   * topPanelHeight: Number,
   * headerRowHeight: Number,
   * showTopPanel: true,
   * sortColumn: Start Date
   * sortDir: asc/desc
   * @constructor
   */
  function Viewer(targetNodeSelector, options)
  {
    var _self = this;
    var $_lengthFinder = $("#lengthFinder")
        || $("<div id='lengthFinder'></div>").appendTo($(document.body));
    this.dataView = new Slick.Data.DataView({ inlineFilters: true });
    this.grid = null;
    this.columnManager = options.columnManager ? options.columnManager : {};
    this.rowManager = options.rowManager ? options.rowManager : {};

    this.columns = [];
    // displayColumns: columns that are actually in the Grid.
    this.displayColumns = options.displayColumns ? options.displayColumns : [];
    this.resizedColumns = {};  // Columns the user has resized.
    this.columnFilters = options.columnFilters ? options.columnFilters : {};
    this.updatedColumnSelects = {};
    this.targetNodeSelector = targetNodeSelector;
    this.columnOptions = options.columnOptions ? options.columnOptions : {};
    this.options = options;
    this.options.forceFitColumns = options.columnManager
        ? options.columnManager.forceFitColumns
        : false;

    // This is the TableData for a VOTable.  Will be set on load.
    this.longestValues = {};

    this.sortcol = options.sortColumn;
    this.sortAsc = options.sortDir == "asc";

    /**
     * @param input  Object representing the input.
     *
     * One of xmlDOM or json or url is required.
     *
     * input.xmlDOM = The XML DOM Object
     * input.json = The JSON Object
     * input.csv = The CSV text
     * input.url = The URL of the input.  The Content-Type will dictate how to
     *             build it.  This is the only way to stream CSV.
     * @param completeCallback  Callback function when complete.
     * @param errorCallBack     Callback function with jqXHR, status, message
     *                    (Conforms to jQuery error callback for $.ajax calls).
     */
    function build(input, completeCallback, errorCallBack)
    {
      new cadc.vot.Builder(options.maxRowLimit,
                           input, 
                           function (voTableBuilder)
                           {
                             var hasDisplayColumns =
                                 (_self.displayColumns
                                     && (_self.displayColumns.length > 0));

                             // Set up to stream.
                             if (input.url)
                             {
                               var inputFields =
                                   input.tableMetadata.getFields();
                               
                               // Display spinner only if paging is off
                               if (!usePager())
                               {
                                 // add a spinner to the header bar to indicate
                                 // streaming has begun
                                 var gridHeaderIcon = $("#grid-header-icon");
                                 if (gridHeaderIcon)
                                 {
                                   gridHeaderIcon.attr("src", "/cadcVOTV/images/PleaseWait-small.gif");
                                 }
                               }

                               /*
                                * We need to refresh columns twice; once to
                                * display something while the data is streaming,
                                * and again to update the column widths based
                                * on data.
                                *
                                * jenkinsd 2013.12.20
                                */
                               if (!hasDisplayColumns)
                               {
                                 refreshColumns(inputFields);
                               }

                               voTableBuilder.subscribe(cadc.vot.onDataLoadComplete,
                                                        function(event, args)
                               {
                                 setLongestValues(args.longestValues);
                                 resetColumnWidths();
				 
                                 // Display spinner only if paging is off
                                 if (!usePager())
                                 {
                                   var gridHeaderIcon = $("#grid-header-icon");
                                   if (gridHeaderIcon)
                                   {
                                     if (options.maxRowLimit > getDataView().getPagingInfo().totalRows)
                                     {
                                       gridHeaderIcon.prop("src", "/cadcVOTV/images/transparent-20.png");
                                     }
                                     else
                                     {
                                       gridHeaderIcon.prop("src", "/cadcVOTV/images/warning.gif");
                                     }
                                   }
                                 }
                               });

                               clearRows();

                               // Setup the Grid and DataView to be loaded.
                               _self.init();

                               voTableBuilder.subscribe(cadc.vot.onPageAddStart,
                                                        function(event)
                                                        {
                                                          getDataView().beginUpdate();
                                                        });
                                                        
                               voTableBuilder.subscribe(cadc.vot.onPageAddEnd,
                                                        function(event)
                                                        {
                                                          getDataView().endUpdate();

                                                          // Sorting as data loads.  Not sure if this is a good idea or not.
                                                          // jenkinsd 2014.05.09
                                                          // WebRT 53730
                                                          //
{'fraction_non_alphanumeric': 0.07849666983824928, 'fraction_numerical': 0.0036699741742558106, 'mean_word_length': 0.9593874833555259, 'pattern_counts': {'":': 24, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 124, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1460122', 'n_tokens_mistral': 3240, 'n_tokens_neox': 3093, 'n_words': 749}