<commit_before>define([
    'require',
    'underscore',
    'modules/services/google',
    'ngApp'
], function (require) {
    var ngApp = require('ngApp'),
        _ = require('underscore');

    return ngApp.service('addressFinderService', ['googleService', function (googleService) {
        var geocoder;


        googleService.onGoogleReady(function () {
            geocoder = new google.maps.Geocoder();
        });

        function geocodeAddress(address, callback) {
            if (!geocoder) {
                googleService.onGoogleReady(function () {
                    geocoder.geocode({'address': address}, function (results, status) {
                        console.log('geocodeAddress(%s) =', address, arguments);
                        callback.apply();
                    });
                });
            } else {
                geocoder.geocode({'address': address}, function (results, status) {
                    console.log('geocodeAddress(%s) =', address, arguments);
                    switch (status) {
                        case 'OK':
                            var locationResult = results[0];
                            callback.call(null, {
                                address : locationResult['formatted_address'],
                                lat: locationResult.geometry.location.lat(),
                                lng: locationResult.geometry.location.lng()
                            });
                            break;
                        case 'ZERO_RESULTS':
                        default:
                            callback.call(null, false);
                            break;
                    }
                });
            }
        }

        this.findCoordinates = geocodeAddress;

        return this;
    }]);
});<commit_msg>fixes web saves without google maps key<commit_after>var ngApp = require('ngApp'),
    angular = require('angular'),
    url = require('url');

ngApp.service('addressFinderService', ['googleService', function (googleService) {
    var geocoder,
        $mapsScript = angular.element("script[src*='maps.googleapis.com/maps/api/js']"),
        mapsKey = url.parse($mapsScript.attr('src')).query['key'];


    googleService.onGoogleReady(function () {
        geocoder = new google.maps.Geocoder();
    });

    function geocodeAddress(address, callback) {
        debugger;
        if (geocoder && mapsKey) {
            geocoder.geocode({'address': address}, function (results, status) {
                console.log('geocodeAddress(%s) =', address, arguments);
                switch (status) {
                    case 'OK':
                        var locationResult = results[0];
                        callback.call(null, {
                            address : locationResult['formatted_address'],
                            lat: locationResult.geometry.location.lat(),
                            lng: locationResult.geometry.location.lng()
                        });
                        break;
                    case 'ZERO_RESULTS':
                    default:
                        callback.call(null, false);
                        break;
                }
            });
        } else if (mapsKey) {
            googleService.onGoogleReady(function () {
                geocoder.geocode({'address': address}, function (results, status) {
                    console.log('geocodeAddress(%s) =', address, arguments);
                    callback.apply();
                });
            });
        } else {
            callback(null, false);
        }
    }

    this.findCoordinates = geocodeAddress;

    return this;
}]);

module.exports = ngApp;
{'fraction_non_alphanumeric': 0.11635475996745322, 'fraction_numerical': 0.0005424464334147003, 'mean_word_length': 1.3870550161812298, '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': '2557067', 'n_tokens_mistral': 910, 'n_tokens_neox': 866, 'n_words': 156}