<commit_before>'use strict';

/**
 * @ngdoc function
 * @name uiApp.controller:SiteeditCtrl
 * @description
 * # SiteeditCtrl
 * Controller of the uiApp
 */
angular.module('uiApp')
  .controller('SiteeditCtrl', function ($scope, $routeParams, $rootScope, SiteFactory) {
    map.showMap(true);

    //SiteFactory.setActiveSiteId($routeParams.siteId);
    //var site = SiteFactory.getActiveSite();

    $scope.sites = [];
    $scope.site = {};
    var isNewSite = false;
    var activeSiteId;
    var blankSite;

    if ($routeParams.siteId === undefined) {
      activeSiteId = null;
      isNewSite = true;
      blankSite = {
        id: '',
        type: 'Feature',
        geometry: {}, // wkt
        properties: {}
      };
    } else {
      activeSiteId = parseInt($routeParams.siteId, 10);
    }

    SiteFactory.getSites().then(
      function() {
        $scope.sites = SiteFactory.sites.features;

        map.clear();

        if (isNewSite) {
          map.loadSites({type: 'FeatureCollection', features: []});
          map.addSite();

        } else {
          // set active site
          for (var i = SiteFactory.sites.features.length - 1; i >= 0; i--) {
            var site = SiteFactory.sites.features[i];
            if (site.id === activeSiteId) {
              $scope.site = site;
            }
          }

          map.loadSites({
            type: 'FeatureCollection',
            features:[$scope.site]
          });
          map.editSite();
        }

          
      }
    );

    $scope.$on('activeFeatureWKT', function (event, wkt) {
      $scope.site.geometry = wkt;
    });

    $scope.save = function () {
      if (isNewSite) {
        console.log('POST new Site');
      } else {
        console.log('PUT edited Site');<commit_msg>remove some old code and white space<commit_after>'use strict';

/**
 * @ngdoc function
 * @name uiApp.controller:SiteeditCtrl
 * @description
 * # SiteeditCtrl
 * Controller of the uiApp
 */
angular.module('uiApp')
  .controller('SiteeditCtrl', function ($scope, $routeParams, $rootScope, SiteFactory) {
    map.showMap(true);

    $scope.sites = [];
    $scope.site = {};
    var isNewSite = false;
    var activeSiteId;
    var blankSite;

    if ($routeParams.siteId === undefined) {
      activeSiteId = null;
      isNewSite = true;
      blankSite = {
        id: '',
        type: 'Feature',
        geometry: {}, // wkt
        properties: {}
      };
    } else {
      activeSiteId = parseInt($routeParams.siteId, 10);
    }

    SiteFactory.getSites().then(
      function() {
        $scope.sites = SiteFactory.sites.features;

        map.clear();

        if (isNewSite) {
          map.loadSites({type: 'FeatureCollection', features: []});
          map.addSite();

        } else {
          // set active site
          for (var i = SiteFactory.sites.features.length - 1; i >= 0; i--) {
            var site = SiteFactory.sites.features[i];
            if (site.id === activeSiteId) {
              $scope.site = site;
            }
          }

          map.loadSites({
            type: 'FeatureCollection',
            features:[$scope.site]
          });
          map.editSite();
        }
      }
    );

    $scope.$on('activeFeatureWKT', function (event, wkt) {
      $scope.site.geometry = wkt;
    });

    $scope.save = function () {
      if (isNewSite) {
        console.log('POST new Site');
      } else {
        console.log('PUT edited Site');
{'fraction_non_alphanumeric': 0.14579710144927535, 'fraction_numerical': 0.002318840579710145, 'mean_word_length': 1.9, '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': '5093410', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1020, 'n_words': 209}