<commit_before>angular.module('starter.controllers', [])

.controller('AppCtrl', function($scope, $ionicModal, $timeout) {

  // With the new view caching in Ionic, Controllers are only called
  // when they are recreated or on app start, instead of every page change.
  // To listen for when this page is active (for example, to refresh data),
  // listen for the $ionicView.enter event:
  //$scope.$on('$ionicView.enter', function(e) {
  //});

  // Form data for the login modal
  $scope.loginData = {};

  // Form data for the signUp modal
  $scope.signUpData = {};

        console.log(window.localStorage);

        var userData = JSON.parse(window.localStorage['user-data'] || '{}');
        console.log(userData);
        if (userData != null) {
            $scope.username = userData.username;
            $scope.email = userData.email;
            $scope.token = userData.token;

        }

  // Create the login modal that we will use later
  $ionicModal.fromTemplateUrl('templates/login.html', {
    scope: $scope
  }).then(function(modal) {
    $scope.modalLogin = modal;
  });

  // Create the signUp modal that we will use later
  $ionicModal.fromTemplateUrl('templates/signup.html', {
    scope: $scope
  }).then(function(modal) {
    $scope.modalSignUp = modal;
  });

  // Triggered in the login modal to close it
  $scope.closeModal = function() {
    $scope.modal.hide();
  };

  // Open the login modal
  $scope.login = function() {
      $scope.modal = $scope.modalLogin;
      $scope.modal.show();
  };
  // Open the signUp modal
  $scope.signUp = function() {
      $scope.modal = $scope.modalSignUp;
      $scope.modal.show();
  };

    // Richiede il logout
    $scope.logout = function() {
        if(confirm('Vuoi effettuare il logout')) {
            $scope.doLogout();
        }
    };



// Perform the login action when the user submits the login form
    $scope.doLogout = function() {
        console.log('Doing logout', $scope.loginData);
        BaasBox.logout()
            .done(function (res) {
                console.log(res);
                $scope.username = null;
            })
            .fail(function (error) {
                console.log("error ", error);
            })
        window.localStorage['user-data'] = null;
        $scope.username = null;
    };




        // Perform the login action when the user submits the login form
  $scope.doLogin = function() {
    console.log('Doing login', $scope.loginData);

      BaasBox.login($scope.loginData.username, $scope.loginData.password)
          .done(function (user) {
              console.log("Logged in ", user);
              $scope.username = user.username;
              $scope.email = user.visibleByTheUser.email;

              window.localStorage['user-data'] = JSON.stringify({
                  'username' : user.username,
                  'password' : <PASSWORD>,
                  'token' : <PASSWORD>.token
              });

              console.log(window.localStorage);

          })
          .fail(function (err) {
              console.log("error ", err);
          });


    // Simulate a login delay. Remove this and replace with your login
    // code if using a login system
    $timeout(function() {
      $scope.closeModal();
    }, 1000);
  };

  $scope.doSignUp = function() {
    console.log('Doing SignUp', $scope.signUpData);

      BaasBox.signup($scope.signUpData.username, $scope.signUpData.password, {"visibleByTheUser": {"email" : $scope.signUpData.email}})
          .done(function (res) {
              console.log("signup ", res);
          })
          .fail(function (error) {$scope.signUpData
              console.log("error ", error);
          });



    // Simulate a SignUp delay. Remove this and replace with your SignUp
    // code if using a SignUp system
    $timeout(function() {
      $scope.closeModal();
    }, 1000);
  };
})

.controller('PlaylistsCtrl', function($scope) {
  $scope.playlists = [
    { title: 'Reggae', id: 1 },
    { title: 'Chill', id: 2 },
    { title: 'Dubstep', id: 3 },
    { title: 'Indie', id: 4 },
    { title: 'Rap', id: 5 },
    { title: 'Cowbell', id: 6 }
  ];
})

.controller('PlaylistCtrl', function($scope, $stateParams) {
});
<commit_msg>Add Local Storage in SignUp<commit_after>angular.module('starter.controllers', [])

.controller('AppCtrl', function($scope, $ionicModal, $timeout) {

  // With the new view caching in Ionic, Controllers are only called
  // when they are recreated or on app start, instead of every page change.
  // To listen for when this page is active (for example, to refresh data),
  // listen for the $ionicView.enter event:
  //$scope.$on('$ionicView.enter', function(e) {
  //});

  // Form data for the login modal
  $scope.loginData = {};

  // Form data for the signUp modal
  $scope.signUpData = {};

        console.log(window.localStorage);

        var userData = JSON.parse(window.localStorage['user-data'] || '{}');
        console.log(userData);
        if (userData != null) {
            $scope.username = userData.username;
            $scope.email = userData.email;
            $scope.token = userData.token;

        }

  // Create the login modal that we will use later
  $ionicModal.fromTemplateUrl('templates/login.html', {
    scope: $scope
  }).then(function(modal) {
    $scope.modalLogin = modal;
  });

  // Create the signUp modal that we will use later
  $ionicModal.fromTemplateUrl('templates/signup.html', {
    scope: $scope
  }).then(function(modal) {
    $scope.modalSignUp = modal;
  });

  // Triggered in the login modal to close it
  $scope.closeModal = function() {
    $scope.modal.hide();
  };

  // Open the login modal
  $scope.login = function() {
      $scope.modal = $scope.modalLogin;
      $scope.modal.show();
  };
  // Open the signUp modal
  $scope.signUp = function() {
      $scope.modal = $scope.modalSignUp;
      $scope.modal.show();
  };

    // Richiede il logout
    $scope.logout = function() {
        if(confirm('Vuoi effettuare il logout')) {
            $scope.doLogout();
        }
    };



// Perform the login action when the user submits the login form
    $scope.doLogout = function() {
        console.log('Doing logout', $scope.loginData);
        BaasBox.logout()
            .done(function (res) {
                console.log(res);
                $scope.username = null;
            })
            .fail(function (error) {
                console.log("error ", error);
            })
        window.localStorage['user-data'] = null;
        $scope.username = null;
    };




        // Perform the login action when the user submits the login form
  $scope.doLogin = function() {
    console.log('Doing login', $scope.loginData);

      BaasBox.login($scope.loginData.username, $scope.loginData.password)
          .done(function (user) {
              console.log("Logged in ", user);
              $scope.username = user.username;
              $scope.email = user.visibleByTheUser.email;

              window.localStorage['user-data'] = JSON.stringify({
                  'username' : user.username,
                  'password' : <PASSWORD>,
                  'token' : user.token
              });

              console.log(window.localStorage);

          })
          .fail(function (err) {
              console.log("error ", err);
          });


    // Simulate a login delay. Remove this and replace with your login
    // code if using a login system
    $timeout(function() {
      $scope.closeModal();
    }, 1000);
  };

  $scope.doSignUp = function() {
    console.log('Doing SignUp', $scope.signUpData);

      BaasBox.signup($scope.signUpData.username, $scope.signUpData.password, {"visibleByTheUser": {"email" : $scope.signUpData.email}})
          .done(function (res) {
              console.log("signup ", user);

              $scope.username = user.username;
              $scope.email = $scope.signUpData.email;
              window.localStorage['user-data'] = JSON.stringify({
                  'username' : $scope.signUpData.username,
                  'password' : <PASSWORD>,
                  'token' : user.token
              });

              console.log(window.localStorage);
          })
          .fail(function (error) {$scope.signUpData
              console.log("error ", error);
          });



    // Simulate a SignUp delay. Remove this and replace with your SignUp
    // code if using a SignUp system
    $timeout(function() {
      $scope.closeModal();
    }, 1000);
  };
})

.controller('PlaylistsCtrl', function($scope) {
  $scope.playlists = [
    { title: 'Reggae', id: 1 },
    { title: 'Chill', id: 2 },
    { title: 'Dubstep', id: 3 },
    { title: 'Indie', id: 4 },
    { title: 'Rap', id: 5 },
    { title: 'Cowbell', id: 6 }
  ];
})

.controller('PlaylistCtrl', function($scope, $stateParams) {
});

{'fraction_non_alphanumeric': 0.14482447228806863, 'fraction_numerical': 0.0031606276103397675, 'mean_word_length': 2.164285714285714, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, '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': '1033865', 'n_tokens_mistral': 2710, 'n_tokens_neox': 2594, 'n_words': 627}