<commit_before>angular.module('profile-app', ['firebase'])
.controller('ProfileCtrl', ['$scope', '$firebaseObject', '$firebaseArray', '$window',function($scope, $firebaseObject, $firebaseArray, $window) {
	//init firebase
	initalizeFirebase();
    
    $scope.userData = {
        name: 'default',
        language: [],
        gpa: 0,
        team: [],
        description: ''
    }
    $scope.txtLanguage = '';
    $scope.username ='';
    
    //$scope.users is an array of users in firebase
    var ref = firebase.database().ref('users');
    $scope.users = $firebaseArray(ref);

	
	//logout function
	$scope.logout = function(){
		firebase.auth().signOut();
	}

    //Add language
    $scope.addLanguage = function(){
        $scope.userData.language.push($scope.txtLanguage);
        $scope.txtLanguage = '';
    }

    //Remove language
    $scope.removeLanguage = function(lan){
        console.log('remove pressed');
        $scope.userData.language.splice($scope.userData.language.indexOf(lan),1);
    }

    //Submit userData
    $scope.submitUserData = function(){
        var database = firebase.database();
        var currentUser = firebase.auth().currentUser;
        //add user data under users/currentUser.uid
        database.ref('users/'+currentUser.uid).set($scope.userData);
        console.log(currentUser.uid);
        console.log('Submitted');
        $scope.refreshInput();
    }

    //refresh input box
    $scope.refreshInput = function(){
        var currentUser = firebase.auth().currentUser;
        var database = firebase.database();
        var ref = database.ref('users/'+currentUser.uid);
        var currentUserData = $firebaseObject(ref);
            currentUserData.$loaded()
                .then(function(data){
                    console.log(data===currentUserData);
                    console.log(currentUserData.name);
                    $scope.userData.name = currentUserData.name;
                    $scope.userData.gpa = currentUserData.gpa;
                    $scope.userData.team = currentUserData.team;
                    $scope.userData.language = currentUserData.language;
                    console.log('refreshed');
                   // $scope.$apply();
                })
                .catch(function(error){
                    console.error("Error: "+error);
                });
    }



    //monitor if the user is logged in or not
	firebase.auth().onAuthStateChanged(user => {<commit_msg>refresh navbar's name after edit name<commit_after>angular.module('profile-app', ['firebase'])
.controller('ProfileCtrl', ['$scope', '$firebaseObject', '$firebaseArray', '$window',function($scope, $firebaseObject, $firebaseArray, $window) {
	//init firebase
	initalizeFirebase();
    
    $scope.userData = {
        name: 'default',
        language: [],
        gpa: 0,
        team: [],
        description: ''
    }
    $scope.txtLanguage = '';
    $scope.username ='';
    
    //$scope.users is an array of users in firebase
    var ref = firebase.database().ref('users');
    $scope.users = $firebaseArray(ref);

	
	//logout function
	$scope.logout = function(){
		firebase.auth().signOut();
	}

    //Add language
    $scope.addLanguage = function(){
        $scope.userData.language.push($scope.txtLanguage);
        $scope.txtLanguage = '';
    }

    //Remove language
    $scope.removeLanguage = function(lan){
        console.log('remove pressed');
        $scope.userData.language.splice($scope.userData.language.indexOf(lan),1);
    }

    //Submit userData
    $scope.submitUserData = function(){
        var database = firebase.database();
        var currentUser = firebase.auth().currentUser;
        //add user data under users/currentUser.uid
        database.ref('users/'+currentUser.uid).set($scope.userData);
        console.log(currentUser.uid);
        console.log('Submitted');
        $scope.refreshInput();
    }

    //refresh input box
    $scope.refreshInput = function(){
        var currentUser = firebase.auth().currentUser;
        var database = firebase.database();
        var ref = database.ref('users/'+currentUser.uid);
        var currentUserData = $firebaseObject(ref);
            currentUserData.$loaded()
                .then(function(data){
                    console.log(data===currentUserData);
                    console.log(currentUserData.name);
                    $scope.userData.name = currentUserData.name;
                    $scope.userData.gpa = currentUserData.gpa;
                    $scope.userData.team = currentUserData.team;
                    $scope.userData.language = currentUserData.language;
                    $scope.username = currentUserData.name;
                    console.log('refreshed');
                   // $scope.$apply();
                })
                .catch(function(error){
                    console.error("Error: "+error);
                });
    }



    //monitor if the user is logged in or not
	firebase.auth().onAuthStateChanged(user => {
{'fraction_non_alphanumeric': 0.14148681055155876, 'fraction_numerical': 0.0007993605115907274, 'mean_word_length': 2.1858688733290896, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1153431', 'n_tokens_mistral': 1409, 'n_tokens_neox': 1356, 'n_words': 241}