<commit_before>'use strict';
/* global angular, $ */

var directivesModule = require('./_index.js');



directivesModule.directive('signinTwitter', ['$timeout', '$rootScope', 'HelloService', 'AppSettings', function($timeout, $rootScope, HelloService, AppSettings) {
	return {
		scope: {
			hello: '=',
			twitterSession: '=',
		},
		templateUrl: 'signin-twitter.html',
		controller: function($scope) {

			/* Hello related init*/
			var hello = $scope.hello;

			// Init service, will also evaluate available cookies
			hello.init({
				twitter: AppSettings.twitterConsumerKey
			},
			{
				oauth_proxy: AppSettings.oauthProxyUrl,
				redirect_uri: '/redirect'
			}
			);

			// If service init result in e.g. login
			// Create global session variable
			hello.on('auth.login', function(auth) {
				hello(auth.network).api('/me').then(function(twitterSession) {
					$rootScope.$apply(function() {
						$rootScope.root.twitterSession = twitterSession;	
						$scope.imageURLClear = twitterSession.profile_image_url_https.split('_normal');
						$rootScope.root.twitterSession.profileURL = $scope.imageURLClear[0]+$scope.imageURLClear[1];
						console.log($rootScope.root.twitterSession);
					});
				}, function() {
					console.log("Authentication failed, try again later");
				});

				hello(auth.network).api('/me/friends').then(function(twitterFriendFeed) {
					console.log(twitterFriendFeed);
					$rootScope.$apply(function() {
						$rootScope.root.twitterFriends = twitterFriendFeed;
					});
					console.log($rootScope.root.twitterFriends);
				}, function(){
					console.log('Unable to load tweets from your followers');
				});
			});

			hello.on('auth.logout', function(auth) {<commit_msg>Add back sort fn to sort feeds on timeline<commit_after>'use strict';
/* global angular, $ */

var directivesModule = require('./_index.js');



directivesModule.directive('signinTwitter', ['$timeout', '$rootScope', 'HelloService', 'AppSettings', function($timeout, $rootScope, HelloService, AppSettings) {
	return {
		scope: {
			hello: '=',
			twitterSession: '=',
		},
		templateUrl: 'signin-twitter.html',
		controller: function($scope) {

			/* Hello related init*/
			var hello = $scope.hello;

			// Init service, will also evaluate available cookies
			hello.init({
				twitter: AppSettings.twitterConsumerKey
			},
			{
				oauth_proxy: AppSettings.oauthProxyUrl,
				redirect_uri: '/redirect'
			}
			);

			// If service init result in e.g. login
			// Create global session variable
			hello.on('auth.login', function(auth) {
				hello(auth.network).api('/me').then(function(twitterSession) {
					$rootScope.$apply(function() {
						$rootScope.root.twitterSession = twitterSession;	
						$scope.imageURLClear = twitterSession.profile_image_url_https.split('_normal');
						$rootScope.root.twitterSession.profileURL = $scope.imageURLClear[0]+$scope.imageURLClear[1];
					});
				}, function() {
					console.log("Authentication failed, try again later");
				});

				hello(auth.network).api('/me/friends').then(function(twitterFriendFeed) {
					twitterFriendFeed.data.sort(function(a,b) {
						return new Date(b.status.created_at) - new Date(a.status.created_at);
					});
					$rootScope.$apply(function() {
						$rootScope.root.twitterFriends = twitterFriendFeed;
						window.debugging = $rootScope.root.twitterFriends.data;
					});
				}, function(){
					console.log('Unable to load tweets from your followers');
				});
			});

			hello.on('auth.logout', function(auth) {
{'fraction_non_alphanumeric': 0.1518951268167569, 'fraction_numerical': 0.001139925904816187, 'mean_word_length': 3.7690217391304346, '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': '4804976', 'n_tokens_mistral': 1308, 'n_tokens_neox': 1046, 'n_words': 189}