<commit_before>'use strict';

angular.module('treasuremapApp')
  .controller('NewCtrl', function ($scope, $http) {
    $scope.message = 'Hello';
    $scope.newLocation = {};
    $scope.alerts = [];

    $scope.closeAlert = function(index) {
      $scope.alerts.splice(index, 1);
    };

    $http.get('/api/categories')
      .success(function (categories) {
        $scope.categories = categories;
      })
      .error(function (data, status) {
        console.log('Error!' + status);
        console.log(data);
      });

    $scope.addLocation = function (form) {
      $scope.submitted = true;

      if ($scope.newLocation === {}) {
        return;
      }

      //if (form.$valid) {
      $http.post('/api/locations', $scope.newLocation)
        .success(function (data, status) {
          console.log('Success!' + status);
          console.log(data);
          $scope.alerts.push({type: 'success', msg: 'New Location successfully added!'});
        })
        .error(function (data, status) {
          console.log('Error!' + status);          $scope.alerts.push({type: 'danger', msg: 'Couln\'t add new location!'});
        });
      //}
    };

  });



<commit_msg>close modal and refresh page<commit_after>'use strict';

angular.module('treasuremapApp')
  .controller('NewCtrl', function ($scope, $http) {
    $scope.message = 'Hello';
    $scope.newLocation = {};
    $scope.alerts = [];

    $scope.closeAlert = function(index) {
      $scope.alerts.splice(index, 1);
    };

    $http.get('/api/categories')
      .success(function (categories) {
        $scope.categories = categories;
      })
      .error(function (data, status) {
        console.log('Error!' + status);
        console.log(data);
      });

    $scope.addLocation = function (form) {
      $scope.submitted = true;

      if ($scope.newLocation === {}) {
        return;
      }

      //if (form.$valid) {
      $http.post('/api/locations', $scope.newLocation)
        .success(function (data, status) {
          console.log('Success!' + status);
          console.log(data);
          $scope.alerts.push({type: 'success', msg: 'New Location successfully added!'});
          window.location.reload();

        })
        .error(function (data, status) {
          console.log('Error!' + status);          $scope.alerts.push({type: 'danger', msg: 'Couln\'t add new location!'});
        });
      //}
    };

  });




{'fraction_non_alphanumeric': 0.17966804979253112, 'fraction_numerical': 0.0008298755186721991, 'mean_word_length': 2.2802721088435374, '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': '5000358', 'n_tokens_mistral': 746, 'n_tokens_neox': 723, 'n_words': 131}