<commit_before>'use strict';

angular.module('core').controller('mainController', ['$scope', 'Menus',
	function($scope, Menus) {
		$scope.isCollapsed = false;
		$scope.menu = Menus.getMenu('topbar');

		$scope.toggleCollapsibleMenu = function() {
			$scope.isCollapsed = !$scope.isCollapsed;
		};

		// Collapsing the menu after navigation
		$scope.$on('$stateChangeSuccess', function() {
			$scope.isCollapsed = false;
		});
	}
])

.directive('youtube', 
	function($window) {
	  return {
	    restrict: "E",


	    scope: {
      		height:   "@",
      		width:    "@",
      		videoId:  "@"  
    	},

	    template: '<div></div>',

	    link: function(scope, element, attrs) {
	      var tag = document.createElement('script');
	      tag.src = "https://www.youtube.com/iframe_api";
	      var firstScriptTag = document.getElementsByTagName('script')[0];
	      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

	      var player;
	      //var searchVideos;

	      $window.onYouTubeIframeAPIReady = function() {
	        player = new YT.Player(element.children()[0], {


		        playerVars: {
	            autoplay: 0,
	            html5: 1,
	            theme: "light",
	            modesbranding: 0,
	            color: "white",
	            iv_load_policy: 3,
	            showinfo: 1,
          		controls: 1,
         	  },
          	  height: scope.height,
              width: scope.width,
              videoId: 'AXwGVXD7qEQ', //set to searchVideos
              events: {
              	'onReady': onPlayerReady,
              	'onStateChange': onPlayerStateChange
              }
       		});
	      };
	    },  
	  }
	});



				var socket = io.connect();
				


	    function onPlayerStateChange(event){
	    	
	    	var socket = io.connect();

	// If player is Playing
			if (event.data === 1) {
				console.log('playing')

						socket.emit('hi', console.log('emitting hi'));
					
				}
			
	//If Player is paused
			if (event.data === 2) {
				console.log('paused')
				}
			}
	//

		   function onPlayerReady(event){
		   	console.log('player ready')
		};<commit_msg>sockets working, implement youtube broadcast play<commit_after>'use strict';

angular.module('core').controller('mainController', ['$scope', 'Menus',
	function($scope, Menus) {
		$scope.isCollapsed = false;
		$scope.menu = Menus.getMenu('topbar');

		$scope.toggleCollapsibleMenu = function() {
			$scope.isCollapsed = !$scope.isCollapsed;
		};
	}
])

.directive('youtube', 
	function($window) {
	  return {
	    restrict: "E",


	    scope: {
      		height:   "@",
      		width:    "@",
      		videoId:  "@"  
    	},

	    template: '<div></div>',

	    link: function(scope, element, attrs) {
	      window.j = attrs;
	      var tag = document.createElement('script');
	      tag.src = "https://www.youtube.com/iframe_api";
	      var firstScriptTag = document.getElementsByTagName('script')[0];
	      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

	      var player;
	      //var searchVideos;

	      $window.onYouTubeIframeAPIReady = function() {
	        player = new YT.Player(element.children()[0], {

		        playerVars: {
	            autoplay: play,
	            html5: 1,
	            theme: "light",
	            modesbranding: 0,
	            color: "white",
	            iv_load_policy: 3,
	            showinfo: 1,
          		controls: 1,
         	  },
          	  height: scope.height,
              width: scope.width,
              videoId: 'AXwGVXD7qEQ', //set to searchVideos
              events: {
              	'onReady': onPlayerReady,
              	'onStateChange': onPlayerStateChange
              }
       		});
	      };
	    },  
	  }
	});



				var socket = io.connect();
				


	    function onPlayerStateChange(event){
	    	
	    	var socket = io.connect();

	// If player is Playing
			if (event.data === 1) {
				console.log('Youtube object: ' + window.j)
				console.log('playing')
				console.log(io)
				socket.emit('hi', console.log('emitting hi'));


				socket.broadcast('Initiate Player', potential variable)

				function VideoPlay() {
					player.videoPlay
				}

				socket.on('Initiate Player', videoPlay())
					
			}
			
	//If Player is paused
			if (event.data === 2) {
				console.log('paused')
				}
			}
	//

		   function onPlayerReady(event){
		   	console.log('player ready')
		};
{'fraction_non_alphanumeric': 0.14285714285714285, 'fraction_numerical': 0.005265567765567766, 'mean_word_length': 1.9761580381471389, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '4150806', 'n_tokens_mistral': 1584, 'n_tokens_neox': 1358, 'n_words': 252}