<commit_before>'use strict';

/* Services */


// Demonstrate how to register services
// In this case it is a simple value service.
var myModule = angular.module('myApp.services', []);
myModule.factory('auth', ['$rootScope', '$http', '$location', function($rootScope, $http, $location) {
 //  function isLoggedin() {
 //  	$http.get('/api/isLoggedin').success(function(data, status, headers, config) {
 //  		$rootScope.user = data;
	// }).error(function (data, status, headers, config) {
	// 	if(status == 401) {
	// 		$location.path('/landing');
	// 	}
	// });
 //  }
 //  return isLoggedin();
}]);

myModule.factory('GoogleMap', function($http){
	return {
		createMap: function () {	
			console.log("I'm calling GoogleMap in services");
			var myOptions = {
                zoom : 12,
                center : new google.maps.LatLng(40.750046, -73.992358),
                mapTypeId : google.maps.MapTypeId.ROADMAP
            };
            
            var map = new google.maps.Map(document.getElementById('map-canvas'),
                myOptions);

            return map;
		},
		populateMap: function(tweets, map){

			//console.log(tweets);
			var locations = [];
      var markers = [];
      var infowindows = [];

			for (var i = 0; i < tweets.length; i++) {
           console.log(tweets[i]);
          if(tweets[i].coordinates){

              var myLatLng = new google.maps.LatLng(tweets[i].coordinates.lat, tweets[i].coordinates.lng);
              var marker = new google.maps.Marker({
                position: myLatLng,
                map: map,
              });
             
              var contentString =  
              '<div id="infoWindow">'+
              '<p>'+ tweets[i].text + '</p>'+
              '<p>'+ tweets[i].user.screen_name + '</p>'+
              '<p>'+ tweets[i].user.followers_count + '</p>'+
              '<p> <strong> Sentiment </strong>' + tweets[i].sentiment + '</p>'
              + '<button ng-click="reply()">reply</button>'
              + '</div>';

              // '<h2>' + locations[i].user.followers_count + '</h2>'+
                      
              var infowindow = new google.maps.InfoWindow({
                content: contentString
              });
              google.maps.event.addListener(marker, 'click', function() {
                infowindow.open(map,marker);
              });
          }
			};
		},

    fillMap: function(tweets, map){

      var locations = [];
      for (var i = 0; i < tweets.length; i++) {
        locations.push(tweets[i].coordinates);
      };

      var infowindow = new google.maps.InfoWindow({
        maxWidth: 160
      });
      var marker;
      var markers = new Array();

      var iconCounter = 0;
    
      // Add the markers and infowindows to the map
      for (var i = 0; i < locations.length; i++) {  

        if(tweets[i].coordinates){
          marker = new google.maps.Marker({
            position: new google.maps.LatLng(locations[i].lat, locations[i].lng),
            map: map
            // icon : icons[iconCounter],
            // shadow: shadow
            });
        }


      markers.push(marker);

      google.maps.event.addListener(marker, 'click', (function(marker, i) {
        return function() {
          infowindow.setContent(contentString);
          infowindow.open(map, marker);
        }
      })(marker, i));
      
      iconCounter++;
      // We only have a limited number of possible icon colors, so we may have to restart the counter
      if(iconCounter >= tweets.length){
        iconCounter = 0;
      }
    }

      function AutoCenter() {
        //  Create a new viewpoint bound
        var bounds = new google.maps.LatLngBounds();
        //  Go through each...
        $.each(markers, function (index, marker) {
          bounds.extend(marker.position);
        });
        //  Fit these bounds to the map
        map.fitBounds(bounds);
      }
    
      AutoCenter();
    }

	}
});

myModule.factory('Dates', function($http){<commit_msg>fix small map<commit_after>'use strict';

/* Services */


// Demonstrate how to register services
// In this case it is a simple value service.
var myModule = angular.module('myApp.services', []);
myModule.factory('auth', ['$rootScope', '$http', '$location', function($rootScope, $http, $location) {
 //  function isLoggedin() {
 //  	$http.get('/api/isLoggedin').success(function(data, status, headers, config) {
 //  		$rootScope.user = data;
	// }).error(function (data, status, headers, config) {
	// 	if(status == 401) {
	// 		$location.path('/landing');
	// 	}
	// });
 //  }
 //  return isLoggedin();
}]);

myModule.factory('GoogleMap', function($http){
	return {
		createMap: function () {	
			console.log("I'm calling GoogleMap in services");
			var myOptions = {
                zoom : 12,
                center : new google.maps.LatLng(40.750046, -73.992358),
                mapTypeId : google.maps.MapTypeId.ROADMAP
            };
            
            var map = new google.maps.Map(document.getElementById('map-canvas'),
                myOptions);

            return map;
		},

    fillMap: function(tweets, map){

      var locations = [];
      for (var i = 0; i < tweets.length; i++) {
        locations.push(tweets[i].coordinates);
      };

      var infowindow = new google.maps.InfoWindow({
        maxWidth: 160
      });
      var marker;
      var markers = new Array();

      var iconCounter = 0;
    
      // Add the markers and infowindows to the map
      for (var i = 0; i < locations.length; i++) {  

        if(tweets[i].coordinates){
          marker = new google.maps.Marker({
            position: new google.maps.LatLng(locations[i].lat, locations[i].lng),
            map: map
            // icon : icons[iconCounter],
            // shadow: shadow
            });
        }


      markers.push(marker);

      google.maps.event.addListener(marker, 'click', (function(marker, i) {
        return function() {
          var contentString =  
              '<div id="infoWindow">'+
              '<p>'+ tweets[i].text + '</p>'+
              '<p>'+ tweets[i].user.screen_name + '</p>'+
              '<p>'+ tweets[i].user.followers_count + '</p>'+
              '<p> <strong> Sentiment </strong>' + tweets[i].sentiment + '</p>'
              + '<button ng-click="reply()">reply</button>'
              + '</div>';

          infowindow.setContent(contentString);
          infowindow.open(map, marker);
        }
      })(marker, i));
      
      iconCounter++;
      // We only have a limited number of possible icon colors, so we may have to restart the counter
      if(iconCounter >= tweets.length){
        iconCounter = 0;
      }
    }

      function AutoCenter() {
        //  Create a new viewpoint bound
        var bounds = new google.maps.LatLngBounds();
        //  Go through each...
        $.each(markers, function (index, marker) {
          bounds.extend(marker.position);
        });
        //  Fit these bounds to the map
        map.fitBounds(bounds);
      }
    
      AutoCenter();
    }

	}
});

myModule.factory('Dates', function($http){
{'fraction_non_alphanumeric': 0.15403010268673512, 'fraction_numerical': 0.00829933886622591, 'mean_word_length': 1.873888439773646, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 35, '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': '771933', 'n_tokens_mistral': 2229, 'n_tokens_neox': 2091, 'n_words': 476}