<commit_before>(function() {
    if($('.daily-message').length) {
        initDailyMessage();
    }

    var show_comments = function(e) {
        e.preventDefault();
        var $me = $(e.target);
        $me.hide();
        $me.next().show();
        $me.parents('tr').next().show();
    };

    var hide_comments = function(e) {
        e.preventDefault();
        var $me = $(e.target);
        $me.hide();
        $me.prev().show();
        $me.parents('tr').next().hide();
    };


    $('a.show').click(show_comments);
    $('a.hide').click(hide_comments);

    if ($('.queue-search').length) {
        initQueueSearch($('.queue-search'));
    }

    if($('#review-actions').length > 0) {
        initReviewActions();
    }

    if ($('#extra-review-actions').length) {
        initExtraReviewActions();
    }

    if ($('.all-backgrounds').length) {
        initBackgroundImagesForTheme();
    }

    if($('#monthly.highcharts-container').length) {
        initPerformanceStats();
    }

    if($('#scroll_sidebar').length && !$('body.mobile, body.tablet').length &&
       !z.capabilities.mobile) {
        initScrollingSidebar();
    }

    if($('#addon-queue').length) {
        initQueue();
    }

    // Show add-on ID when icon is clicked
    if ($("#addon[data-id], #persona[data-id]").length) {
      $("#addon .icon").click(function() {
        window.location.hash = "id=" + $("#addon, #persona").attr("data-id");
      });
    }
})();


function initReviewActions() {
    var groups = $('#id_canned_response').find('optgroup');

    function showForm(element, pageload) {
        var $element = $(element),
            value = $element.find('input').val(),
            $data_toggle = $('form.review-form').find('.data-toggle');

        pageload = pageload || false;
        $element.closest('.review-actions').addClass('on');
        $('.review-actions .action_nav ul li').removeClass('on-tab');
        $element.find('input').prop('checked', true);

        $element.addClass('on-tab');

        if (pageload) {
          $('#review-actions-form').show();
        } else {
          $('#review-actions-form').slideDown();
          $('#review-actions').find('.errorlist').remove();
        }

        // Hide everything, then show the ones containing the value we're
        // interested in. An extra | (the separator used) is added at the end
        // to make sure we don't match things with a common prefix (i.e. don't
        // show elements with data-value="reject_multiple_versions" when the
        // value is "reject".)
        $data_toggle.hide();
        $data_toggle.filter('[data-value*="' + value + '|"]').show();

        /* Fade out canned responses */
        var label = $element.text().trim();
        groups.css('color', '#AAA');
        groups.filter("[label='"+label+"']").css('color', '#444');
    }

    $('#review-actions .action_nav ul li:not(.disabled)').click(function() {
        showForm(this);
    });

    /* Canned Response stuff */
    $('.review-actions-canned select').change(function() {
        insertAtCursor($('#id_comments'), $(this).val());
    });

    var review_checked = $('#review-actions [name=action]:checked');
    if(review_checked.length > 0) {
      showForm(review_checked.closest('li'), true);
    }

    /* Install Triggers */

    $('.files .install').click(_pd(function(){
        var $this = $(this),
            installer = $this.is('[data-type="search-tools"]') ? z.installSearch : z.installAddon;
        installer($this.text(), $this.attr('href'), "");
    }));


    /* Who's currently on this page? */
    var addon_id = $('#addon').attr('data-id');
    var url = $('#addon').attr('data-url');
    function check_currently_viewing() {
        $.post(url, {'addon_id': addon_id}, function(d){
            var show = d.is_user != 1 && typeof d.current_name != "undefined",
                       $current = $('.currently_viewing_warning');

            $current.toggle(show);

            if(show) {
              var title;
              if (d.is_user == 2) {
                /* 2 is when the editor has reached the lock limit */
                title = d.current_name;
              } else {
                title = format(gettext('{name} was viewing this page first.'),
                                       {name: d.current_name});
              }
              $current_div = $current.filter('div');
              $current_div.find('strong').remove();
              $current_div.prepend($('<strong>', {'text': title}));
            }

            setTimeout(check_currently_viewing, d.interval_seconds * 1000);
        });
    }
    if (!(z.capabilities.localStorage && window.localStorage.dont_poll)) {
        check_currently_viewing();
    }

    /* Item History */
    $('#review-files tr.listing-header').click(function() {
        $(this).next('tr.listing-body').toggle();
    });

    var storage = z.Storage(),
        eh_setting = storage.get('reviewers_history'),
        eh_els = $('#review-files tr.listing-body'),
        eh_size = eh_els.length;
    if(!eh_setting) eh_setting = 3;

    toggleHistory();

    function toggleHistory() {
        eh_els.slice(eh_size - eh_setting, eh_setting).show();
        eh_els.slice(0, eh_size - eh_setting).hide();
    }

    $('.eh_open').click(_pd(function() {
        eh_setting = $(this).attr('data-num');
        storage.set('reviewers_history', eh_setting);
        toggleHistory();
        highlightHistory();
    }));

    function highlightHistory() {
        $('#history a').removeClass('on');
        $(format('#history a[data-num="{0}"]', eh_setting)).addClass('on');
    }
    highlightHistory();

    function check_receipt() {
        var $node = $('#receipt-check-result');
        if ($node) {
            $.getJSON($node.data('url'), function(data) {
                if (data.status) {
                    $node.text(gettext('Receipt checked by app.'));
                } else {
                    $node.text(gettext('Receipt was not checked by app.'));
                    setTimeout(check_receipt, 10000);
                }
            });
        }
    }
    check_receipt();
}

function callReviewersAPI(apiUrl, method, data, successCallback) {
    var apiToken = $('form.more-actions').data('api-token');
    if (data) {
        data = JSON.stringify(data);
    }
    $.ajax({
        url: apiUrl,
        data: data,
        type: method,<commit_msg>Remove useless XHR in reviewer tools left over from Marketplace<commit_after>(function() {
    if($('.daily-message').length) {
        initDailyMessage();
    }

    var show_comments = function(e) {
        e.preventDefault();
        var $me = $(e.target);
        $me.hide();
        $me.next().show();
        $me.parents('tr').next().show();
    };

    var hide_comments = function(e) {
        e.preventDefault();
        var $me = $(e.target);
        $me.hide();
        $me.prev().show();
        $me.parents('tr').next().hide();
    };


    $('a.show').click(show_comments);
    $('a.hide').click(hide_comments);

    if ($('.queue-search').length) {
        initQueueSearch($('.queue-search'));
    }

    if($('#review-actions').length > 0) {
        initReviewActions();
    }

    if ($('#extra-review-actions').length) {
        initExtraReviewActions();
    }

    if ($('.all-backgrounds').length) {
        initBackgroundImagesForTheme();
    }

    if($('#monthly.highcharts-container').length) {
        initPerformanceStats();
    }

    if($('#scroll_sidebar').length && !$('body.mobile, body.tablet').length &&
       !z.capabilities.mobile) {
        initScrollingSidebar();
    }

    if($('#addon-queue').length) {
        initQueue();
    }

    // Show add-on ID when icon is clicked
    if ($("#addon[data-id], #persona[data-id]").length) {
      $("#addon .icon").click(function() {
        window.location.hash = "id=" + $("#addon, #persona").attr("data-id");
      });
    }
})();


function initReviewActions() {
    var groups = $('#id_canned_response').find('optgroup');

    function showForm(element, pageload) {
        var $element = $(element),
            value = $element.find('input').val(),
            $data_toggle = $('form.review-form').find('.data-toggle');

        pageload = pageload || false;
        $element.closest('.review-actions').addClass('on');
        $('.review-actions .action_nav ul li').removeClass('on-tab');
        $element.find('input').prop('checked', true);

        $element.addClass('on-tab');

        if (pageload) {
          $('#review-actions-form').show();
        } else {
          $('#review-actions-form').slideDown();
          $('#review-actions').find('.errorlist').remove();
        }

        // Hide everything, then show the ones containing the value we're
        // interested in. An extra | (the separator used) is added at the end
        // to make sure we don't match things with a common prefix (i.e. don't
        // show elements with data-value="reject_multiple_versions" when the
        // value is "reject".)
        $data_toggle.hide();
        $data_toggle.filter('[data-value*="' + value + '|"]').show();

        /* Fade out canned responses */
        var label = $element.text().trim();
        groups.css('color', '#AAA');
        groups.filter("[label='"+label+"']").css('color', '#444');
    }

    $('#review-actions .action_nav ul li:not(.disabled)').click(function() {
        showForm(this);
    });

    /* Canned Response stuff */
    $('.review-actions-canned select').change(function() {
        insertAtCursor($('#id_comments'), $(this).val());
    });

    var review_checked = $('#review-actions [name=action]:checked');
    if(review_checked.length > 0) {
      showForm(review_checked.closest('li'), true);
    }

    /* Install Triggers */

    $('.files .install').click(_pd(function(){
        var $this = $(this),
            installer = $this.is('[data-type="search-tools"]') ? z.installSearch : z.installAddon;
        installer($this.text(), $this.attr('href'), "");
    }));


    /* Who's currently on this page? */
    var addon_id = $('#addon').attr('data-id');
    var url = $('#addon').attr('data-url');
    function check_currently_viewing() {
        $.post(url, {'addon_id': addon_id}, function(d){
            var show = d.is_user != 1 && typeof d.current_name != "undefined",
                       $current = $('.currently_viewing_warning');

            $current.toggle(show);

            if(show) {
              var title;
              if (d.is_user == 2) {
                /* 2 is when the editor has reached the lock limit */
                title = d.current_name;
              } else {
                title = format(gettext('{name} was viewing this page first.'),
                                       {name: d.current_name});
              }
              $current_div = $current.filter('div');
              $current_div.find('strong').remove();
              $current_div.prepend($('<strong>', {'text': title}));
            }

            setTimeout(check_currently_viewing, d.interval_seconds * 1000);
        });
    }
    if (!(z.capabilities.localStorage && window.localStorage.dont_poll)) {
        check_currently_viewing();
    }

    /* Item History */
    $('#review-files tr.listing-header').click(function() {
        $(this).next('tr.listing-body').toggle();
    });

    var storage = z.Storage(),
        eh_setting = storage.get('reviewers_history'),
        eh_els = $('#review-files tr.listing-body'),
        eh_size = eh_els.length;
    if(!eh_setting) eh_setting = 3;

    toggleHistory();

    function toggleHistory() {
        eh_els.slice(eh_size - eh_setting, eh_setting).show();
        eh_els.slice(0, eh_size - eh_setting).hide();
    }

    $('.eh_open').click(_pd(function() {
        eh_setting = $(this).attr('data-num');
        storage.set('reviewers_history', eh_setting);
        toggleHistory();
        highlightHistory();
    }));

    function highlightHistory() {
        $('#history a').removeClass('on');
        $(format('#history a[data-num="{0}"]', eh_setting)).addClass('on');
    }
    highlightHistory();
}

function callReviewersAPI(apiUrl, method, data, successCallback) {
    var apiToken = $('form.more-actions').data('api-token');
    if (data) {
        data = JSON.stringify(data);
    }
    $.ajax({
        url: apiUrl,
        data: data,
        type: method,
{'fraction_non_alphanumeric': 0.18658280922431866, 'fraction_numerical': 0.0028221254636348974, 'mean_word_length': 2.257090336134454, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5807275', 'n_tokens_mistral': 3778, 'n_tokens_neox': 3613, 'n_words': 663}