<commit_before>(function ($)
{
  if (typeof A === "undefined")
  {
    // Require AladinLite.
    throw new Error("AladinLite must be present.  (http://aladin.u-strasbg.fr/AladinLite/)");
  }

  // register namespace
  $.extend(true, window, {
    "cadc": {
      "vot": {
        "plugin": {
          "footprint": AladinLiteFootprintViewer
        }
      }
    }
  });


  /**
   * AladinLite footprint viewer.  This is incorporated as a Plugin to allow
   *
   * @constructor
   */
  function AladinLiteFootprintViewer(_inputs)
  {
    var PI_OVER_180 = Math.PI / 180.0;
    var DEG_PER_ARC_SEC = 1.0 / 3600.0;
    var POLYGON_SPLIT = "Polygon ICRS";
    var DEFAULT_FOV_DEGREES = 180;

    var _self = this;
    var _defaults = {
      targetSelector: "#aladin-lite",
      toggleSwitchSelector: null,     // Always show by default.
      toggleClose: function ($toggleSelector)
      {
        $toggleSelector.data("close", $toggleSelector.html());
        $toggleSelector.html($toggleSelector.data("open"));
      },
      toggleOpen: function ($toggleSelector)
      {
        $toggleSelector.data("open", $toggleSelector.html());
        $toggleSelector.html($toggleSelector.data("close"));
      },
      aladin_options: {},  // Specific options for AladinLite.
      renderedRowsOnly: true,
      footprintFieldID: "footprint",
      raFieldID: "ra",
      decFieldID: "dec",
      fovFieldID: "fov",
      colour: "orange",
      navigateToSelected: true,
      highlightColour: "yellow",
      /**
       * Perform further calculations on the FOV before setting it.  Useful
       * for further reducing it (e.g. from square degrees to degrees).
       * @param {Number} fovValue
       * @return  {Number}
       */
      afterFOVCalculation: function (fovValue)
      {
        return fovValue;
      },
      onHover: true,
      onClick: false,
      coords: [1000, -1000, 0, 0]   // Remember to slice this!
    };

    this.grid = null;

    /**
     * {cadc.vot.Viewer}
     */
    this.viewer = null;
    this.handler = new Slick.EventHandler();

    var inputs = $.extend(true, {}, _defaults, _inputs);

    this.footprintFieldID = inputs.footprintFieldID;
    this.raFieldID = inputs.raFieldID;
    this.decFieldID = inputs.decFieldID;
    this.fovFieldID = inputs.fovFieldID;
    this.$target = $(inputs.targetSelector);

    //
    // Declare AladinLite
    //
    this.aladin = null;

    // footprint overlay, public data
    this.aladinOverlay = null;
    //
    // End declaration of AladinLite
    //

    // currently 'active' (hover/click) row
    //
    this.currentFootprint = null;

    // Start at this location.  Reset when re-rendering.
    this.defaultRA = null;
    this.defaultDec = null;

    // Field of View calculation
    // For FOV computation.
    this.DEC = null;
    this.RA0 = null;
    this.RA180 = null;
    this.fieldOfViewSetFlag = false;

    /**
     * Initialize with the Slick Grid instance.
     * @param _viewer{cadc.vot.Viewer}      The CADC VOTable Viewer instance.
     */
    function init(_viewer)
    {
      destroy();

      if (inputs.toggleSwitchSelector != null)
      {
        _self.$target.hide();
        var $toggleSwitchSelector = $(inputs.toggleSwitchSelector);

        if ($toggleSwitchSelector.data("open") != null)
        {
          $toggleSwitchSelector.html($toggleSwitchSelector.data("open"));
        }

        $toggleSwitchSelector.on("click", function (e)
        {
          e.preventDefault();

          _self.$target.toggle();

          if (_self.$target.is(":visible"))
          {
            inputs.toggleOpen($(this), _self.$target);
          }
          else
          {
            inputs.toggleClose($(this), _self.$target);
          }

          return false;
        });
      }

      _self.viewer = _viewer;
      _self.grid = _viewer.getGrid();
      _self.aladin = A.aladin(inputs.targetSelector, inputs.aladin_options);
      _self.aladinOverlay =
        A.graphicOverlay({color: inputs.colour, lineWidth: 3});
      _self.DEC = _defaults.coords.slice(0);
      _self.RA0 = _defaults.coords.slice(0);
      _self.RA180 = _defaults.coords.slice(0);
      _self.aladin.addOverlay(_self.aladinOverlay);
      _self.currentFootprint = A.graphicOverlay({
                                                  name: "current",
                                                  color: inputs.highlightColour,
                                                  lineWidth: 5
                                                });
      _self.aladin.addOverlay(_self.currentFootprint);

      if (inputs.fov != null)
      {
        _self.aladin.setFoV(inputs.fov);
      }

      if (_self.grid.getData().getLength)
      {
        if (inputs.renderedRowsOnly === true)
        {
          _self.handler.subscribe(_self.grid.onRenderComplete,
                                  handleRenderComplete);
        }
        else
        {
          _self.viewer.subscribe(cadc.vot.events.onRowAdded,
                                 handleAddFootprint);

          _self.viewer.subscribe(cadc.vot.events.onDataLoaded,
                                 function ()
                                 {
                                   _setFieldOfView();
                                 });

          _self.viewer.subscribe(cadc.vot.events.onFilterData,
                                 function (event, args)
                                 {
                                   reset();

                                   var v = args.application;
                                   var data = v.getGrid().getData();
                                   var currentRows = data.getRows();

                                   for (var cdi = 0, cdl = currentRows.length;<commit_msg>s1986: disable the View in sky button if there are more than 10,000 results.<commit_after>(function ($)
{
  if (typeof A === "undefined")
  {
    // Require AladinLite.
    throw new Error("AladinLite must be present.  (http://aladin.u-strasbg.fr/AladinLite/)");
  }

  // register namespace
  $.extend(true, window, {
    "cadc": {
      "vot": {
        "plugin": {
          "footprint": AladinLiteFootprintViewer
        }
      }
    }
  });


  /**
   * AladinLite footprint viewer.  This is incorporated as a Plugin to allow
   *
   * @constructor
   */
  function AladinLiteFootprintViewer(_inputs)
  {
    var PI_OVER_180 = Math.PI / 180.0;
    var DEG_PER_ARC_SEC = 1.0 / 3600.0;
    var POLYGON_SPLIT = "Polygon ICRS";
    var DEFAULT_FOV_DEGREES = 180;
    var ALADIN_ROW_LIMIT = 10000;

    var _self = this;
    var _defaults = {
      targetSelector: "#aladin-lite",
      toggleSwitchSelector: null,     // Always show by default.
      toggleClose: function ($toggleSelector)
      {
        $toggleSelector.data("close", $toggleSelector.html());
        $toggleSelector.html($toggleSelector.data("open"));
      },
      toggleOpen: function ($toggleSelector)
      {
        $toggleSelector.data("open", $toggleSelector.html());
        $toggleSelector.html($toggleSelector.data("close"));
      },
      aladin_options: {},  // Specific options for AladinLite.
      renderedRowsOnly: true,
      footprintFieldID: "footprint",
      raFieldID: "ra",
      decFieldID: "dec",
      fovFieldID: "fov",
      colour: "orange",
      navigateToSelected: true,
      highlightColour: "yellow",
      /**
       * Perform further calculations on the FOV before setting it.  Useful
       * for further reducing it (e.g. from square degrees to degrees).
       * @param {Number} fovValue
       * @return  {Number}
       */
      afterFOVCalculation: function (fovValue)
      {
        return fovValue;
      },
      onHover: true,
      onClick: false,
      coords: [1000, -1000, 0, 0]   // Remember to slice this!
    };

    this.grid = null;

    /**
     * {cadc.vot.Viewer}
     */
    this.viewer = null;
    this.handler = new Slick.EventHandler();

    var inputs = $.extend(true, {}, _defaults, _inputs);

    this.footprintFieldID = inputs.footprintFieldID;
    this.raFieldID = inputs.raFieldID;
    this.decFieldID = inputs.decFieldID;
    this.fovFieldID = inputs.fovFieldID;
    this.$target = $(inputs.targetSelector);

    //
    // Declare AladinLite
    //
    this.aladin = null;

    // footprint overlay, public data
    this.aladinOverlay = null;
    //
    // End declaration of AladinLite
    //

    // currently 'active' (hover/click) row
    //
    this.currentFootprint = null;

    // Start at this location.  Reset when re-rendering.
    this.defaultRA = null;
    this.defaultDec = null;

    // Field of View calculation
    // For FOV computation.
    this.DEC = null;
    this.RA0 = null;
    this.RA180 = null;
    this.fieldOfViewSetFlag = false;

    /**
     * Initialize with the Slick Grid instance.
     * @param _viewer{cadc.vot.Viewer}      The CADC VOTable Viewer instance.
     */
    function init(_viewer)
    {
      destroy();

      if (inputs.toggleSwitchSelector != null)
      {
        _self.$target.hide();
        var $toggleSwitchSelector = $(inputs.toggleSwitchSelector);

        if ($toggleSwitchSelector.data("open") != null)
        {
          $toggleSwitchSelector.html($toggleSwitchSelector.data("open"));
        }

        $toggleSwitchSelector.on("click", function (e)
        {
          e.preventDefault();

          _self.$target.toggle();

          if (_self.$target.is(":visible"))
          {
            inputs.toggleOpen($(this), _self.$target);
          }
          else
          {
            inputs.toggleClose($(this), _self.$target);
          }

          return false;
        });
      }

      _self.viewer = _viewer;
      _self.grid = _viewer.getGrid();
      _self.aladin = A.aladin(inputs.targetSelector, inputs.aladin_options);
      _self.aladinOverlay =
        A.graphicOverlay({color: inputs.colour, lineWidth: 3});
      _self.DEC = _defaults.coords.slice(0);
      _self.RA0 = _defaults.coords.slice(0);
      _self.RA180 = _defaults.coords.slice(0);
      _self.aladin.addOverlay(_self.aladinOverlay);
      _self.currentFootprint = A.graphicOverlay({
                                                  name: "current",
                                                  color: inputs.highlightColour,
                                                  lineWidth: 5
                                                });
      _self.aladin.addOverlay(_self.currentFootprint);
      _self.viewAladinButton = $("#slick-visualize");
      _self.viewAladinStatus = $("#slick-visualize-status");
      _self.rowCount = 0;

      if (inputs.fov != null)
      {
        _self.aladin.setFoV(inputs.fov);
      }

      if (_self.grid.getData().getLength)
      {
        if (inputs.renderedRowsOnly === true)
        {
          _self.handler.subscribe(_self.grid.onRenderComplete,
                                  handleRenderComplete);
        }
        else
        {
          _self.viewer.subscribe(cadc.vot.events.onRowAdded,
                                 function()
                                 {
                                   handleAddFootprint;

                                   if (_self.rowCount == 0)
                                   {
                                     // _self.viewAladinButton.removeClass("button-disabled");
                                     _self.viewAladinButton.removeClass("ui-disabled");
                                     _self.viewAladinStatus.addClass("wb-invisible");
                                   }
                                   _self.rowCount++;
                                   if (_self.rowCount > ALADIN_ROW_LIMIT &&
                                     !(_self.viewAladinButton.hasClass("ui-disabled")))
                                   {
                                     // _self.viewAladinButton.addClass("button-disabled");
                                     _self.viewAladinButton.addClass("ui-disabled");
                                     _self.viewAladinStatus.removeClass("wb-invisible");
                                   }
                                 });

          _self.viewer.subscribe(cadc.vot.events.onDataLoaded,
                                 function ()
                                 {
                                   _setFieldOfView();
                                 });

          _self.viewer.subscribe(cadc.vot.events.onFilterData,
                                 function (event, args)
                                 {
                                   reset();

                                   var v = args.application;
                                   var data = v.getGrid().getData();
                                   var currentRows = data.getRows();

                                   for (var cdi = 0, cdl = currentRows.length;
{'fraction_non_alphanumeric': 0.11226077485607593, 'fraction_numerical': 0.007624085887661428, 'mean_word_length': 1.5117233294255568, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 58, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5044973', 'n_tokens_mistral': 3758, 'n_tokens_neox': 3550, 'n_words': 668}