<commit_before>{% extends 'reports/async/tabular.html' %}
{% load hq_shared_tags %}
{% load report_tags %}
{% load i18n %}

{% block js-inline %} {{ block.super }}
    <script type="text/javascript">
    function updateFormCounts() {
        var selectedCount = $('#form-management').find('input.xform-checkbox:checked').length;
        $(".selectedCount").text(selectedCount);
        enable_disable_button(selectedCount);
    }

    function enable_disable_button(count){
        if (count == 0) {
            $("#submitForms").attr('disabled', true);
        }
        else {
            $("#submitForms").attr('disabled', false);
        }
    }

    (function () {
        function applyCheckboxBindings() {
            var $XFormManagement = $('#form-management');

            $XFormManagement.find('a.select-visible').click(function () {
                $XFormManagement.find('input[name="select_all"]').attr('checked', false);
                $XFormManagement.find('input.xform-checkbox').attr('checked', true).change();
                return false;
            });

            $XFormManagement.find('a.select-none').click(function() {selectNone(); return false;});
            $XFormManagement.find('.dataTables_paginate a').mouseup(selectNone);
            $XFormManagement.find('.dataTables_length select').change(selectNone);

            function selectNone() {
                $XFormManagement.find('input.xform-checkbox:checked').attr('checked', false).change();
                $XFormManagement.find('input[name="select_all"]').attr('checked', false);
            }
            $XFormManagement.find('input.xform-checkbox').on('change', function(){
                // updates text like '3 of 5 selected'
                updateFormCounts();
            })

            $XFormManagement.find('input.xform-checkbox').on('click', function(){
                $('#form-management').find('input[name="select_all"]').attr('checked', false);
            })

            $XFormManagement.find('input[name="select_all"]').on('click', function(){
                if (this.checked) {
                    $XFormManagement.find('input.xform-checkbox').attr('checked', true).change();
                    enable_disable_button(1);
                    $(".selectedCount").text(79);
                }
                else {
                    $(".selectedCount").text(0);
                    $XFormManagement.find('a.select-none').click();
                    enable_disable_button(0);
                }
            })
        }

        var keepTrying = setInterval(function () {
            if (window.reportTables !== undefined) {
                clearInterval(keepTrying);
                applyCheckboxBindings();<commit_msg>refactor<commit_after>{% extends 'reports/async/tabular.html' %}
{% load hq_shared_tags %}
{% load report_tags %}
{% load i18n %}

{% block js-inline %} {{ block.super }}
    <script type="text/javascript">
    function updateFormCounts() {
        var selectedCount = $('#form-management').find('input.xform-checkbox:checked').length;
        $(".selectedCount").text(selectedCount);
        enable_disable_button(selectedCount);
    }

    function enable_disable_button(count){
        if (count == 0) {
            $("#submitForms").attr('disabled', true);
        }
        else {
            $("#submitForms").attr('disabled', false);
        }
    }

    (function () {
        function applyCheckboxBindings() {
            var $XFormManagement = $('#form-management');
            var $allFormsButton = $XFormManagement.find('input[name="select_all"]');
            var $checkboxes = $XFormManagement.find('input.xform-checkbox');

            // bindings for 'all' button
            $XFormManagement.find('a.select-visible').click(function () {
                $allFormsButton.attr('checked', false);
                $checkboxes.attr('checked', true).change();
                return false;
            });

            // bindings for 'none' button
            $XFormManagement.find('a.select-none').click(function(){
                selectNone(); return false;
            });
            function selectNone() {
                $XFormManagement.find('input.xform-checkbox:checked').attr('checked', false).change();
                $allFormsButton.attr('checked', false);
            }

            // bindings for form checkboxes
            $checkboxes.on('change', function(){
                // updates text like '3 of 5 selected'
                updateFormCounts();
            })
            $checkboxes.on('click', function(){
                $allFormsButton.attr('checked', false);
            })

            // bindings for 'Select all' checkboxe
            $allFormsButton.on('click', function(){
                if (this.checked) {
                    $checkboxes.attr('checked', true).change();
                    enable_disable_button(1);
                    $(".selectedCount").text({{ total_xForms }});
                }
                else {
                    $(".selectedCount").text(0);
                    $XFormManagement.find('a.select-none').click();
                    enable_disable_button(0);
                }
            })

            $XFormManagement.find('.dataTables_paginate a').mouseup(selectNone);
            $XFormManagement.find('.dataTables_length select').change(selectNone);
        }

        var keepTrying = setInterval(function () {
            if (window.reportTables !== undefined) {
                clearInterval(keepTrying);
                applyCheckboxBindings();
{'fraction_non_alphanumeric': 0.15112309074573224, 'fraction_numerical': 0.003234501347708895, 'mean_word_length': 1.9828510182207932, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '379913', 'n_tokens_mistral': 1465, 'n_tokens_neox': 1382, 'n_words': 207}