<commit_before>$(document).ready( function() {
    var metadata = $('#view-metadata');
    var form = $('#obj-form form')[0];
    var domainsUrl = metadata.attr( 'data-domainsUrl' );

    // For inputs with id = 'id_fqdn' | 'id_target' | server, make smart names.
    $( document ).on( 'click', '#id_fqdn, #id_target, #id_server', function() {
        if ( domainsUrl ) {
            make_smart_name_get_domains(
                $('#id_fqdn, #id_target, #id_server'), true, domainsUrl );
        }
    });

    // displays the loading gif on ajax event
    $(document).ajaxStart( function() {
        $('#busy-spinner').stop().fadeIn( 160 );
    }).ajaxStop( function() {
        $('#busy-spinner').stop().fadeOut( 160 );
    });

    // sidebar animation logic
    $('.nav-item.parent').click( function( e ) {
        e.preventDefault();
        var parentsChild = ( '#' + this.id + '-children' );
        $('#dns-sidebar-children, #dhcp-sidebar-children, #core-sidebar-children')
            .not(parentsChild).slideUp( 'slow' );
        $(parentsChild).slideToggle( 'slow' );
    });

    $( document ).on( 'click', '.exit-message', function( e ) {
        slideUp_and_remove( $(this).parent() );
    });

    $( document ).on( 'focus', '#id_attribute', function() {
        $('#id_attribute').autocomplete({
            minLength: 1,
            source: function( request, response ) {
                $.ajax({
                    global: false,
                    url: '/eav/search',
                    dataType: 'json',
                    data: {
                        term: request.term,
                        attribute_type: $('#id_attribute_type').val()
                    },
                    success: response
                });
            },
            delay: 400,
            select: function( event, ui ) {
                attributeName = ui.item.label;
            }
        });
    });

    $( document ).on( 'change', '#id_attribute_type', function() {
        $('#id_attribute').val( '' );
    });

    // button behavior logic, see css
    function buttonLogic() {
        var selectors = '.js-get-form, .js-create-object, .update, ' +
            '.cancel, .system_form';
        $(selectors).addClass( 'hover' );
        if ( $(this).hasClass( 'selected' ) ) {
            $(this).removeClass( 'selected' );
        } else {
            $(selectors).removeClass( 'selected' );
            $(this).removeClass( 'hover' ).addClass( 'selected' );
        }
    }
    $( document ).on('click',
        '.js-get-form, .js-create-object, .update, .cancel, .system_form',
        buttonLogic );


    $( document ).on( 'click', '.js-get-form', function( e ) {
        // Show update form on clicking update icon.
        e.preventDefault();
        get_update_form( this );
    });

    function btn_not_toggle_close( btn ) {
        return ($(btn).hasClass( 'selected' ) ||
            $(btn).parents().attr( 'class' ) == 'actions_column');
    };

    function get_update_form( btn ) {
        var kwargs;
        var formTitle;
        var buttonLabel;
        var getData;
        var buttonAttrs;
        var initData;
        slideUp( $('#obj-form') );
        form.action = btn.href;
        if ( btn_not_toggle_close( btn ) ) {
            buttonAttrs = 'btn c js-submit';
            kwargs = JSON.parse( $(btn).attr( 'data-kwargs' ) );
            if ( kwargs.pk ) {
                getData = {
                    'obj_type': kwargs.obj_type,
                    'pk': kwargs.pk
                };
            } else {
                if ( $(btn).attr( 'data-init' ) ) {
                    initData = $(btn).attr( 'data-init' );
                }

                getData = {
                    'data': initData,
                    'obj_type': kwargs.obj_type,
                    'related_pk': metadata.attr( 'data-objPk' ),
                    'related_type': metadata.attr( 'data-objType' ),
                };
            }

            $.ajax({
                type: 'GET',
                url: kwargs.get_url,
                data: getData,
                global: false,
                dataType: 'json',
                success: function( data ) {
                    metaData = $('<div id="form-metadata">')
                        .attr( 'objType', kwargs.obj_type )
                        .attr( 'style', 'display:none' );
                    setTimeout( function() {
                        $('#hidden-inner-form')
                            .empty()
                            .append( data.form )
                            .append( metaData );
                        initForms();
                    }, 150 );
                    $('#form-title').html( data.form_title );
                    $('.form-btns .btn').not('.cancel').text( data.submit_btn_label );
                    $('.form-btns .btn').not('.cancel').attr( 'class', buttonAttrs );
                    $('#obj-form').slideDown();
                }
            });<commit_msg>Scroll to top of page when opening an object form<commit_after>$(document).ready( function() {
    var metadata = $('#view-metadata');
    var form = $('#obj-form form')[0];
    var domainsUrl = metadata.attr( 'data-domainsUrl' );

    // For inputs with id = 'id_fqdn' | 'id_target' | server, make smart names.
    $( document ).on( 'click', '#id_fqdn, #id_target, #id_server', function() {
        if ( domainsUrl ) {
            make_smart_name_get_domains(
                $('#id_fqdn, #id_target, #id_server'), true, domainsUrl );
        }
    });

    // displays the loading gif on ajax event
    $(document).ajaxStart( function() {
        $('#busy-spinner').stop().fadeIn( 160 );
    }).ajaxStop( function() {
        $('#busy-spinner').stop().fadeOut( 160 );
    });

    // sidebar animation logic
    $('.nav-item.parent').click( function( e ) {
        e.preventDefault();
        var parentsChild = ( '#' + this.id + '-children' );
        $('#dns-sidebar-children, #dhcp-sidebar-children, #core-sidebar-children')
            .not(parentsChild).slideUp( 'slow' );
        $(parentsChild).slideToggle( 'slow' );
    });

    $( document ).on( 'click', '.exit-message', function( e ) {
        slideUp_and_remove( $(this).parent() );
    });

    $( document ).on( 'focus', '#id_attribute', function() {
        $('#id_attribute').autocomplete({
            minLength: 1,
            source: function( request, response ) {
                $.ajax({
                    global: false,
                    url: '/eav/search',
                    dataType: 'json',
                    data: {
                        term: request.term,
                        attribute_type: $('#id_attribute_type').val()
                    },
                    success: response
                });
            },
            delay: 400,
            select: function( event, ui ) {
                attributeName = ui.item.label;
            }
        });
    });

    $( document ).on( 'change', '#id_attribute_type', function() {
        $('#id_attribute').val( '' );
    });

    // button behavior logic, see css
    function buttonLogic() {
        var selectors = '.js-get-form, .js-create-object, .update, ' +
            '.cancel, .system_form';
        $(selectors).addClass( 'hover' );
        if ( $(this).hasClass( 'selected' ) ) {
            $(this).removeClass( 'selected' );
        } else {
            $(selectors).removeClass( 'selected' );
            $(this).removeClass( 'hover' ).addClass( 'selected' );
        }
    }
    $( document ).on('click',
        '.js-get-form, .js-create-object, .update, .cancel, .system_form',
        buttonLogic );


    $( document ).on( 'click', '.js-get-form', function( e ) {
        // Show update form on clicking update icon.
        e.preventDefault();
        get_update_form( this );
    });

    function btn_not_toggle_close( btn ) {
        return ($(btn).hasClass( 'selected' ) ||
            $(btn).parents().attr( 'class' ) == 'actions_column');
    };

    function get_update_form( btn ) {
        var kwargs;
        var formTitle;
        var buttonLabel;
        var getData;
        var buttonAttrs;
        var initData;
        slideUp( $('#obj-form') );
        form.action = btn.href;
        if ( btn_not_toggle_close( btn ) ) {
            buttonAttrs = 'btn c js-submit';
            kwargs = JSON.parse( $(btn).attr( 'data-kwargs' ) );
            if ( kwargs.pk ) {
                getData = {
                    'obj_type': kwargs.obj_type,
                    'pk': kwargs.pk
                };
            } else {
                if ( $(btn).attr( 'data-init' ) ) {
                    initData = $(btn).attr( 'data-init' );
                }

                getData = {
                    'data': initData,
                    'obj_type': kwargs.obj_type,
                    'related_pk': metadata.attr( 'data-objPk' ),
                    'related_type': metadata.attr( 'data-objType' ),
                };
            }

            $(document).scrollTop(0);
            $.ajax({
                type: 'GET',
                url: kwargs.get_url,
                data: getData,
                global: false,
                dataType: 'json',
                success: function( data ) {
                    metaData = $('<div id="form-metadata">')
                        .attr( 'objType', kwargs.obj_type )
                        .attr( 'style', 'display:none' );
                    setTimeout( function() {
                        $('#hidden-inner-form')
                            .empty()
                            .append( data.form )
                            .append( metaData );
                        initForms();
                    }, 150 );
                    $('#form-title').html( data.form_title );
                    $('.form-btns .btn').not('.cancel').text( data.submit_btn_label );
                    $('.form-btns .btn').not('.cancel').attr( 'class', buttonAttrs );
                    $('#obj-form').slideDown();
                }
            });
{'fraction_non_alphanumeric': 0.15915409054805402, 'fraction_numerical': 0.0028792692613185066, 'mean_word_length': 1.4121168582375478, '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': '4778071', 'n_tokens_mistral': 2838, 'n_tokens_neox': 2723, 'n_words': 566}