<commit_before>$(function(){
    function setAddress($container){
        clearTimeout(window._address_timeout);

        window._address_timeout = setTimeout(function(){
            var country = MapasCulturais.pais ? MapasCulturais.pais : 'BR';
            var state = $container.find('.js-rfc-input-En_Estado').val();
            var city = $container.find('.js-rfc-input-En_Municipio').val();
            var street = $container.find('.js-rfc-input-En_Nome_Logradouro').val();
            var neighborhood = $container.find('.js-rfc-input-En_Bairro').val();
            var number = $container.find('.js-rfc-input-En_Num').val();
    
            if (state && city && street) {
                var address = neighborhood ? 
                    street + ' ' + number + ', ' + neighborhood + ', ' + city + ', ' + state + ', ' + country : 
                    street + ' ' + number + ', ' + city + ', ' + state + ', ' + country;
    
                
                $container.find('.js-rfc-input-endereco').val(address).trigger('change');
            }
        },500);
    }

    function changeCEP($cep, $container, timeout) {
        clearTimeout(window._cep_timeout);

        window._cep_timeout = setTimeout(function() {
            if(/^\d{5}-\d{3}$/.exec($cep.val())){
                $container.find('.js-rfc-input-En_Nome_Logradouro').val('').attr('placeholder', 'carregando...');
                $container.find('.js-rfc-input-En_Bairro').val('').attr('placeholder', 'carregando...');
                $container.find('.js-rfc-input-En_Estado').val('').attr('placeholder', 'carregando...');
                $container.find('.js-rfc-input-En_Municipio').val('').attr('placeholder', 'carregando...');

                $.getJSON('/site/address_by_postalcode?postalcode='+$cep.val())
                .success(function(r){
                    $container.find('.js-rfc-input-En_Nome_Logradouro').attr('placeholder', '');
                    $container.find('.js-rfc-input-En_Bairro').attr('placeholder', '');
                    $container.find('.js-rfc-input-En_Estado').attr('placeholder', '');
                    $container.find('.js-rfc-input-En_Municipio').attr('placeholder', '');
                    if (r.success) {
                        $container.find('.js-rfc-input-_lat').val(r.lat).trigger('change');
                        $container.find('.js-rfc-input-_lon').val(r.lon).trigger('change');

                        $container.find('.js-rfc-input-En_Nome_Logradouro').val(r.streetName).trigger('change');
                        $container.find('.js-rfc-input-En_Bairro').val(r.neighborhood).trigger('change');
                        $container.find('.js-rfc-input-En_Estado').val(r.state.sigla).trigger('change');
                        
                        $container.find('.js-rfc-input-En_Municipio').val(r.city.nome).trigger('change');

                        setAddress($container);
                    }
                })
                .error(function(){
                    $container.find('.js-rfc-input-En_Nome_Logradouro').attr('placeholder', '');
                    $container.find('.js-rfc-input-En_Bairro').attr('placeholder', '');
                    $container.find('.js-rfc-input-En_Estado').attr('placeholder', '');
                    $container.find('.js-rfc-input-En_Municipio').attr('placeholder', '');
                });
            }
        },timeout);

        setAddress($container);
    }

    $('body').on('change', 'input.js-rfc-input-En_CEP', function() {
        var $cep = $(this);
        var $container = $cep.parents('.js-rfc-location');

        changeCEP($cep, $container, 10);
    });

    $('body').on('keypress', 'input.js-rfc-input', function() {
        clearTimeout(window._geocoding_timeout);

        var $container = $(this).parents('.js-rfc-location');
        
        window._geocoding_timeout = setTimeout(function(){
            var country = MapasCulturais.pais ? MapasCulturais.pais : 'BR';
            var state = $container.find('.js-rfc-input-En_Estado').val();
            var city = $container.find('.js-rfc-input-En_Municipio').val();
            var street = $container.find('.js-rfc-input-En_Nome_Logradouro').val();
            var neighborhood = $container.find('.js-rfc-input-En_Bairro').val();
            var number = $container.find('.js-rfc-input-En_Num').val();

            if (state && city && street) {
                var address = neighborhood ? 
                    street + ' ' + number + ', ' + neighborhood + ', ' + city + ', ' + state + ', ' + country : 
                    street + ' ' + number + ', ' + city + ', ' + state + ', ' + country;

                
                MapasCulturais.geocoder.geocode({ fullAddress: address }, function(r) {
                    
                    $container.find('.js-rfc-input-_lat').val(r.lat).trigger('change');
                    $container.find('.js-rfc-input-_lon').val(r.lon).trigger('change');
                    
                    setTimeout(function(){
                        $container.find('.js-rfc-input:first').trigger('change');
                    },10);

                    setAddress($container);

                });
            }
        },1000);
    });
});<commit_msg>ao carregar a página do formulário de oportunidade, se há campo de endereço preenchido faz a busca por lat/long<commit_after>$(function(){
    function setAddress($container){
        clearTimeout(window._address_timeout);

        window._address_timeout = setTimeout(function(){
            var country = MapasCulturais.pais ? MapasCulturais.pais : 'BR';
            var state = $container.find('.js-rfc-input-En_Estado').val();
            var city = $container.find('.js-rfc-input-En_Municipio').val();
            var street = $container.find('.js-rfc-input-En_Nome_Logradouro').val();
            var neighborhood = $container.find('.js-rfc-input-En_Bairro').val();
            var number = $container.find('.js-rfc-input-En_Num').val();
    
            if (state && city && street) {
                var address = neighborhood ? 
                    street + ' ' + number + ', ' + neighborhood + ', ' + city + ', ' + state + ', ' + country : 
                    street + ' ' + number + ', ' + city + ', ' + state + ', ' + country;
    
                
                $container.find('.js-rfc-input-endereco').val(address).trigger('change');
            }
        },500);
    }

    function changeCEP($cep, $container, timeout) {
        clearTimeout(window._cep_timeout);

        window._cep_timeout = setTimeout(function() {
            if(/^\d{5}-\d{3}$/.exec($cep.val())){
                $container.find('.js-rfc-input-En_Nome_Logradouro').val('').attr('placeholder', 'carregando...');
                $container.find('.js-rfc-input-En_Bairro').val('').attr('placeholder', 'carregando...');
                $container.find('.js-rfc-input-En_Estado').val('').attr('placeholder', 'carregando...');
                $container.find('.js-rfc-input-En_Municipio').val('').attr('placeholder', 'carregando...');

                $.getJSON('/site/address_by_postalcode?postalcode='+$cep.val())
                .success(function(r){
                    $container.find('.js-rfc-input-En_Nome_Logradouro').attr('placeholder', '');
                    $container.find('.js-rfc-input-En_Bairro').attr('placeholder', '');
                    $container.find('.js-rfc-input-En_Estado').attr('placeholder', '');
                    $container.find('.js-rfc-input-En_Municipio').attr('placeholder', '');
                    if (r.success) {
                        $container.find('.js-rfc-input-_lat').val(r.lat).trigger('change');
                        $container.find('.js-rfc-input-_lon').val(r.lon).trigger('change');

                        $container.find('.js-rfc-input-En_Nome_Logradouro').val(r.streetName).trigger('change');
                        $container.find('.js-rfc-input-En_Bairro').val(r.neighborhood).trigger('change');
                        $container.find('.js-rfc-input-En_Estado').val(r.state.sigla).trigger('change');
                        
                        $container.find('.js-rfc-input-En_Municipio').val(r.city.nome).trigger('change');

                        setAddress($container);
                    }
                })
                .error(function(){
                    $container.find('.js-rfc-input-En_Nome_Logradouro').attr('placeholder', '');
                    $container.find('.js-rfc-input-En_Bairro').attr('placeholder', '');
                    $container.find('.js-rfc-input-En_Estado').attr('placeholder', '');
                    $container.find('.js-rfc-input-En_Municipio').attr('placeholder', '');
                });
            }
        },timeout);

        setAddress($container);
    }

    $('body').on('change', 'input.js-rfc-input-En_CEP', function() {
        var $cep = $(this);
        var $container = $cep.parents('.js-rfc-location');

        changeCEP($cep, $container, 10);
    });

    $('body').on('keypress', 'input.js-rfc-input', function() {
        clearTimeout(window._geocoding_timeout);

        var $container = $(this).parents('.js-rfc-location');
        
        window._geocoding_timeout = setTimeout(function(){
            var country = MapasCulturais.pais ? MapasCulturais.pais : 'BR';
            var state = $container.find('.js-rfc-input-En_Estado').val();
            var city = $container.find('.js-rfc-input-En_Municipio').val();
            var street = $container.find('.js-rfc-input-En_Nome_Logradouro').val();
            var neighborhood = $container.find('.js-rfc-input-En_Bairro').val();
            var number = $container.find('.js-rfc-input-En_Num').val();

            if (state && city && street) {
                var address = neighborhood ? 
                    street + ' ' + number + ', ' + neighborhood + ', ' + city + ', ' + state + ', ' + country : 
                    street + ' ' + number + ', ' + city + ', ' + state + ', ' + country;

                
                MapasCulturais.geocoder.geocode({ fullAddress: address }, function(r) {
                    
                    $container.find('.js-rfc-input-_lat').val(r.lat).trigger('change');
                    $container.find('.js-rfc-input-_lon').val(r.lon).trigger('change');
                    
                    setTimeout(function(){
                        $container.find('.js-rfc-input:first').trigger('change');
                    },10);

                    setAddress($container);

                });
            }
        },1000);
    });

    setTimeout(function() {
        $('input.js-rfc-input:first').trigger('keypress');
    }, 5000);


});
{'fraction_non_alphanumeric': 0.1839649057308195, 'fraction_numerical': 0.002800074668657831, 'mean_word_length': 1.8588580576307363, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6444248', 'n_tokens_mistral': 3209, 'n_tokens_neox': 3073, 'n_words': 329}