<commit_before>var module = angular.module('app', []);

module.factory('socket', function($rootScope){
    var socket = io.connect(window.location.href);
  	return {
        on: function (eventName, callback) {
            socket.on(eventName, function () {
            	var args = arguments;
                $rootScope.$apply(function () {
                    callback.apply(socket, args);
                });
            });
        },
        emit: function (eventName, data, callback) {
	      	socket.emit(eventName, data, function () {
	        	$rootScope.$apply(function () {
	          		if (callback) {
	            		callback.apply(socket, data);
	          		}
	        	});
	      	})
	    }
    };
});

module.factory('GoogleMap', function(){
    var mapOptions = {
		center: {lat: 20, lng: 0},
		zoom: 2
	}
	return new google.maps.Map($('#map-canvas')[0], mapOptions);
});

module.controller('MapController', function($scope, GoogleMap, socket){
	var keyword = null;
	var markers = [];
	$scope.keyword = null;
	$scope.stopBtnValue = 'Stop';
	$scope.trends = [];

	$scope.RestartBtnClick = function(){
		for (var i = 0; i < markers.length; i++) {
            markers[i].setMap(null);
        }
        markers = [];
		keyword = $scope.keyword.trim();
	}

	$scope.StopBtnClick = function(){
		if($scope.stopBtnValue === 'Stop')
			$scope.stopBtnValue = 'Continue';
		else
			$scope.stopBtnValue = 'Stop';
	}

	socket.on('connected', function(){
		socket.emit('start-streaming');
		socket.emit('get-trends');
	});
	socket.on('new-tweet', function(tweet){
		if($scope.stopBtnValue === 'Stop' &&
			(!keyword || keyword.length === 0 
				|| tweet.text.toLowerCase().indexOf(keyword.toLowerCase()) > -1))
		{
			var icon = null;
			if(tweet.sentiment.score < 0)
				icon = '../res/img/marker-red.png';
			if(tweet.sentiment.score == 0)
				icon = '../res/img/marker-yellow.png';
			if(tweet.sentiment.score > 0)
				icon = '../res/img/marker-green.png';


	      	var marker = new google.maps.Marker({
	         	map: GoogleMap,
	          	title: '@' + tweet.user.name,
	         	position: new google.maps.LatLng(tweet.coordinates.coordinates[1], tweet.coordinates.coordinates[0]),
	          	draggable: false,
	         	animation: google.maps.Animation.DROP,
	          	icon: icon
	      	}); 
	      	marker.setMap(GoogleMap);
	      	markers.push(marker);

	      	var info = '<div class="row text-center tweet-info-window">'
	      				+	'<div class="col-md-2 text-center">' 
	      				+		'<img class="img-responsive" src=' + tweet.user.profile_image_url + '></img>'
	      				+	'</div>'
	      				+	'<div class="col-md-10 text-left">' 
	      				+		'<p>' + '@' + tweet.user.name + '</p>'
	      				+ 		'<p><strong>' + tweet.text + '</strong></p>'
	      				+ 		'<p>' + tweet.created_at;
	      	if(tweet.place.name){
	      		info += '<br>' 
	      				+ tweet.place.name + ', ' 
	      				+ tweet.place.country;
	      	}
	      	info += '</p></div></div>';

	      	var infowindow = new google.maps.InfoWindow({
	        	  content: info,
	        	  maxWidth: 350
	      	});
	      	google.maps.event.addListener(marker, 'click', function(){
	        	if(infowindow.getMap() !== null) 
	        		infowindow.close(); 
	        	else 
	        		infowindow.open(GoogleMap, marker);
	      	});
      	}
	});

	socket.on('new-trends', function(trends){
		$scope.trends = trends;
	});
});<commit_msg>fixed the bug that the marker needs clicking twice to open<commit_after>var module = angular.module('app', []);

module.factory('socket', function($rootScope){
    var socket = io.connect(window.location.href);
  	return {
        on: function (eventName, callback) {
            socket.on(eventName, function () {
            	var args = arguments;
                $rootScope.$apply(function () {
                    callback.apply(socket, args);
                });
            });
        },
        emit: function (eventName, data, callback) {
	      	socket.emit(eventName, data, function () {
	        	$rootScope.$apply(function () {
	          		if (callback) {
	            		callback.apply(socket, data);
	          		}
	        	});
	      	})
	    }
    };
});

module.factory('GoogleMap', function(){
    var mapOptions = {
		center: {lat: 20, lng: 0},
		zoom: 2
	}
	return new google.maps.Map($('#map-canvas')[0], mapOptions);
});

module.controller('MapController', function($scope, GoogleMap, socket){
	var keyword = null;
	var markers = [];
	$scope.keyword = null;
	$scope.stopBtnValue = 'Stop';
	$scope.trends = [];

	$scope.RestartBtnClick = function(){
		for (var i = 0; i < markers.length; i++) {
            markers[i].setMap(null);
        }
        markers = [];
		keyword = $scope.keyword.trim();
	}

	$scope.StopBtnClick = function(){
		if($scope.stopBtnValue === 'Stop')
			$scope.stopBtnValue = 'Continue';
		else
			$scope.stopBtnValue = 'Stop';
	}

	socket.on('connected', function(){
		socket.emit('start-streaming');
		socket.emit('get-trends');
	});
	socket.on('new-tweet', function(tweet){
		if($scope.stopBtnValue === 'Stop' &&
			(!keyword || keyword.length === 0 
				|| tweet.text.toLowerCase().indexOf(keyword.toLowerCase()) > -1))
		{
			var icon = null;
			if(tweet.sentiment.score < 0)
				icon = '../res/img/marker-red.png';
			if(tweet.sentiment.score == 0)
				icon = '../res/img/marker-yellow.png';
			if(tweet.sentiment.score > 0)
				icon = '../res/img/marker-green.png';


	      	var marker = new google.maps.Marker({
	         	map: GoogleMap,
	          	title: '@' + tweet.user.name,
	         	position: new google.maps.LatLng(tweet.coordinates.coordinates[1], tweet.coordinates.coordinates[0]),
	          	draggable: false,
	         	animation: google.maps.Animation.DROP,
	          	icon: icon
	      	}); 
	      	marker.setMap(GoogleMap);
	      	markers.push(marker);

	      	var info = '<div class="row text-center tweet-info-window">'
	      				+	'<div class="col-md-2 text-center">' 
	      				+		'<img class="img-responsive" src=' + tweet.user.profile_image_url + '></img>'
	      				+	'</div>'
	      				+	'<div class="col-md-10 text-left">' 
	      				+		'<p>' + '@' + tweet.user.name + '</p>'
	      				+ 		'<p><strong>' + tweet.text + '</strong></p>'
	      				+ 		'<p>' + tweet.created_at;
	      	if(tweet.place){
	      		info += '<br>' 
	      				+ tweet.place.name + ', ' 
	      				+ tweet.place.country;
	      	}
	      	info += '</p></div></div>';

	      	var infowindow = new google.maps.InfoWindow({
	        	  content: info,
	        	  maxWidth: 350
	      	});
	      	google.maps.event.addListener(marker, 'click', function(){
	        	infowindow.open(GoogleMap, marker);
	      	});
      	}
	});

	socket.on('new-trends', function(trends){
		$scope.trends = trends;
	});
});
{'fraction_non_alphanumeric': 0.1771798264961035, 'fraction_numerical': 0.0055874136156447585, 'mean_word_length': 2.1374538745387452, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, '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': '6477161', 'n_tokens_mistral': 2533, 'n_tokens_neox': 2246, 'n_words': 380}