<commit_before>(function() {
    'use strict';

    /**
     * Component for the home page.
     * @returns {directive}
     */
    var homeDirective = function() {
        return {
            restrict: 'E',
            scope: {},
            controller: 'vgHomeCtrl',
            controllerAs: 'homeVm',
            bindToController: true,
            templateUrl: '/veganaut/home/home.tpl.html'
        };
    };

    var homeCtrl = [
        '$scope', '$location', '$translate', 'backendService', 'angularPiwik',
        'mainMapService', 'geocodeService', 'alertService', 'localeService',
        function($scope, $location, $translate, backendService, angularPiwik,
            mainMapService, geocodeService, alertService, localeService)
        {
            var vm = this;

            /**
             * Zoom on the map used when we show the place returned
             * by the browser's geo location API.
             * @type {number}
             */
            var GEO_LOCATION_ZOOM = 15;

            // Expose the global methods we still need
            // TODO: find a better way to do this
            vm.legacyGlobals = {
                goToView: $scope.$parent.goToView,
                isLoggedIn: $scope.$parent.isLoggedIn
            };

            /**
             * Cta form input model
             * @type {string}
             */
            vm.ctaFormInput = '';

            /**
             * Whether we are currently running geo locating
             * @type {boolean}
             */
            vm.geolocating = false;

            /**
             * The target place to show on the map when submitting the cta form.
             * @type {{}}
             */
            var targetPlace = {
                lat: 0,
                lng: 0,
                zoom: 2,
                displayName: vm.ctaFormInput
            };

            /**
             * Whether to clear the cta input field on the next focus event
             * @type {boolean}
             */
            var clearCtaInputOnFocus = true;

            /**
             * Uses the geocodeService to search for places with the given name
             * @param {string} searchInput
             * @returns {GeocodeResult[]}
             */
            vm.getSearchResults = function(searchInput) {
                // TODO: should use piwik's search tracking
                angularPiwik.track('home.cta', 'home.cta.searchStart');

                return geocodeService.search(searchInput).then(function(response) {
                    return response;
                });
            };

            /**
             * Whether the cta form can currently be submitted
             * @returns {boolean}
             */
            vm.canSubmitCta = function() {
                // Can only submit when we have a target and it's currently shown in the input field
                return (angular.isObject(targetPlace) && targetPlace.displayName === vm.ctaFormInput);
            };

            /**
             * Handler for when the user selects a result from the auto-complete.
             * @param {GeocodeResult} selected
             */
            vm.onResultSelected = function(selected) {
                // Set the target place
                targetPlace = {
                    lat: selected.lat,
                    lng: selected.lng,
                    boundingBox: selected.bounds,
                    displayName: selected.getDisplayName()
                };

                // We no longer want to clear the input field on focus
                clearCtaInputOnFocus = false;

                angularPiwik.track('home.cta', 'home.cta.selectResult');
            };

            /**
             * Handler for the focus event of the cta input.
             */
            vm.onCtaInputFocus = function() {
                if (clearCtaInputOnFocus) {
                    vm.ctaFormInput = '';
                }
            };

            /**
             * Handler for the blur event of the cta input.
             */
            vm.onCtaInputBlur = function() {
                // If the user leaves the input and we cannot submit the form
                // but we have a target place, set that place again
                if (!vm.canSubmitCta() && angular.isObject(targetPlace)) {
                    vm.ctaFormInput = targetPlace.displayName;
                }
            };

            /**
             * Handler for submission of the cta form.
             * Will go to the selected place on the map.
             */
            vm.onCtaSubmit = function(targetPage) {
                mainMapService.setTargetPlace(targetPlace);
                $location.path('map');

                // Check which target page was given
                var action = '';
                if (targetPage === 'list') {
                    action = 'home.cta.submitToList';
                    // Feature not done yet, inform the user
                    alertService.addAlert($translate.instant('missingFeature.goToList'), 'info', undefined, 13000);
                }
                else {
                    action = 'home.cta.submitToMap';
                }

                angularPiwik.track('home.cta', action);<commit_msg>Showing hint about list feature missing for a longer time.<commit_after>(function() {
    'use strict';

    /**
     * Component for the home page.
     * @returns {directive}
     */
    var homeDirective = function() {
        return {
            restrict: 'E',
            scope: {},
            controller: 'vgHomeCtrl',
            controllerAs: 'homeVm',
            bindToController: true,
            templateUrl: '/veganaut/home/home.tpl.html'
        };
    };

    var homeCtrl = [
        '$scope', '$location', '$translate', 'backendService', 'angularPiwik',
        'mainMapService', 'geocodeService', 'alertService', 'localeService',
        function($scope, $location, $translate, backendService, angularPiwik,
            mainMapService, geocodeService, alertService, localeService)
        {
            var vm = this;

            /**
             * Zoom on the map used when we show the place returned
             * by the browser's geo location API.
             * @type {number}
             */
            var GEO_LOCATION_ZOOM = 15;

            // Expose the global methods we still need
            // TODO: find a better way to do this
            vm.legacyGlobals = {
                goToView: $scope.$parent.goToView,
                isLoggedIn: $scope.$parent.isLoggedIn
            };

            /**
             * Cta form input model
             * @type {string}
             */
            vm.ctaFormInput = '';

            /**
             * Whether we are currently running geo locating
             * @type {boolean}
             */
            vm.geolocating = false;

            /**
             * The target place to show on the map when submitting the cta form.
             * @type {{}}
             */
            var targetPlace = {
                lat: 0,
                lng: 0,
                zoom: 2,
                displayName: vm.ctaFormInput
            };

            /**
             * Whether to clear the cta input field on the next focus event
             * @type {boolean}
             */
            var clearCtaInputOnFocus = true;

            /**
             * Uses the geocodeService to search for places with the given name
             * @param {string} searchInput
             * @returns {GeocodeResult[]}
             */
            vm.getSearchResults = function(searchInput) {
                // TODO: should use piwik's search tracking
                angularPiwik.track('home.cta', 'home.cta.searchStart');

                return geocodeService.search(searchInput).then(function(response) {
                    return response;
                });
            };

            /**
             * Whether the cta form can currently be submitted
             * @returns {boolean}
             */
            vm.canSubmitCta = function() {
                // Can only submit when we have a target and it's currently shown in the input field
                return (angular.isObject(targetPlace) && targetPlace.displayName === vm.ctaFormInput);
            };

            /**
             * Handler for when the user selects a result from the auto-complete.
             * @param {GeocodeResult} selected
             */
            vm.onResultSelected = function(selected) {
                // Set the target place
                targetPlace = {
                    lat: selected.lat,
                    lng: selected.lng,
                    boundingBox: selected.bounds,
                    displayName: selected.getDisplayName()
                };

                // We no longer want to clear the input field on focus
                clearCtaInputOnFocus = false;

                angularPiwik.track('home.cta', 'home.cta.selectResult');
            };

            /**
             * Handler for the focus event of the cta input.
             */
            vm.onCtaInputFocus = function() {
                if (clearCtaInputOnFocus) {
                    vm.ctaFormInput = '';
                }
            };

            /**
             * Handler for the blur event of the cta input.
             */
            vm.onCtaInputBlur = function() {
                // If the user leaves the input and we cannot submit the form
                // but we have a target place, set that place again
                if (!vm.canSubmitCta() && angular.isObject(targetPlace)) {
                    vm.ctaFormInput = targetPlace.displayName;
                }
            };

            /**
             * Handler for submission of the cta form.
             * Will go to the selected place on the map.
             */
            vm.onCtaSubmit = function(targetPage) {
                mainMapService.setTargetPlace(targetPlace);
                $location.path('map');

                // Check which target page was given
                var action = '';
                if (targetPage === 'list') {
                    action = 'home.cta.submitToList';
                    // Feature not done yet, inform the user
                    alertService.addAlert($translate.instant('missingFeature.goToList'), 'info', undefined, 18000);
                }
                else {
                    action = 'home.cta.submitToMap';
                }

                angularPiwik.track('home.cta', action);
{'fraction_non_alphanumeric': 0.09191141526470868, 'fraction_numerical': 0.0019009599847923202, 'mean_word_length': 1.2411075612353568, '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': '483411', 'n_tokens_mistral': 2655, 'n_tokens_neox': 2474, 'n_words': 722}