<commit_before>// Set of initialization actions run on page load to make UI features live

$(function() {

    // Move any rhs elements (typically from type-specific templates) to rhs column
    $(".rhs").appendTo("#rhs");

    // Enable datatable processing
    $('.datatable').dataTable( {
      "language": {
        "search": "Filter entries:"
      },
      "lengthMenu": [ [20, 50, 100, -1], [20, 50, 100, "All"] ]
    } );
    
    // Query forms run a target query and load the resulting HTML into a data-result element
    var processQueryForms = function() {
        $(".query-form").each(function() {
            var target = $(this).attr('data-target');
            var queryField = $(this).attr('data-query');
            var resultField = $(this).attr('data-result');
            $(this).submit( function(){
                var url = target + $(queryField).val();
                $(resultField).load(url);
                return false;
            });
        });
    };

    processQueryForms();

    // Activate the hidable metadata tab area
    $('#pillstack li a').click(function (e) {
        e.preventDefault();
        $('#description').removeClass('col-md-10').addClass('col-md-5');
        $('#metadata-pane').removeClass('hide');
        $('#close-pillstack').removeClass('hide');
        $(this).tab('show');
    });

    $('#close-pillstack').click(function (e) {
        e.preventDefault();
        $('#description').removeClass('col-md-5').addClass('col-md-10');
        $('#metadata-pane').addClass('hide');
        $('#close-pillstack').addClass('hide');
        $('#pillstack li a[href="#collapse-tab"]').tab('show');
    });

    // Set up ajax loading tabs
    $('.action-tab').bind('show.bs.tab', function(e) {
        var pattern=/#.+/gi
        var contentID = e.target.toString().match(pattern)[0];
        var tab = $(contentID);
        var action = tab.attr('data-action');
        var uri = tab.attr('data-uri');
        var uiroot = tab.attr('data-uiroot');
        if (action) {
          //var url = '$uiroot/' + action +'?uri=$lib.pathEncode($uri)&requestor=$requestor';
          var url = uiroot + '/' + action + '?uri=' + uri;
          var args = tab.attr('data-args');
          if (args) {
             url = url + "&" + args;
          }
          tab.find(".tab-pane-inner").load(url, function(){
             $('.action-tab').tab(); //reinitialize tabs
             $('.datatable').dataTable();
             processQueryForms();
           });
        };
     });


    // Anything marked as popinfo will have a popover (data-trigger, data-placement, data-content)
    // enable popups
    $(".popinfo").popover();

    // General ajax forms which reload the page when actioned. Errors are displayed in elts of class "ajax-error".
    $(".ajax-form").each(function(){
        var form = $(this);
        var returnURL = form.attr('data-return');
        form. ajaxForm({
            success:
                function(data, status, xhr){
                    if (returnURL) {
                        window.location.href = returnURL;
                    } else {
                      location.reload();
                    }
                },

            error:
              function(xhr, status, error){
                 $(".ajax-error").html("<div class='alert alert-warning'> <button type='button' class='close' data-dismiss='alert'>&times;</button>Action failed: " + error + " - " + xhr.responseText + "</div>");
              }
          });
    });

    // Simple ajax inline forms that display the returned message
    $(".ajax-inline-form").ajaxForm({
      success:
          function(data, status, xhr){
             $("#form-result").html(data);
          },

      error:
        function(xhr, status, error){
           $("#form-result").html("<div class='alert'> <button type='button' class='close' data-dismiss='alert'>&times;</button>Action failed: " + error + " - " + xhr.responseText + "</div>");
        }
    });

    // Hierarchical views
    var hlistHandler = function(event) {
        var button = $(event.target).closest("a");
        var parent = button.closest("div");
        var state = button.attr("data-state");
        if (state === "new") {
            $.get(button.attr("data-target"), function(data){
                parent.after("<div class='hlist-child-box'>" + data + "</div>");    
                parent.next("div").find("a.hlist-button").click(hlistHandler);
            });
            setHlistState(button, "open");
        } else if (state === "open") {
            parent.next("div.hlist-child-box").hide();
            setHlistState(button, "closed");
        } else if (state === "closed") {
            parent.next("div.hlist-child-box").show();
            setHlistState(button, "open");
        }
    };

    var setHlistState = function(button, state) {
        button.attr("data-state", state);
        if (state === "open") {
            button.find("span").removeClass("glyphicon-plus-sign").addClass("glyphicon-minus-sign");            
        } else if (state === "closed") {
            button.find("span").removeClass("glyphicon-minus-sign").addClass("glyphicon-plus-sign");
        }
    };
    
    $("a.hlist-button").click( hlistHandler );

    // ------------
    // Edit support
    // ------------

    // Set up editable fields
    $.fn.editable.defaults.mode = 'inline';

    var editTarget = function(event) {
        return $(event.target).closest("button").attr("data-target");
    }

    var editRemoveAction = function(e){
        var rowid = editTarget(e);
        $(rowid).remove();
    };<commit_msg>Stop tree browse scrolling to top<commit_after>// Set of initialization actions run on page load to make UI features live

$(function() {

    // Move any rhs elements (typically from type-specific templates) to rhs column
    $(".rhs").appendTo("#rhs");

    // Enable datatable processing
    $('.datatable').dataTable( {
      "language": {
        "search": "Filter entries:"
      },
      "lengthMenu": [ [20, 50, 100, -1], [20, 50, 100, "All"] ]
    } );
    
    // Query forms run a target query and load the resulting HTML into a data-result element
    var processQueryForms = function() {
        $(".query-form").each(function() {
            var target = $(this).attr('data-target');
            var queryField = $(this).attr('data-query');
            var resultField = $(this).attr('data-result');
            $(this).submit( function(){
                var url = target + $(queryField).val();
                $(resultField).load(url);
                return false;
            });
        });
    };

    processQueryForms();

    // Activate the hidable metadata tab area
    $('#pillstack li a').click(function (e) {
        e.preventDefault();
        $('#description').removeClass('col-md-10').addClass('col-md-5');
        $('#metadata-pane').removeClass('hide');
        $('#close-pillstack').removeClass('hide');
        $(this).tab('show');
    });

    $('#close-pillstack').click(function (e) {
        e.preventDefault();
        $('#description').removeClass('col-md-5').addClass('col-md-10');
        $('#metadata-pane').addClass('hide');
        $('#close-pillstack').addClass('hide');
        $('#pillstack li a[href="#collapse-tab"]').tab('show');
    });

    // Set up ajax loading tabs
    $('.action-tab').bind('show.bs.tab', function(e) {
        var pattern=/#.+/gi
        var contentID = e.target.toString().match(pattern)[0];
        var tab = $(contentID);
        var action = tab.attr('data-action');
        var uri = tab.attr('data-uri');
        var uiroot = tab.attr('data-uiroot');
        if (action) {
          //var url = '$uiroot/' + action +'?uri=$lib.pathEncode($uri)&requestor=$requestor';
          var url = uiroot + '/' + action + '?uri=' + uri;
          var args = tab.attr('data-args');
          if (args) {
             url = url + "&" + args;
          }
          tab.find(".tab-pane-inner").load(url, function(){
             $('.action-tab').tab(); //reinitialize tabs
             $('.datatable').dataTable();
             processQueryForms();
           });
        };
     });


    // Anything marked as popinfo will have a popover (data-trigger, data-placement, data-content)
    // enable popups
    $(".popinfo").popover();

    // General ajax forms which reload the page when actioned. Errors are displayed in elts of class "ajax-error".
    $(".ajax-form").each(function(){
        var form = $(this);
        var returnURL = form.attr('data-return');
        form. ajaxForm({
            success:
                function(data, status, xhr){
                    if (returnURL) {
                        window.location.href = returnURL;
                    } else {
                      location.reload();
                    }
                },

            error:
              function(xhr, status, error){
                 $(".ajax-error").html("<div class='alert alert-warning'> <button type='button' class='close' data-dismiss='alert'>&times;</button>Action failed: " + error + " - " + xhr.responseText + "</div>");
              }
          });
    });

    // Simple ajax inline forms that display the returned message
    $(".ajax-inline-form").ajaxForm({
      success:
          function(data, status, xhr){
             $("#form-result").html(data);
          },

      error:
        function(xhr, status, error){
           $("#form-result").html("<div class='alert'> <button type='button' class='close' data-dismiss='alert'>&times;</button>Action failed: " + error + " - " + xhr.responseText + "</div>");
        }
    });

    // Hierarchical views
    var hlistHandler = function(event) {
        var button = $(event.target).closest("a");
        var parent = button.closest("div");
        var state = button.attr("data-state");
        if (state === "new") {
            $.get(button.attr("data-target"), function(data){
                parent.after("<div class='hlist-child-box'>" + data + "</div>");    
                parent.next("div").find("a.hlist-button").click(hlistHandler);
            });
            setHlistState(button, "open");
        } else if (state === "open") {
            parent.next("div.hlist-child-box").hide();
            setHlistState(button, "closed");
        } else if (state === "closed") {
            parent.next("div.hlist-child-box").show();
            setHlistState(button, "open");
        }
        return false;
    };

    var setHlistState = function(button, state) {
        button.attr("data-state", state);
        if (state === "open") {
            button.find("span").removeClass("glyphicon-plus-sign").addClass("glyphicon-minus-sign");            
        } else if (state === "closed") {
            button.find("span").removeClass("glyphicon-minus-sign").addClass("glyphicon-plus-sign");
        }
    };
    
    $("a.hlist-button").click( hlistHandler );

    // ------------
    // Edit support
    // ------------

    // Set up editable fields
    $.fn.editable.defaults.mode = 'inline';

    var editTarget = function(event) {
        return $(event.target).closest("button").attr("data-target");
    }

    var editRemoveAction = function(e){
        var rowid = editTarget(e);
        $(rowid).remove();
    };
{'fraction_non_alphanumeric': 0.18441535467893155, 'fraction_numerical': 0.0038917388996992748, 'mean_word_length': 1.994438559322034, 'pattern_counts': {'":': 6, '<': 23, '<?xml version=': 0, '>': 23, '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': '3370609', 'n_tokens_mistral': 3225, 'n_tokens_neox': 3148, 'n_words': 665}