<commit_before>/**
 * jQuery behaviors for tenon reports.
 */
(function ($) {
  Drupal.behaviors.tenon_reports = {
    attach: function (context, settings) {
      // Setup.
      var menuLinkSel = 'a[data-tenon="page_report"]';
      if ($(menuLinkSel + '.tenon-notifications-processed').length) {
        return;
      }
      $(menuLinkSel).attr('href', '#').addClass('tenon-notifications-processed');

      // Only continue if we have the hopscotch library defined.
      if (typeof hopscotch == 'undefined') {
        return;
      }
      // If we have a count of issues reported for the current page, show it.
      if (settings.tenon.issuesCount !== false) {
        // Format the message based on its structure.
        var msg = '';
        var issues_class = '';
        if (settings.tenon.issuesCount === 0) {
          msg = Drupal.t('No issue');
          issues_class = 'no-issue';
        }
        else {
          msg = Drupal.formatPlural(settings.tenon.issuesCount, '1 issue', '@count issues');
          issues_class = 'has-issue';
        }
        // Display the count of issues from the previous test.
        $(menuLinkSel).append($('<span id="tenon-report-summary-count" class="' + issues_class + '">' + msg + '</span>'));
      }

      // Adds our tour overlay behavior with desired effects.
      $('a[data-tenon="page_report"]').click(function (e) {
        // Close the drawer when we generate the report.
        Drupal.cp_toolbar.drawer_close();

        $('html, body').animate({scrollTop: 0}, '500', 'swing', function () {
          // Sets up the tour object with appropriate content.
          var tour = {
            showPrevButton: true,
            scrollTopMargin: 100,
            id: "tenon-notifications",
            steps: [Drupal.tenon.buildItem(settings.tenon.moduleBasePath)]
          };
          // Adjust the rendering to match our needs.
          var hopscotch_selector = '.hopscotch-bubble';
          $(hopscotch_selector).addClass('animated');
          hopscotch.startTour(tour);

          // Trigger the page report for the current URL.
          $.get('/tenon/ajax/page?url=' + encodeURI(settings.tenon.url)).done(function(data) {
            $('.tenon-notifications .hopscotch-content .description').html(data.content);
            $('.tenon-notifications .hopscotch-content .tenon-notifications-readmore').html(data.link);
          });

          // Removes animation for each step and let us to target just this tour in CSS rules.
          $(hopscotch_selector).removeClass('animated').addClass('tenon-notifications');
        });
      });
    }
  };

  Drupal.tenon = Drupal.tenon || {
    /**
     * Format Tour content.
     *
     * @returns {{title: string, content: string, target: Element, placement: string, yOffset: number, xOffset: number}}
     */
    buildItem: function (module_path) {
      // Prepare the output to display inside the tour's content region.
      // Builds a default message to show the user that he has to wait.
      var output = "<div class='feed_item'>";
      output += '<span class="description"><p>' + Drupal.t("Report generation in progress.") + '<br />';
      output += '<img src="' + module_path + '/throbber.gif" /></p></span>';
      output += '<div class="tenon-notifications-readmore"></div>';
      output += '</div>';

      // Returns the item to be added to the tour's (array) `items` property.
      return {
        title: Drupal.t('Your page accessibility report'),
        content: output,
        target: document.querySelector('.tenon-link'),
        placement: "bottom",
        yOffset: -3,
        xOffset: -10,
      };
    }
  };
})(jQuery);
<commit_msg>Remove the double execution of the API calls.<commit_after>/**
 * jQuery behaviors for tenon reports.
 */
(function ($) {
  Drupal.behaviors.tenon_reports = {
    attach: function (context, settings) {
      // Setup.
      var menuLinkSel = 'a[data-tenon="page_report"]';
      if ($(menuLinkSel + '.tenon-notifications-processed').length) {
        return;
      }
      $(menuLinkSel).attr('href', '#').addClass('tenon-notifications-processed');

      // Only continue if we have the hopscotch library defined.
      if (typeof hopscotch == 'undefined') {
        return;
      }
      // If we have a count of issues reported for the current page, show it.
      if (settings.tenon.issuesCount !== false) {
        // Format the message based on its structure.
        var msg = '';
        var issues_class = '';
        if (settings.tenon.issuesCount === 0) {
          msg = Drupal.t('No issue');
          issues_class = 'no-issue';
        }
        else {
          msg = Drupal.formatPlural(settings.tenon.issuesCount, '1 issue', '@count issues');
          issues_class = 'has-issue';
        }
        // Display the count of issues from the previous test.
        $(menuLinkSel).append($('<span id="tenon-report-summary-count" class="' + issues_class + '">' + msg + '</span>'));
      }

      // Adds our tour overlay behavior with desired effects.
      $('a[data-tenon="page_report"]').click(function (e) {
        // Close the drawer when we generate the report.
        Drupal.cp_toolbar.drawer_close();

        // Sets up the tour object with appropriate content.
        var tour = {
          showPrevButton: true,
          scrollTopMargin: 100,
          id: "tenon-notifications",
          steps: [Drupal.tenon.buildItem(settings.tenon.moduleBasePath)]
        };
        // Adjust the rendering to match our needs.
        var hopscotch_selector = '.hopscotch-bubble';
        $(hopscotch_selector).addClass('animated');
        hopscotch.startTour(tour);

        // Trigger the page report for the current URL.
        $.get('/tenon/ajax/page?url=' + encodeURI(settings.tenon.url)).done(function(data) {
          $('.tenon-notifications .hopscotch-content .description').html(data.content);
          $('.tenon-notifications .hopscotch-content .tenon-notifications-readmore').html(data.link);
        });

        // Removes animation for each step and let us to target just this tour in CSS rules.
        $(hopscotch_selector).removeClass('animated').addClass('tenon-notifications');
      });
    }
  };

  Drupal.tenon = Drupal.tenon || {
    /**
     * Format Tour content.
     *
     * @returns {{title: string, content: string, target: Element, placement: string, yOffset: number, xOffset: number}}
     */
    buildItem: function (module_path) {
      // Prepare the output to display inside the tour's content region.
      // Builds a default message to show the user that he has to wait.
      var output = "<div class='feed_item'>";
      output += '<span class="description"><p>' + Drupal.t("Report generation in progress.") + '<br />';
      output += '<img src="' + module_path + '/throbber.gif" /></p></span>';
      output += '<div class="tenon-notifications-readmore"></div>';
      output += '</div>';

      // Returns the item to be added to the tour's (array) `items` property.
      return {
        title: Drupal.t('Your page accessibility report'),
        content: output,
        target: document.querySelector('.tenon-link'),
        placement: "bottom",
        yOffset: -3,
        xOffset: -10,
      };
    }
  };
})(jQuery);

{'fraction_non_alphanumeric': 0.14444749862561848, 'fraction_numerical': 0.002748763056624519, 'mean_word_length': 2.386226151698464, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '3341040', 'n_tokens_mistral': 2103, 'n_tokens_neox': 2058, 'n_words': 561}