<commit_before>'use strict';

angular.module('myApp.route-planner', ['ngRoute'])

    .config(['$routeProvider', function ($routeProvider) {
        $routeProvider.when('/route-planner', {
            templateUrl: 'route-planner/route-planner.html',
            controller: 'RoutePlannerCtrl'
        });
    }])

    .controller('RoutePlannerCtrl', ['$scope', 'GoogleMapApi'.ns(), function ($scope, GoogleMapApi) {

        $scope.locations = [
            'orem, ut',
            'payson, ut',
            'springville, ut'
        ];

        $scope.waypoints = []

        $scope.input = document.getElementById('searchTextField');
        $scope.autoComplete = new google.maps.places.Autocomplete(input);

        google.maps.event.addListener($scope.autoComplete, 'place_changed', function() {
            var place = $scope.autoComplete.getPlace();
            $scope.selected = place.formatted_address;
    });

        $scope.addWaypoint = function () {

            var locationObject = {location: $scope.selected}
            $scope.waypoints.push(locationObject)
            $scope.calcRoute()
        }

        $scope.deleteWaypoint = function (waypoint) {

            var index = $scope.waypoints.indexOf(waypoint)
            if (index > -1) {
                $scope.waypoints.splice(index, 1);
                $scope.calcRoute()
            }
        }

        GoogleMapApi.then(function (maps) {
            $scope.maps = maps;
            console.log(maps);
            $scope.initialize();
        });

        $scope.initialize = function () {

            $scope.travelMode = $scope.maps.TravelMode.DRIVING
            $scope.start = "new york"
            $scope.end = "new york"
            $scope.rendererOptions = {
                draggable: true
            };
            $scope.directionsDisplay = new $scope.maps.DirectionsRenderer($scope.rendererOptions);
            ;
            $scope.directionsService = new $scope.maps.DirectionsService();
            $scope.map;
            $scope.travelModes = [
                {
                    name: "driving",
                    value: $scope.maps.TravelMode.DRIVING
                },
                {
                    name: "walking",
                    value: $scope.maps.TravelMode.WALKING
                },
                {
                    name: "bicycling",
                    value: $scope.maps.TravelMode.BICYCLING
                },
                {
                    name: "transit",
                    value: $scope.maps.TravelMode.TRANSIT
                }

            ]


            $scope.directionsDisplay = new $scope.maps.DirectionsRenderer($scope.rendererOptions);
//            $scope.chicago = new $scope.maps.LatLng(41.850033, -87.6500523);
            var mapOptions = {
                zoom: 7
            };
            $scope.map = new $scope.maps.Map(document.getElementById('map-canvas'), mapOptions);

            $scope.directionsDisplay.setMap($scope.map);
            $scope.directionsDisplay.setPanel(document.getElementById("directionsPanel"));
            $scope.maps.event.addListener($scope.directionsDisplay, 'directions_changed', function () {
                $scope.computeTotalDistance($scope.directionsDisplay.getDirections());
            });

            $scope.calcRoute()
        };

        $scope.calcRoute = function () {
            var request = {
                origin: $scope.start,
                destination: $scope.end,
//                travelMode: $scope.maps.TravelMode.DRIVING
                waypoints: $scope.waypoints,
                optimizeWaypoints: true,
                travelMode: $scope.travelMode
            };
            $scope.directionsService.route(request, function (response, status) {
                if (status == $scope.maps.DirectionsStatus.OK) {
                    $scope.directionsDisplay.setDirections(response);
                    $scope.directionsDisplay.setPanel(document.getElementById("directionsPanel"));
                }
            });

            $scope.maps.event.trigger($scope.map, 'resize');
        };

        $scope.computeTotalDistance = function (result) {
            var total = 0;
            var myroute = result.routes[0];
            for (var i = 0; i < myroute.legs.length; i++) {
                total += myroute.legs[i].distance.value;
            }
            total = total / 1000.0
            document.getElementById('total').innerHTML = total + 'km';
        }


    }]);<commit_msg>Got a custom bank button calling a function - not the function we want, but a function<commit_after>'use strict';

angular.module('myApp.route-planner', ['ngRoute'])

    .config(['$routeProvider', function ($routeProvider) {
        $routeProvider.when('/route-planner', {
            templateUrl: 'route-planner/route-planner.html',
            controller: 'RoutePlannerCtrl'
        });
    }])

    .controller('RoutePlannerCtrl', ['$scope', 'GoogleMapApi'.ns(), function ($scope, GoogleMapApi) {

        $scope.locations = [
            'orem, ut',
            'payson, ut',
            'springville, ut'
        ];


        $scope.waypoints = [];

        $scope.input = document.getElementById('searchTextField');
        $scope.autoComplete = new google.maps.places.Autocomplete(input);

        google.maps.event.addListener($scope.autoComplete, 'place_changed', function () {
            var place = $scope.autoComplete.getPlace();
            $scope.selected = place.formatted_address;
        });

        $scope.addWaypoint = function () {

            var locationObject = {location: $scope.selected};
            $scope.waypoints.push(locationObject);
            $scope.calcRoute();
        };

        $scope.deleteWaypoint = function (waypoint) {

            var index = $scope.waypoints.indexOf(waypoint);
            if (index > -1) {
                $scope.waypoints.splice(index, 1);
                $scope.calcRoute()
            }
        };

        $scope.BankControl = function (controlDiv, map) {

            controlDiv.style.padding = '5px';

            var controlUI = document.createElement('div');
            controlUI.style.backgroundColor = 'white';
            controlUI.style.borderStyle = 'solid';
            controlUI.style.borderWidth = '2px';
            controlUI.style.cursor = 'pointer';
            controlUI.style.textAlign = 'center';
            controlUI.title = 'Click to find banks nearby';
            controlDiv.appendChild(controlUI);

            var controlText = document.createElement('div');
            controlText.style.fontFamily = 'Arial,sans-serif';
            controlText.style.fontSize = '12px';
            controlText.style.paddingLeft = '4px';
            controlText.style.paddingRight = '4px';
            controlText.innerHTML = '<b>Bank</b>';
            controlUI.appendChild(controlText);

            $scope.maps.event.addDomListener(controlUI, 'click', function () {
                var chicago = new $scope.maps.LatLng(41.850033, -87.6500523)
                map.setCenter(chicago);
            });

        };

        GoogleMapApi.then(function (maps) {
            $scope.maps = maps;
            console.log(maps);
            $scope.initialize();
        });

        $scope.initialize = function () {



            $scope.travelMode = $scope.maps.TravelMode.DRIVING;
            $scope.start = "new york";
            $scope.end = "new york";
            $scope.rendererOptions = {
                draggable: true
            };
            $scope.directionsDisplay = new $scope.maps.DirectionsRenderer($scope.rendererOptions);
            $scope.directionsService = new $scope.maps.DirectionsService();


            $scope.travelModes = [
                {
                    name: "driving",
                    value: $scope.maps.TravelMode.DRIVING
                },
                {
                    name: "walking",
                    value: $scope.maps.TravelMode.WALKING
                },
                {
                    name: "bicycling",
                    value: $scope.maps.TravelMode.BICYCLING
                },
                {
                    name: "transit",
                    value: $scope.maps.TravelMode.TRANSIT
                }

            ];


            $scope.directionsDisplay = new $scope.maps.DirectionsRenderer($scope.rendererOptions);
//            $scope.chicago = new $scope.maps.LatLng(41.850033, -87.6500523);
            var mapOptions = {
                zoom: 7
            };
            $scope.map = new $scope.maps.Map(document.getElementById('map-canvas'), mapOptions);

            $scope.directionsDisplay.setMap($scope.map);
            $scope.directionsDisplay.setPanel(document.getElementById("directionsPanel"));
            $scope.maps.event.addListener($scope.directionsDisplay, 'directions_changed', function () {
                $scope.computeTotalDistance($scope.directionsDisplay.getDirections());
            });

            $scope.calcRoute()
        };

        $scope.calcRoute = function () {
            var request = {
                origin: $scope.start,
                destination: $scope.end,
//                travelMode: $scope.maps.TravelMode.DRIVING
                waypoints: $scope.waypoints,
                optimizeWaypoints: true,
                travelMode: $scope.travelMode
            };
            $scope.directionsService.route(request, function (response, status) {
                if (status == $scope.maps.DirectionsStatus.OK) {
                    $scope.directionsDisplay.setDirections(response);
                    $scope.directionsDisplay.setPanel(document.getElementById("directionsPanel"));
                }
            });

            $scope.bankControlDiv;

            $scope.bankControlDiv = document.createElement('div');
            $scope.bankControl = new $scope.BankControl($scope.bankControlDiv, $scope.map);
            $scope.bankControlDiv.index = 1;
            $scope.map.controls[$scope.maps.ControlPosition.TOP_RIGHT].push($scope.bankControlDiv);


            $scope.maps.event.trigger($scope.map, 'resize');
        };

        $scope.computeTotalDistance = function (result) {
            var total = 0;
            var myroute = result.routes[0];
            for (var i = 0; i < myroute.legs.length; i++) {
                total += myroute.legs[i].distance.value;
            }
            total = total / 1000.0;
            document.getElementById('total').innerHTML = total + 'km';
        }


    }]);

{'fraction_non_alphanumeric': 0.12458519010145065, 'fraction_numerical': 0.007585095287759552, 'mean_word_length': 1.6730866700456157, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1537432', 'n_tokens_mistral': 2925, 'n_tokens_neox': 2710, 'n_words': 423}