<commit_before>function get_id(id) { return id.split('_')[2]; }

function getNodeID($node) {
    /* A helper function that returns the tree_id and level for $node */
    var nodeIDList = $node.attr('id').split('_');

    return {
        'treeID': parseInt(nodeIDList[1]),
        'level': parseInt(nodeIDList[2])
    }
}


function move_node(move_data) {
    var $form = $('#ostinato_page_move_form');

    $form.find('input[name="node"]').val(move_data.node);
    $form.find('input[name="target"]').val(move_data['target']);
    $form.find('input[name="position"]').val(move_data.position);

    $form.submit();
}


django.jQuery(document).ready(function() {
    var page_id, selected_template;

    /*  Detail View Scripts */

    // When changing the template, we should 'refresh' the Page
    django.jQuery('#id_template').focus(function() {
        selected_template = $(this).val();
    }).change(function() {
        var refresh = confirm('Changing the template will save and reload the page. Are you sure you want to do this now?');
        if (refresh) {
            django.jQuery('input[name="_continue"]').click();
        } else {
            $(this).val(selected_template);
        }
    });


    /* List View Scripts */

    // Expand/Collapse Rows

    $('#result_list td:eq(1)').css('width', '20px');

    function toggleRow($node, action) {
        var $el = $node.parent().parent();
        if (action == 'collapse') {
            $el.hide();
        } else if (action == 'expand') {
            $el.show();
        }
    }


    $('a.toggle_children').click(function() {
        var $parentNode = $(this).parent();
        var parentNodeID = getNodeID($parentNode);
        var is_open = $parentNode.hasClass('open');

        // reset node
        $parentNode.removeClass('open');
        $parentNode.removeClass('closed');

        // Find all the rows of the same tree_id, with a higher level 
        $('span.tree_node[id*="tid_' + parentNodeID.treeID + '_"]').each(function(i) {
            var $node = $(this);
            var nodeID = getNodeID($node);

            // Expand/Collapse that row
            if (nodeID.level > parentNodeID.level) {
                if (is_open) {
                    toggleRow($node, 'collapse');

                    if ($node.hasClass('open')) {
                        $node.removeClass('open');
                        $node.addClass('closed');<commit_msg>Bugfix, the icon didn't update for nested child nodes when the parent is collapsed<commit_after>function get_id(id) { return id.split('_')[2]; }

function getNodeID($node) {
    /* A helper function that returns the tree_id and level for $node */
    var nodeIDList = $node.attr('id').split('_');

    return {
        'treeID': parseInt(nodeIDList[1]),
        'level': parseInt(nodeIDList[2])
    }
}


function move_node(move_data) {
    var $form = $('#ostinato_page_move_form');

    $form.find('input[name="node"]').val(move_data.node);
    $form.find('input[name="target"]').val(move_data['target']);
    $form.find('input[name="position"]').val(move_data.position);

    $form.submit();
}


django.jQuery(document).ready(function() {
    var page_id, selected_template;

    /*  Detail View Scripts */

    // When changing the template, we should 'refresh' the Page
    django.jQuery('#id_template').focus(function() {
        selected_template = $(this).val();
    }).change(function() {
        var refresh = confirm('Changing the template will save and reload the page. Are you sure you want to do this now?');
        if (refresh) {
            django.jQuery('input[name="_continue"]').click();
        } else {
            $(this).val(selected_template);
        }
    });


    /* List View Scripts */

    // Expand/Collapse Rows

    $('#result_list td:eq(1)').css('width', '20px');

    function toggleRow($node, action) {
        var $el = $node.parent().parent();
        if (action == 'collapse') {
            $el.hide();
        } else if (action == 'expand') {
            $el.show();
        }
    }


    $('a.toggle_children').click(function() {
        var $parentNode = $(this).parent();
        var parentNodeID = getNodeID($parentNode);
        var is_open = $parentNode.hasClass('open');

        // reset node
        $parentNode.removeClass('open');
        $parentNode.removeClass('closed');

        // Find all the rows of the same tree_id, with a higher level 
        $('span.tree_node[id*="tid_' + parentNodeID.treeID + '_"]').each(function(i) {
            var $node = $(this);
            var nodeID = getNodeID($node);

            // Expand/Collapse that row
            if (nodeID.level > parentNodeID.level) {
                if (is_open) {
                    toggleRow($node, 'collapse');

                    if ($node.hasClass('open')) {
                        $node.removeClass('open');
                        $node.addClass('closed');
                        $node.find('.toggle_children')
                            .html('<img src="' + STATIC_URL +
                                  '/pages/img/tree_closed.png" alt="expand" />');
{'fraction_non_alphanumeric': 0.16333725029377202, 'fraction_numerical': 0.0023501762632197414, 'mean_word_length': 2.2758178319435536, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6071925', 'n_tokens_mistral': 1518, 'n_tokens_neox': 1480, 'n_words': 320}